[转]Centos安装zeromq和jzmq

时间:2021-09-25 16:18:54

Required packages:

    autoconf
automake
libtool
gcc
gcc-g++
make
libuuid-dev
git
java-1.6.0-openjdk-devel

1) Download and unpack ZeroMQ 2.1.10.

$ wget http://download.zeromq.org/zeromq-2.1.10.tar.gz
$ tar zxf zeromq-2.1.10.tar.gz

2) Build

$ cd zeromq-2.1.10
$ ./configure --with-pgm
$ make
$ sudo make install

Now libzmq.so should reside in /usr/local/lib

3) Clone JZMQ from GitHub.

$ git clone https://github.com/zeromq/jzmq.git

4) Build

$ cd jzmq
$ ./autogen.sh
$ ./configure
$ make
$ sudo make install

5) Setup environment

$ sudo bash

optional step #1 (not required on Debian platforms)

    # echo /usr/local/lib > /etc/ld.so.conf.d/local.conf
# ldconfig

optional step #2

    # echo CLASSPATH=/usr/local/share/java/zmq.jar:. >> /etc/environment
Incredibly limiting as you will still need to override to include any other directory or JAR file.

optional step #3

    # echo export LD_LIBRARY_PATH=/usr/local/lib > /etc/profile.d/ldlibrarypath.sh
This is pretty much a workaround to a JRE defect:
http://lists.fedoraproject.org/pipermail/java-devel/2011-March/004153.html
# exit

Then log out and log back in again.

6) Verify new environment

$ echo $CLASSPATH
/usr/local/share/java/zmq.jar:.
$ echo $LD_LIBRARY_PATH
/usr/local/lib

7) Test with Java ?MQ performance examples

$ cd jzmq/perf
$ java local_lat tcp://127.0.0.1:5000 1 100

This will fail if zmq.jar cannot be found in the class path.
This will fail if libjzmq.so or libzmq.so cannot be found in java.library.path or LD_LIBRARY_PATH.

If you skip optional step #1 you will need to specify the library path:

$ LD_LIBRARY_PATH=/usr/local/lib java local_lat tcp://127.0.0.1:5000 1 100

If you skip optional step #2 you will need to specify the class path:

$ java -cp /usr/local/share/java/zmq.jar:. local_lat tcp://127.0.0.1:5000 1 100

Note that setting -Djava.library.path is insufficient for libjzmq.so to find libzmq.so but it is sufficient if you take optional step #1 and skip optional step #3, i.e. LD_LIBRARY_PATH is not overridden but ld.so.conf is updated.

$ java -Djava.library.path=/usr/local/lib local_lat tcp://127.0.0.1:5000 1 100

http://chqz1987.blog.163.com/blog/static/51438311201351511493091/