安装memcached并加入systemctl管理

83530391 2019-12-12

[ bin]# rpm -qa | grep memcache
[ bin]# yum list installed |grep memcache
[ bin]# yum clean all
[ bin]# yum -y update
[ bin]# echo $?
[ bin]# yum list |grep  memcached
[ bin]# yum -y install memcached
[ bin]# locate memcached.service
[ bin]# updatedb
[ bin]# locate memcached.service
/usr/lib/systemd/system/memcached.service
[ bin]# ll /etc/sysconfig/memcached
-rw-r--r-- 1 root root 88 Nov 12 22:30 /etc/sysconfig/memcached

[ bin]# vim /usr/lib/systemd/system/memcached.service
ExecStart=/usr/bin/memcached -l $HOST -u $USER -p $PORT -m $CACHESIZE -c $MAXCONN $OPTIONS
[ bin]# cat /usr/lib/systemd/system/memcached.service[Unit]Description=MemcachedBefore=httpd.serviceAfter=network.target[Service]Type=simpleEnvironmentFile=-/etc/sysconfig/memcachedExecStart=/usr/bin/memcached -l $HOST -u $USER -p $PORT -m $CACHESIZE -c $MAXCONN $OPTIONS[Install]WantedBy=multi-user.target
[ bin]# vim /etc/sysconfig/memcached
HOST="127.0.0.1"
[ bin]# cat /etc/sysconfig/memcachedPORT="11211"HOST="127.0.0.1"USER="memcached"MAXCONN="1024"CACHESIZE="64"OPTIONS=""

[ bin]# systemctl restart memcached
[_58_118_centos ~]# systemctl restart memcached
Warning: memcached.service changed on disk. Run ‘systemctl daemon-reload‘ to reload units.

[_58_118_centos ~]# systemctl daemon-reload

[ bin]# systemctl restart memcached
[ bin]# systemctl status memcached
● memcached.service - Memcached
   Loaded: loaded (/usr/lib/systemd/system/memcached.service; disabled; vendor preset: disabled)
   Active: active (running) since Tue 2019-11-12 22:34:07 CST; 7s ago
 Main PID: 19329 (memcached)
   CGroup: /system.slice/memcached.service
           └─19329 /usr/bin/memcached -u memcached -p 11211 -m 64 -c 1024

Nov 12 22:34:07 izbp18dv3a3metugyd02qxz systemd[1]: Started Memcached.

相关推荐