我已经在ubuntu 16.04机器上安装了redis,如果我运行/usr/local / bin / redis-server /etc/redis/cluster/7000/redis.conf,它会启动并且我可以毫无问题地连接到它.
但是我想使用systemctl start redis启动它,所以我在/etc/systemd/system/redis7000.service上创建了以下文件
[Unit] Description=Redis In-Memory Data Store After=network.target [Service] User=redis Group=redis ExecStart=/usr/local/bin/redis-server /etc/redis/cluster/7000/redis.conf ExecStop=/usr/local/bin/redis-cli shutdown Restart=always [Install] WantedBy=multi-user.target
并且redis配置有监督系统集
我认为看起来很好,但我得到以下错误:
Jan 19 14:54:27 ip-172-31-42-18 systemd[1]: Started Redis In-Memory Data Store. Jan 19 14:54:27 ip-172-31-42-18 redis-server[21661]: 21661:C 19 Jan 14:54:27.680 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo Jan 19 14:54:27 ip-172-31-42-18 redis-server[21661]: 21661:C 19 Jan 14:54:27.680 # Redis version=4.0.6,bits=64,commit=00000000,modified=0,pid=21661,just started Jan 19 14:54:27 ip-172-31-42-18 redis-server[21661]: 21661:C 19 Jan 14:54:27.680 # Configuration loaded Jan 19 14:54:27 ip-172-31-42-18 redis-server[21661]: 21661:C 19 Jan 14:54:27.680 # systemd supervision requested,but NOTIFY_SOCKET not found Jan 19 14:54:27 ip-172-31-42-18 systemd[1]: redis7000.service: Main process exited,code=exited,status=1/FAILURE Jan 19 14:54:27 ip-172-31-42-18 systemd[1]: redis7000.service: Unit entered Failed state. Jan 19 14:54:27 ip-172-31-42-18 systemd[1]: redis7000.service: Failed with result 'exit-code'. Jan 19 14:54:27 ip-172-31-42-18 systemd[1]: redis7000.service: Service hold-off time over,scheduling restart. Jan 19 14:54:27 ip-172-31-42-18 systemd[1]: Stopped Redis In-Memory Data Store.
我甚至不确定这意味着什么,所以有人能引导我朝着正确的方向前进吗?
要在systemd下运行redis,您需要设置受监督的systemd.
原文链接:https://www.f2er.com/ubuntu/348029.html请参阅配置文件:
# If you run Redis from upstart or systemd,Redis can interact with your # supervision tree. Options: # supervised no - no supervision interaction # supervised upstart - signal upstart by putting Redis into SIGSTOP mode # supervised systemd - signal systemd by writing READY=1 to $NOTIFY_SOCKET # supervised auto - detect upstart or systemd method based on # UPSTART_JOB or NOTIFY_SOCKET environment variables # Note: these supervision methods only signal "process is ready." # They do not enable continuous liveness pings back to your supervisor. supervised no
需要改为:
supervised systemd
您也可以在命令行上传递它,这将覆盖redis.conf中的设置.基于Red Hat的系统就是这样做的.这也允许手动或从systemd运行相同的redis实例,而无需更改配置文件.
ExecStart=/usr/bin/redis-server /etc/redis.conf --supervised systemd
此外,您还需要通过在[Service]部分中设置Type = notify来告诉systemd redis将在此模式下运行.