rhel 5 下编译安装gearmand 博客分类: gearmand redhat 5gearmand编译
redhat 5 下安装gearmand
自带的bootst库是boost-1.33.1-10.el5,版本太低,需要Boost >= 1.39
boost库下载
http://packages.atrpms.net/dist/el5/boost/
rpm -ivh boost-date-time-1.39.0-9.el5.x86_64.rpm
rpm -ivh boost-filesystem-1.39.0-9.el5.x86_64.rpm
rpm -ivh boost-system-1.39.0-9.el5.x86_64.rpm
rpm -ivh boost-filesystem-1.39.0-9.el5.x86_64.rpm
rpm -ivh boost-graph-1.39.0-9.el5.x86_64.rpm
rpm -ivh boost-iostreams-1.39.0-9.el5.x86_64.rpm
rpm -ivh boost-math-1.39.0-9.el5.x86_64.rpm
rpm -ivh boost-program-options-1.39.0-9.el5.x86_64.rpm
rpm -ivh boost-python-1.39.0-9.el5.x86_64.rpm
rpm -ivh boost-regex-1.39.0-9.el5.x86_64.rpm
rpm -ivh boost-serialization-1.39.0-9.el5.x86_64.rpm
rpm -ivh boost-signals-1.39.0-9.el5.x86_64.rpm
rpm -ivh boost-test-1.39.0-9.el5.x86_64.rpm
rpm -ivh boost-thread-1.39.0-9.el5.x86_64.rpm
rpm -ivh boost-wave-1.39.0-9.el5.x86_64.rpm
rpm -ivh boost-1.39.0-9.el5.x86_64.rpm
rpm -Uvh boost-devel-1.39.0-9.el5.x86_64.rpm #由于系统已经自带了低版本的,用U防止冲突
rpm -ivh gperf-el5-3.0.1-7.2.2.x86_64.rpm
libevent库安装rpm包后也会找不到,直接下源代码编译安装:
cd /home/sjw/libevent-1.4.14b-stable
./configue
make
make install
执行configure
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib:/usr/lib64
./configure --prefix=/usr/local/gearman --with-mysql --with-sqlite3=no
Configuration summary for gearmand version 1.1.12
* Installation prefix: /usr/local/gearman
* System type: unknown-linux-gnu
* Host CPU: x86_64
* C Compiler: cc -std=gnu99 cc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-46)
* C Flags: -g -O2 -Wno-unknown-pragmas -Wno-pragmas -Wall -Wextra -Wno-attributes -Wbad-function-cast -Wchar-subscripts -Wcomment -Wfloat-equal -Wformat-security -Wformat=2 -Wformat-y2k -Wmissing-field-initializers -Wmissing-noreturn -Wmissing-prototypes -Wnested-externs -Wnormalized=id -Wpointer-arith -Wpointer-sign -Wredundant-decls -Wshadow -Wsign-compare -Wswitch-enum -Wundef -funsafe-loop-optimizations -Wunused -Wunused-variable -Wunused-parameter -Wwrite-strings -fwrapv -pipe -fPIE -pie -Wpacked
* C++ Compiler: c++ c++ (GCC) 4.1.2 20080704 (Red Hat 4.1.2-46)
* C++ Flags: -g -O2 -Wno-unknown-pragmas -Wno-pragmas -Wall -Wextra -Wno-attributes -Wchar-subscripts -Wcomment -Wctor-dtor-privacy -Wfloat-equal -Wformat=2 -Wformat-y2k -Wmissing-field-initializers -Wnon-virtual-dtor -Wnormalized=id -Woverloaded-virtual -Wpointer-arith -Wredundant-decls -Wshadow -Wsign-compare -Wswitch-enum -Wundef -funsafe-loop-optimizations -Wunused -Wunused-variable -Wunused-parameter -Wwrite-strings -Wformat-security -fwrapv -pipe -fPIE -pie -Wpacked
* CPP Flags: -fvisibility=hidden
* LIBS:
* LDFLAGS Flags:
* Assertions enabled: no
* Debug enabled: no
* Warnings as failure: no
* Building with libsqlite3 no
* Building with libdrizzle yes
* Building with libmemcached not found
* Building with libpq no
* Building with tokyocabinet no
* Building with libmysql yes
* SSL enabled: no
* cyassl found: no
* openssl found: yes
* make -j: 17
* VCS checkout: no
* sphinx-build: :
如果gcc版本低于4.4.7可能出现以下错误
make时出现错误:./libgearman-1.0/gearman.h:53:27:error: tr1/cinttypes: No such file or directory
推断是gcc编译器的问题,执行命令:
yum install gcc44 gcc44-c++ libstdc++44-devel –y
要安装gcc44,如果不能上网,可以安装下载的rpm包:
rpm -Uvh gcc44-4.4.7-1.el5.x86_64.rpm libgomp-4.4.7-1.el5.x86_64.rpm gcc44-c++-4.4.7-1.el5.x86_64.rpm libstdc++44-devel-4.4.7-1.el5.x86_64.rpm gcc44-gfortran-4.4.7-1.el5.x86_64.rpm libgfortran44-4.4.7-1.el5.x86_64.rpm
然后:
export CC=/usr/bin/gcc44
export CXX=/usr/bin/g++44
重新configure, makeclean, make
出现错误:
[/root/gearmand-1.1.12] make
make -j17 all-am
make[1]: Entering directory `/root/gearmand-1.1.12'
CXXLD libtest/libtest.la
CXXLD t/unittest
CXXLD t/skip
CXXLD gearmand/hostile_gearmand
/usr/bin/ld: cannot find -lmysqlclient
collect2: ld returned 1 exit status
make[1]: *** [gearmand/hostile_gearmand] 错误 1
make[1]: Leaving directory `/root/gearmand-1.1.12'
make: *** [all] 错误 2
解决:
安装包:
rpm -ivh MySQL-shared-compat-5.6.15-1.rhel5.x86_64.rpm
(由于机器上已经安装MySQL-5.6.15,所以安装mysql-devel-5.0.77-3.el5.x86_64.rpm和mysql-5.0.77-3.el5.x86_64.rpm报包冲突)
建软链接:
ln -s /usr/lib64/libmysqlclient.so.16.0.0 /usr/lib64/mysql/libmysqlclient.so
结果还是报错,看编译目录下的Makefile文件中竟然有“MYSQL_LDFLAGS = -L/usr/lib64 -lmysqlclient -lpthread -lm -lrt -ldl”,坑爹啊,果断重建软链接
ln -s /usr/lib64/libmysqlclient.so.16.0.0 /usr/lib64/libmysqlclient.so
问题解决!
经过千难万险,终于可以启动了:
/usr/local/gearman/sbin/gearmand -d -L 165.32.9.202 -p 8090 --log-file=/tmp/gearmand-8090.log