292013
 

环境:

No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 12.04.2 LTS
Release:	12.04
Codename:	precise

1.安装所需工具

sudo apt-get install autoconf automake libtool gcc gcc- g++ make libuuid-dev/uuid-dev git

2.下载安装ZeroMQ
2.1下载地址:

wget http://zeromq.org/area:download

2.2编译安装


$ cd zeromq-3.2.3
$ ./configure
$ make
$ sudo make install

3.下载安装jzmq
3.1下载地址:


wget https://codeload.github.com/zeromq/jzmq/zip/master

3.2编译安装


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

4.配置环境变量


$ sudo bash
$ echo /usr/local/lib > /etc/ld.so.conf.d/local.conf
$ ldconfig
$ echo CLASSPATH=/usr/local/share/java/zmq.jar:. >> /etc/environment
$ echo export LD_LIBRARY_PATH=/usr/local/lib > /etc/profile.d/ldlibrarypath.sh
$ exit

经过测试上面的环境变量配置没有必要搞的那么麻烦,我们只需要修改文件~/.bashrc添加环境变量就OK


echo CLASSPATH=/usr/local/share/java/zmq.jar:. >> ~/.bashrc
echo export LD_LIBRARY_PATH=/usr/local/lib > ~/.bashrc

修改完成后加载最新环境变量:source ~/.bashrc,或者重新打开一个终端。

5.验证安装
5.1修改运行脚本添加jvm参数java.library.path


$ cd jzmq-master/perf/
$ vim local_lat.sh
#!/bin/sh
#java -classpath "../src/zmq.jar:zmq-perf.jar" local_lat $@
#如果出现错误no XXX in java.library.path,就添加jvm参数java.library.path
java -Djava.library.path=/usr/local/lib -classpath "../src/zmq.jar:zmq-perf.jar" local_lat $@

$ vim remote_lat.sh
#!/bin/sh
#java -classpath "../src/zmq.jar:zmq-perf.jar" remote_lat $@
#如果出现错误no XXX in java.library.path,就添加jvm参数java.library.path
java -Djava.library.path=/usr/local/lib -classpath "../src/zmq.jar:zmq-perf.jar" remote_lat $@

5.2运行
先运行


$ ./local_lat.sh tcp://127.0.0.1:5555 1 100

新建终端运行


$ ./remote_lat.sh tcp://127.0.0.1:5555 1 100

5.3显示结果,测试安装成功


message size: 1 [B]
roundtrip count: 100
mean latency: 60.0 [us]

对不起,评论功能目前被关闭。