首页 > 系统应用 > memcache > memcached 安装记录
2015
08-03

memcached 安装记录

分别将 libevent-1.1a.tar.gz 和 memcached-1.1.12.tar.gz 解开包、编译、安装:
# tar -xzf libevent-1.1a.tar.gz
# cd libevent-1.1a
# ./configure
# make
# make install
# cd ..
# tar -xzf memcached-1.1.12.tar.gz
# cd memcached-1.1.12
# ./configure --with-libevent=/usr/local/libevent
# make
# make install
 
LD_DEBUG=libs /usr/local/bin/memcached -v
ln -sv /usr/local/lib/libevent-1.2.so.1  /usr/lib/libevent-1.2.so.1
LD_DEBUG=libs /usr/local/bin/memcached -v
/usr/local/bin/memcached -d -m 128 -u httpd
 
/usr/local/bin/memcached -d -m 128 -l 192.168.1.1 -p 11211 -u httpd
 
-d 以守护程序(daemon)方式运行 memcached;
-m 设置 memcached 可以使用的内存大小,单位为 M;
-l 设置监听的 IP 地址,如果是本机的话,通常可以不设置此参数;
-p 设置监听的端口,默认为 11211,所以也可以不设置此参数;
-u 指定用户,如果当前为 root 的话,需要使用此参数指定用户。
 
 
 
~]# ll /usr/local/lib/ |grep libevent
lrwxrwxrwx  1 root root      21 Dec 18 14:43 libevent-1.2.so.1 -> libevent-1.2.so.1.0.3
-rwxr-xr-x  1 root root  217866 Dec 18 14:43 libevent-1.2.so.1.0.3
-rw-r--r--  1 root root  282016 Dec 18 14:43 libevent.a
-rwxr-xr-x  1 root root     811 Dec 18 14:43 libevent.la
lrwxrwxrwx  1 root root      21 Dec 18 14:43 libevent.so -> libevent-1.2.so.1.0.3
 
 
加php的memcache扩展,到php的源码包ext目录下面
tar xvf memcache-2.2.3.tgz
cd memcache-2.2.3
/usr/local/php5/bin/phpize
./configure --with-php-config=/usr/local/php5/bin/php-config
make install
vi /etc/php.ini
extension = "memcache.so"
 
 
安装libmemcached
 
安装之前要先按照memcache 服务端,可以不起用但是要装,不然提示找不到库
 
cd libmemcached-0.30
./configure
make -j4
make install
 
如果按照的时候报
udp_request_id':
/var/go2packages/libmemcached-0.37/clients/ms_conn.c:184: undefined reference to `__sync_fetch_and_add_4'
clients/ms_conn.o: In function `ms_reconn_socks':
/var/go2packages/libmemcached-0.37/clients/ms_conn.c:1055: undefined reference to `__sync_fetch_and_add_4'
clients/ms_conn.o: In function `ms_reconn':
/var/go2packages/libmemcached-0.37/clients/ms_conn.c:924: undefined reference to `__sync_fetch_and_add_4'
/var/go2packages/libmemcached-0.37/clients/ms_conn.c:960: undefined reference to `__sync_fetch_and_add_4'
clients/ms_thread.o: In function `ms_setup_thread':
/var/go2packages/libmemcached-0.37/clients/ms_thread.c:215: undefined reference to `__sync_fetch_and_add_4'
clients/ms_thread.o:/var/go2packages/libmemcached-0.37/clients/ms_thread.c:198: more undefined references to `__sync_fetch_and_add_4' follow
collect2: ld returned 1 exit status
make[2]: *** [clients/memslap] Error 1
make[2]: Leaving directory `/var/go2packages/libmemcached-0.37'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/var/go2packages/libmemcached-0.37'
make: *** [all] Error 2
 
 
解决方法:
 
./configure --disable-64bit CFLAGS="-O3 -march=i686"
 
tar xvf memcached-1.0.0.tgz
cd memcached-1.0.0
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make -j4
make install
最后编辑:
作者:saunix
大型互联网公司linux系统运维攻城狮,专门担当消防员

留下一个回复