Memcached和Magent简介及安装
memcached的安装
安装libevent
[root@test ~]# wget https://cloud.github.com/downloads/libevent/libevent/libevent-2.0.19-stable.tar.gz [root@test ~]# tar zxvf libevent-2.0.19-stable.tar.gz [root@test ~]# cd libevent-2.0.19-stable [root@test libevent-2.0.19-stable]# ./configure --prefix=/usr/ [root@test libevent-2.0.19-stable]# make && make install
2.安装memcached
[root@test ~]# wget http://www.memcached.org/files/memcached-1.4.22.tar.gz [root@test ~]# tar zxvf memcached-1.4.22.tar.gz [root@test memcached-1.4.22]# ./configure --prefix=/usr/local/memcached --with-libevent=/usr/ [root@test memcached-1.4.22]# make && make install
magent的安装
magent是一款开源的Memcached代理服务器软件,其项目网址为:
[root@test ~]# tar zxvf magent-0.6.tar.gz [root@test ~]# mkdir /usr/local/magent [root@test magent]# tar zxvf magent-0.6.tar.gz ketama.c ketama.h magent.c Makefile [root@test magent]# make gcc -Wall -g -O2 -I/usr/local/include -m64 -c -o magent.o magent.c magent.c: In function ‘writev_list’: magent.c:729: error: ‘SSIZE_MAX’ undeclared (first use in this function) magent.c:729: error: (Each undeclared identifier is reported only once magent.c:729: error: for each function it appears in.) make: *** [magent.o] Error 1 解决方法: [root@test magent]# vim ketama.h #ifndef SSIZE_MAX #define SSIZE_MAX 32767 #endif #ifndef _KETAMA_H #define _KETAMA_H struct dot { unsigned int point; int srvid; }; struct ketama { unsigned int numpoints; struct dot *dot; int count; char **name; int *weight; int totalweight; }; int create_ketama(struct ketama *, int); void free_ketama(struct ketama *); int get_server(struct ketama *, const char *); #endif [root@test magent]# make gcc -Wall -g -O2 -I/usr/local/include -m64 -o magent magent.o ketama.o /usr/lib64/libevent.a /usr/lib64/libm.a gcc: /usr/lib64/libevent.a: No such file or directory gcc: /usr/lib64/libm.a: No such file or directory make: *** [magent] Error 1 解决方案: [root@test magent]# ln -svf /usr/lib/libevent* /usr/lib64/ `/usr/lib64/libevent-2.0.so.5‘ -> `/usr/lib/libevent-2.0.so.5‘ `/usr/lib64/libevent-2.0.so.5.1.7‘ -> `/usr/lib/libevent-2.0.so.5.1.7‘ `/usr/lib64/libevent.a‘ -> `/usr/lib/libevent.a‘ `/usr/lib64/libevent_core-2.0.so.5‘ -> `/usr/lib/libevent_core-2.0.so.5‘ `/usr/lib64/libevent_core-2.0.so.5.1.7‘ -> `/usr/lib/libevent_core-2.0.so.5.1.7‘ `/usr/lib64/libevent_core.a‘ -> `/usr/lib/libevent_core.a‘ `/usr/lib64/libevent_core.la‘ -> `/usr/lib/libevent_core.la‘ `/usr/lib64/libevent_core.so‘ -> `/usr/lib/libevent_core.so‘ `/usr/lib64/libevent_extra-2.0.so.5‘ -> `/usr/lib/libevent_extra-2.0.so.5‘ `/usr/lib64/libevent_extra-2.0.so.5.1.7‘ -> `/usr/lib/libevent_extra-2.0.so.5.1.7‘ `/usr/lib64/libevent_extra.a‘ -> `/usr/lib/libevent_extra.a‘ `/usr/lib64/libevent_extra.la‘ -> `/usr/lib/libevent_extra.la‘ `/usr/lib64/libevent_extra.so‘ -> `/usr/lib/libevent_extra.so‘ `/usr/lib64/libevent.la‘ -> `/usr/lib/libevent.la‘ `/usr/lib64/libevent_pthreads-2.0.so.5‘ -> `/usr/lib/libevent_pthreads-2.0.so.5‘ `/usr/lib64/libevent_pthreads-2.0.so.5.1.7‘ -> `/usr/lib/libevent_pthreads-2.0.so.5.1.7‘ `/usr/lib64/libevent_pthreads.a‘ -> `/usr/lib/libevent_pthreads.a‘ `/usr/lib64/libevent_pthreads.la‘ -> `/usr/lib/libevent_pthreads.la‘ `/usr/lib64/libevent_pthreads.so‘ -> `/usr/lib/libevent_pthreads.so‘ `/usr/lib64/libevent.so‘ -> `/usr/lib/libevent.so‘ [root@test magent]# make gcc -Wall -g -O2 -I/usr/local/include -m64 -o magent magent.o ketama.o /usr/lib64/libevent.a /usr/lib64/libm.a gcc: /usr/lib64/libm.a: No such file or directory make: *** [magent] Error 1 解决方案: 如果是64bit的系统则不会在/usr/lib64/libm.a 生成,如果是32bit即会有 [root@test magent]# yum install glibc glibc-devel [root@test magent]# cp /usr/lib64/libm.so /usr/lib64/libm.a [root@test magent]# make gcc -Wall -g -O2 -I/usr/local/include -m64 -o magent magent.o ketama.o /usr/lib64/libevent.a /usr/lib64/libm.a /usr/lib64/libevent.a(event.o): In function `gettime‘: /usr/local/src/libevent-2.0.19-stable/event.c:366: undefined reference to `clock_gettime‘ /usr/lib64/libevent.a(event.o): In function `detect_monotonic‘: /usr/local/src/libevent-2.0.19-stable/event.c:336: undefined reference to `clock_gettime‘ collect2: ld returned 1 exit status make: *** [magent] Error 1 解决方案: [root@test magent]# vim Makefile CFLAGS = -Wall -g -O2 -I/usr/local/include $(M64) 改为: CFLAGS = -lrt -Wall -g -O2 -I/usr/local/include $(M64) [root@test magent]# make gcc -lrt -Wall -g -O2 -I/usr/local/include -m64 -o magent magent.o ketama.o /usr/lib64/libevent.a /usr/lib64/libm.a [root@test magent]# ls 终于成功了- -! ketama.c ketama.h ketama.o magent magent-0.6.tar.gz magent.c magent.o Makefile [root@test magent]# cp magent /bin/
本文出自 “Linux革命” 博客,请务必保留此出处http://kaibinyuan.blog.51cto.com/7304008/1612364
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。