redis和sentinel开机自启

cat > /usr/lib/systemd/system/redis.service << EOF
[Unit]
Description=Redis persistent key-value database
After=network.target
After=network-online.target
Wants=network-online.target

[Service]
Type=forking
ExecStart=/usr/local/redis/bin/redis-server /etc/redis.conf --supervised systemd
ExecStop=/usr/local/redis/bin/redis-cli -a 密码 -p 6379 shutdown
#需要先创建用户
#User=redis
#Group=redis
#RuntimeDirectory=redis
#RuntimeDirectoryMode=0755

[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
#=======================
cat > /usr/lib/systemd/system/sentinel.service << EOF
[Unit]
Description=Redis persistent key-value database
After=network.target
After=network-online.target
Wants=network-online.target

[Service]
Type=forking
ExecStart=/usr/local/redis/bin/redis-sentinel /etc/sentinel.conf 
ExecStop=/usr/local/redis/bin/redis-cli -h 127.0.0.1 -p 26379 shutdown
#需要先创建用户
#User=redis
#Group=redis
#RuntimeDirectory=redis
#RuntimeDirectoryMode=0755

[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
posted @ 2021-11-15 22:35  1769987233  阅读(291)  评论(0编辑  收藏  举报