目前,服务器使用的zeromq的版本是4.1.2, 存在一个bug:
Resource temporarily unavailable (src/signaler.cpp:282)
如果直接升级zeromq的版本担心引起不兼容问题,以及其他依赖zmq的程序异常。所以决定在4.1.2上自己打补丁。
补丁打法有两种:
yum install -y git build-essential libtool autoconf automake pkg-config unzip libkrb5-dev gcc-c++ gcc
开始下载源码&&编译
git clone https://github.com/zeromq/zeromq4-1.git
cd zeromq4-1
git checkout v4.1.2
wget https://raw.githubusercontent.com/pijyoi/libzmq/596d6e5b1c2d060b2b5b09d01f7ebd207041791d/src/mailbox.cpp -O mailbox.cpp --no-check-certificate
wget https://raw.githubusercontent.com/pijyoi/libzmq/596d6e5b1c2d060b2b5b09d01f7ebd207041791d/src/signaler.cpp -O signaler.cpp --no-check-certificate
wget https://raw.githubusercontent.com/pijyoi/libzmq/596d6e5b1c2d060b2b5b09d01f7ebd207041791d/src/signaler.hpp -O signaler.hpp --no-check-certificate
sh autogen.sh
./configure
make
出现如下报错
No package 'libsodium' found
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.
Alternatively, you may set the environment variables sodium_CFLAGS
and sodium_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
make: *** [config.status] 错误 1
缺少一个库libsodium
需要额外编译
cd /tmp && git clone git://github.com/jedisct1/libsodium.git && cd libsodium && git checkout e2a30a && ./autogen.sh && ./configure --prefix=/usr/ && make check && make install && ldconfig
又出现新的报错
autoreconf: running: aclocal --force -I m4
configure.ac:1: error: Autoconf version 2.65 or higher is required
configure.ac:1: the top level
autom4te: /usr/bin/m4 failed with exit status: 63
aclocal: autom4te failed with exit status: 63
autoreconf: aclocal failed with exit status: 63
需要编译2.65版本以上的autoconf
wget ftp://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz
tar zxvf autoconf-2.69.tar.gz
cd autoconf-2.69
./configure --prefix=/usr/
make && make install
编译zeromq报错
checking for sodium... configure: error: Package requirements (libsodium) were not met:
No package 'libsodium' found
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.
Alternatively, you may set the environment variables sodium_CFLAGS
and sodium_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
上述报错说明zeromq无法找到我们刚才编译的libsodium,需要在/usr/lib/pkgconfig增加文件libsodium.pc
prefix=/usr
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
Name: libsodium
Version: 0.4.3
Description: sodium library
Libs: -L${libdir} -lsodium
Cflags: -I${includedir}
同时需要在/etc/ld.so.conf增加一行:/usr/lib/
echo /usr/lib >>/etc/ld.so.conf