memcache简易安装与配置
一、yum安装:
[root@centos65 /]# yum install memcached -y
二、参数修改:
内存大小和端口
[root@centos65 /]# vim /etc/init.d/memcached
内存大小默认64mb
[root@centos65 /]# vim /etc/sysconfig/memcached
三、多实例memcache
将yum安装好的memcache拷贝一份,重命名
[root@centos65 sysconfig]# cp /etc/init.d/memcached /etc/init.d/memcached11213 [root@centos65 /]# cp /etc/sysconfig/memcached /etc/sysconfig/memcached11213
修改新的配置文件,端口和内存大小
[root@centos65 init.d]# vim /etc/init.d/memcached11213
对新的memcache11213实例的配置文件进行批量修改
sed -i -e 's#/etc/sysconfig/memcached#/etc/sysconfig/memcached\$PORT#g' -e 's#/var/run/memcached/memcached#/var/run/memcached/memcached\$PORT#g' -e 's#/var/lock/subsys/memcached#/var/lock/subsys/memcached\$PORT#g' /etc/init.d/memcached11213
启动双实例:
[root@centos65 init.d]# /etc/init.d/memcached start Starting memcached: [ OK ] [root@centos65 init.d]# /etc/init.d/memcached11213 start Starting memcached: [ OK ]
查看memcache的双实例情况:
[root@centos65 init.d]# netstat -antup | grep memcache tcp 0 0 0.0.0.0:11211 0.0.0.0:* LISTEN 3494/memcached tcp 0 0 0.0.0.0:11213 0.0.0.0:* LISTEN 3507/memcached tcp 0 0 :::11211 :::* LISTEN 3494/memcached tcp 0 0 :::11213 :::* LISTEN 3507/memcached udp 0 0 0.0.0.0:11211 0.0.0.0:* 3494/memcached udp 0 0 0.0.0.0:11213 0.0.0.0:* 3507/memcached udp 0 0 :::11211 :::* 3494/memcached udp 0 0 :::11213 :::* 3507/memcached