[root@izbp18dv3a3metugyd02qxz bin]# rpm -qa | grep memcache
[root@izbp18dv3a3metugyd02qxz bin]# yum list installed |grep memcache
[root@izbp18dv3a3metugyd02qxz bin]# yum clean all
[root@izbp18dv3a3metugyd02qxz bin]# yum -y update
[root@izbp18dv3a3metugyd02qxz bin]# echo $?
[root@izbp18dv3a3metugyd02qxz bin]# yum list |grep memcached
[root@izbp18dv3a3metugyd02qxz bin]# yum -y install memcached
[root@izbp18dv3a3metugyd02qxz bin]# locate memcached.service
[root@izbp18dv3a3metugyd02qxz bin]# updatedb
[root@izbp18dv3a3metugyd02qxz bin]# locate memcached.service
/usr/lib/systemd/system/memcached.service
[root@izbp18dv3a3metugyd02qxz bin]# ll /etc/sysconfig/memcached
-rw-r--r-- root root Nov : /etc/sysconfig/memcached [root@izbp18dv3a3metugyd02qxz bin]# vim /usr/lib/systemd/system/memcached.service
ExecStart=/usr/bin/memcached -l $HOST -u $USER -p $PORT -m $CACHESIZE -c $MAXCONN $OPTIONS
[root@izbp18dv3a3metugyd02qxz bin]# cat /usr/lib/systemd/system/memcached.service
[Unit]
Description=Memcached
Before=httpd.service
After=network.target [Service]
Type=simple
EnvironmentFile=-/etc/sysconfig/memcached
ExecStart=/usr/bin/memcached -l $HOST -u $USER -p $PORT -m $CACHESIZE -c $MAXCONN $OPTIONS [Install]
WantedBy=multi-user.target [root@izbp18dv3a3metugyd02qxz bin]# vim /etc/sysconfig/memcached
HOST="127.0.0.1"
[root@izbp18dv3a3metugyd02qxz bin]# cat /etc/sysconfig/memcached
PORT="11211"
HOST="127.0.0.1"
USER="memcached"
MAXCONN="1024"
CACHESIZE="64"
OPTIONS=""

[root@izbp18dv3a3metugyd02qxz bin]# systemctl restart memcached
[root@VM_58_118_centos ~]# systemctl restart memcached
Warning: memcached.service changed on disk. Run 'systemctl daemon-reload' to reload units. [root@VM_58_118_centos ~]# systemctl daemon-reload [root@izbp18dv3a3metugyd02qxz bin]# systemctl restart memcached
[root@izbp18dv3a3metugyd02qxz bin]# systemctl status memcached
● memcached.service - Memcached
Loaded: loaded (/usr/lib/systemd/system/memcached.service; disabled; vendor preset: disabled)
Active: active (running) since Tue -- :: CST; 7s ago
Main PID: (memcached)
CGroup: /system.slice/memcached.service
└─ /usr/bin/memcached -u memcached -p -m -c Nov :: izbp18dv3a3metugyd02qxz systemd[]: Started Memcached.

把elasticsearch服务systemctl管理

[root@shengyihuo- bin]# vim /usr/lib/systemd/system/elasticsearch.service
[Unit]
Description=Elasticsearch
Documentation=http://www.elastic.co
Wants=network-online.target
After=network-online.target [Service]
Environment=ES_HOME=/usr/share/elasticsearch
Environment=CONF_DIR=/usr/share/elasticsearch/config
Environment=DATA_DIR=/data/elasticsearch/data
Environment=LOG_DIR=/data/elasticsearch/logs
Environment=PID_DIR=/var/run/elasticsearch
EnvironmentFile=-/etc/sysconfig/elasticsearch WorkingDirectory=/usr/share/elasticsearch User=elastic
Group=elastic ExecStartPre=/usr/share/elasticsearch/bin/elasticsearch-systemd-pre-exec ExecStart=/usr/share/elasticsearch/bin/elasticsearch \
                                                -Des.pidfile=${PID_DIR}/elasticsearch.pid \
                                                -Des.default.path.home=${ES_HOME} \
                                                -Des.default.path.logs=${LOG_DIR} \
                                                -Des.default.path.data=${DATA_DIR} \
                                                -Des.default.path.conf=${CONF_DIR} StandardOutput=journal
StandardError=inherit # Specifies the maximum file descriptor number that can be opened by this process
LimitNOFILE=65535 # Specifies the maximum number of bytes of memory that may be locked into RAM
# Set to "infinity" if you use the 'bootstrap.mlockall: true' option
# in elasticsearch.yml and 'MAX_LOCKED_MEMORY=unlimited' in /etc/sysconfig/elasticsearch
#LimitMEMLOCK=infinity # Disable timeout logic and wait until process is stopped
TimeoutStopSec=0 # SIGTERM signal is used to stop the Java process
KillSignal=SIGTERM # Java process is never killed
SendSIGKILL=no # When a JVM receives a SIGTERM signal it exits with code 143
SuccessExitStatus=143 [Install]
WantedBy=multi-user.target # Built for Distribution: RPM-2.3.5 (rpm) [root@izbp18dv3a3metugyd02qxz run]# mkdir -p /var/run/elasticsearch/ 会存放/var/run/elasticsearch/elasticsearch.pid
[root@izbp18dv3a3metugyd02qxz run]# chown -R elastic:elastic /var/run/elasticsearch
[root@izbp18dv3a3metugyd02qxz run]# su - elastic
[root@izbp18dv3a3metugyd02qxz run]$ /usr/share/elasticsearch/bin/elasticsearch -d
[root@izbp18dv3a3metugyd02qxz run]$ exit
[root@izbp18dv3a3metugyd02qxz run]# ps -ef|grep elasticsearch
[root@izbp18dv3a3metugyd02qxz run]# kill -9 xxx
[root@izbp18dv3a3metugyd02qxz run]# systemctl restart elasticsearch 说明:
systemctl 启动的服务,cat /usr/lib/systemd/system/elasticsearch.service查看pid,和各种参数设置
直接启动命令启动的ps -ef|grep xxxx查看指定的命令启动参数,如果没有,就查看服务默认的配置文件有无指定参数,如pid设置,socket等,都没有就是默认的设置。
05-07 10:36