添加Redis的服务
# vim /usr/lib/systemd/system/redis.service
[Unit]
Description=Redis
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/redis/src/redis-server /usr/local/redis/redis.conf
ExecStop=/usr/local/bin/redis-cli -h 127.0.0.1 -a 'my_password' -p 8878 shutdown
PrivateTmp=true
[Install]
WantedBy=multi-user.target
服务的形式启动redis
服务的形式启动的redis,需要通过服务的形式关闭,否则kill后还会起来。
# systemctl list-unit-files |grep redis
redis-30001.service enabled
redis-sentinel-30002.service enabled
# systemctl disable redis-30001.service # disable
# systemctl disable redis-sentinel-30002.service
# systemctl stop redis-30001.service # stop
# systemctl stop redis-sentinel-30002.service
客户端
https://github.com/caoxinyu/RedisClient
转载请注明:liutianfeng.com » redis使用服务 systemctl管理