【转】magent编译安装及常见错误

[size=medium]【原文】http://blog.csdn.net/liu251890347/article/details/38412945?utm_source=tuicool


安装magent到/usr/local/下

cd /usr/local
mkdir magent
cd magent/
wget http://memagent.googlecode.com/files/magent-0.6.tar.gz
tar zxvf magent-0.6.tar.gz
/sbin/ldconfig
sed -i "s#LIBS = -levent#LIBS = -levent -lm#g" Makefile
make

错误1:

gcc -lrt -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

解决办法:
vi ketama.h

在开头加入

#ifndef SSIZE_MAX
# define SSIZE_MAX 32767
#endif

错误2:

gcc -Wall -g -O2 -I/usr/local/include -m64 -c -o magent.o magent.c
gcc -Wall -g -O2 -I/usr/local/include -m64 -c -o ketama.o ketama.c
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’:
(.text+0×449): undefined reference to `clock_gettime’
/usr/lib64/libevent.a(event.o): In function `event_base_new’:
(.text+0x72a): undefined reference to `clock_gettime’
collect2: ld returned 1 exit status
make: *** [magent] Error 1

解决办法
vim Makefile

CFLAGS = -Wall -g -O2 -I/usr/local/include $(M64)
改为:
CFLAGS = -lrt -Wall -g -O2 -I/usr/local/include $(M64)

错误3:centos 6

# make
gcc -Wall -g -O2 -I/usr/local/include -m64 -c -o magent.o magent.c
gcc -Wall -g -O2 -I/usr/local/include -m64 -c -o ketama.o ketama.c
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:没有那个文件或目录
make: *** [magent] 错误 1
解决办法

ln -s /usr/lib64/libm.so /usr/lib64/libm.a

注:有可能还会报错 gcc: /usr/lib64/libevent.a: 没有那个文件或目录
如果有,可执行
vi Makefile

找到 LIBS = /usr/lib64/libevent.a /usr/lib64/libm.a
修改 LIBS = /usr/libevent 的安装路径/libevent.a /usr/lib64/libm.a
例: LIBS = /usr/lib/libevent.a /usr/lib64/libm.a

查看magent是否安装成功
cd /usr/bin/
./magent

please provide -s "ip:port" argument

memcached agent v0.6 Build-Date: Oct 15 2012 16:12:30
Usage:
-h this message
-u uid
-g gid
-p port, default is 11211. (0 to disable tcp support)
-s ip:port, set memcached server ip and port
-b ip:port, set backup memcached server ip and port
-l ip, local bind ip address, default is 0.0.0.0
-n number, set max connections, default is 4096
-D don't go to background
-k use ketama key allocation algorithm
-f file, unix socket path to listen on. default is off
-i number, set max keep alive connections for one memcached server, default is 20
-v verbose[/size]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值