在CentOS 7上启动多个Memcached实例

总结

使不同的端口号来启动多个Memcached实例,让它们运行在不同的端口上。

进行安装配置

安装

yum install memcached

为环境设置文件做准备

复制环境设置文件。

cp -upv /etc/sysconfig/memcached /etc/sysconfig/memcached_11212

更改端口号。

PORT="11212"

准备systemctl的单位文件

复制现有的单位文件。

cp -upv /usr/lib/systemd/system/memcached.service /usr/lib/systemd/system/memcached_11212.service

将先前已更改的读取环境设置更改为新的设置。

EnvironmentFile=-/etc/sysconfig/memcached_11212

启动和自动启动设置

[root@localhost ~]# systemctl start memcached_11212.service
[root@localhost ~]# ps aux | grep memcache
memcach+   854  0.0  0.1 333848  1216 ?        Ssl  01:26   0:00 /usr/bin/memcached -u memcached -p 11211 -m 64 -c 1024
memcach+  2717  0.0  0.1 333848  1212 ?        Ssl  02:00   0:00 /usr/bin/memcached -u memcached -p 11212 -m 64 -c 1024
root      2725  0.0  0.0   9040   668 pts/0    R+   02:00   0:00 grep --color=auto memcache
[root@localhost ~]# systemctl enable memcached_11212.service

请您查看下列网站

    How to run multiple memcached processes in CentOS 7