Linux(CentOS 5.x)下Memcached安装
Linux(CentOS 5.x)下安装:
命令:
mkdir tmp
cd /tmp
wget http://test.3g.cn/xiaohu/soft/Linux/libevent-2.0.12-stable.tar.gz 注:memcached 用到了 libevent 这个库用于 Socket 的处理,所以 还需要安装 libevent
tar zxvf libevent-2.0.12-stable.tar.gz
cd libevent-2.0.12-stable
./configure -prefix=/usr/local/libevent
make
make install
cd ~
cd /tmp
http://memcached.googlecode.com/files/memcached-1.4.13.tar.gz
tar zxvf memcached-1.4.13.tar.gz
cd memcached-1.4.13
./configure -prefix=/usr/local/memcached --with-libevent=/usr/local/libevent 注:安装memcached时需要指定libevent的安装位置
make
make install
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/libevent/lib 注:将libevent的lib目录加入LD_LIBRARY_PATH里
vi /etc/sysconfig/iptables
wget http://test.3g.cn/xiaohu/soft/Linux/libevent-2.0.12-stable.tar.gz 注:memcached 用到了 libevent 这个库用于 Socket 的处理,所以 还需要安装 libevent
tar zxvf libevent-2.0.12-stable.tar.gz
cd libevent-2.0.12-stable
./configure -prefix=/usr/local/libevent
make
make install
cd ~
cd /tmp
http://memcached.googlecode.com/files/memcached-1.4.13.tar.gz
tar zxvf memcached-1.4.13.tar.gz
cd memcached-1.4.13
./configure -prefix=/usr/local/memcached --with-libevent=/usr/local/libevent 注:安装memcached时需要指定libevent的安装位置
make
make install
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/libevent/lib 注:将libevent的lib目录加入LD_LIBRARY_PATH里
vi /etc/sysconfig/iptables
将下面这行加入进去
-A RH-Firewall-l-INPUT -p tcp -m tcp --dport 11211 -j ACCEPT 注:将memcached加入到防火墙允许访问规则中
注:防火墙重启
service iptables restart
启动Memcached
/usr/local/memcached/bin/memcached -d 注:启动memcached
/usr/local/memcached/bin/memcached -d -p 11211 -u nobody -m 3000
/usr/local/memcached/bin/memcached -d -p 11211 -u nobody -m 3000
/usr/local/memcached/bin/memcached -d -p 11211 -u nobody -m 3000
/usr/local/memcached/bin/memcached -d -p 11211 -u nobody -m 3000
设置成开机自动运行
在 /etc/rc.d/rc.local 中加入
vi /etc/rc.d/rc.local
/usr/local/memcached/bin/memcached -l 192.168.20.12 -d -p 11211 -u nobody -m 128
/usr/local/memcached/bin/memcached -l 192.168.20.12 -d -p 11211 -u nobody -m 128
memcached启动参数描述:
-d :启动一个守护进程,
-m:分配给Memcache使用的内存数量,单位是MB,默认是64MB,
-u :运行Memcache的用户
-l :监听的服务器IP地址
-p :设置Memcache监听的端口,默认是11211 注:-p(p为小写)
-c :设置最大并发连接数,默认是1024
-P :设置保存Memcache的pid文件 注:-P(P为大写)
如果要结束Memcache进程,执行:kill cat pid文件路径
查看
telnet 192.168.20.12 11211
stats
stats