memcache簡易安裝與配置

1、yum安裝:
[root@centos65 /]# yum install memcached -y

 

 2、參數修改:
內存大小和端口
[root@centos65 /]# vim /etc/init.d/memcached

  內存大小默認64mbvim

 

[root@centos65 /]# vim /etc/sysconfig/memcached

 

 

 
3、多實例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
相關文章
相關標籤/搜索