Redis Sentinel Systemd 服务无法在 Ubuntu 16.04 和 CentOS 7 上启动

Redis Sentinel Systemd 服务无法在 Ubuntu 16.04 和 CentOS 7 上启动

无法启动我的 Redis sentinel systemd 服务。

我可以成功手动运行哨兵——例如:

root@poolwc:/etc/redis# redis-sentinel ./sentinel.conf --sentinel

10.9.8.1、.2、.3 三个 redis 服务器

.2 和 .3 是 .1 的从属,并且复制正在进行中

redis服务用户对这三台主机均具有0600读写权限redis.confsentinel.conf

对于 Slave1 和 Slave2 (10.9.8.2 和 10.9.8.3),我添加了以下内容redis.conf

+ slaveof 127.0.0.1 6380

对于主服务器、从服务器 1 和从服务器 2:

sentinel.conf

sentinel monitor mymaster 10.9.8.1 6379 2
sentinel down-after-milliseconds mymaster 60000
sentinel failover-timeout mymaster 180000
sentinel parallel-syncs mymaster 1

服务启动时主机的输出:

root@poolwc:/etc/redis# systemctl start redis-sentinel
Job for redis-sentinel.service failed because the control process exited with error code. See "systemctl status redis-sentinel.service" and "journalctl -xe" for details.

    root@poolwc:/etc/redis# systemctl status redis-sentinel.service
    ● redis-sentinel.service - Advanced key-value store
       Loaded: loaded (/lib/systemd/system/redis-sentinel.service; enabled; vendor preset: enabled)
       Active: inactive (dead) (Result: exit-code) since Mon 2018-02-26 21:54:12 

PST;6 秒前 文档:http://redis.io/documentation,man:redis-sentinel(1)进程:5376 ExecStopPost=/bin/run-parts --verbose /etc/redis/redis-sentinel.post-down.d(code=exited,status=0/SUCCESS)进程:7893 ExecStart=/usr/bin/redis-sentinel /etc/redis/sentinel.conf(code=exited,status=1/FAILURE)进程:7890 ExecStartPre=/bin/run-parts --verbose /etc/redis/redis-sentinel.pre-up.d(code=exited,status=0/SUCCESS)

Feb 26 21:54:12 poolwc systemd[1]: redis-sentinel.service: Control process exited, code=exited status=1
Feb 26 21:54:12 poolwc systemd[1]: Failed to start Advanced key-value store.
Feb 26 21:54:12 poolwc systemd[1]: redis-sentinel.service: Unit entered failed state.
Feb 26 21:54:12 poolwc systemd[1]: redis-sentinel.service: Failed with result 'exit-code'.
Feb 26 21:54:12 poolwc systemd[1]: redis-sentinel.service: Service hold-off time over, scheduling restart.
Feb 26 21:54:12 poolwc systemd[1]: Stopped Advanced key-value store.
Feb 26 21:54:12 poolwc systemd[1]: redis-sentinel.service: Start request repeated too quickly.
Feb 26 21:54:12 poolwc systemd[1]: Failed to start Advanced key-value store.

服务启动时 Slave2 的输出——正在运行,但为什么失败时退出?:

[root@ns1 etc]# systemctl start redis-sentinel
[root@ns1 etc]# systemctl status redis-sentinel
● redis-sentinel.service - Redis Sentinel
   Loaded: loaded (/usr/lib/systemd/system/redis-sentinel.service; enabled; vendor preset: disabled)
  Drop-In: /etc/systemd/system/redis-sentinel.service.d
           └─limit.conf
   Active: active (running) since Mon 2018-02-26 21:55:58 PST; 5s ago
  Process: 12876 ExecStop=/usr/libexec/redis-shutdown redis-sentinel (code=exited, status=1/FAILURE)
 Main PID: 12944 (redis-sentinel)
   CGroup: /system.slice/redis-sentinel.service
           └─12944 /usr/bin/redis-sentinel *:26379 [sentinel]

Feb 26 21:55:58 ns1 redis-sentinel[12944]: |    `-._`-._        _.-'_.-'    |           http://redis.io
Feb 26 21:55:58 ns1 redis-sentinel[12944]: `-._    `-._`-.__.-'_.-'    _.-'
Feb 26 21:55:58 ns1 redis-sentinel[12944]: |`-._`-._    `-.__.-'    _.-'_.-'|
Feb 26 21:55:58 ns1 redis-sentinel[12944]: |    `-._`-._        _.-'_.-'    |
Feb 26 21:55:58 ns1 redis-sentinel[12944]: `-._    `-._`-.__.-'_.-'    _.-'
Feb 26 21:55:58 ns1 redis-sentinel[12944]: `-._    `-.__.-'    _.-'
Feb 26 21:55:58 ns1 redis-sentinel[12944]: `-._        _.-'
Feb 26 21:55:58 ns1 redis-sentinel[12944]: `-.__.-'
Feb 26 21:55:58 ns1 redis-sentinel[12944]: 12944:X 26 Feb 21:55:58.490 # Sentinel ID is 659761a6f8328e59d43086ef3265450fcec5d2f5
Feb 26 21:55:58 ns1 redis-sentinel[12944]: 12944:X 26 Feb 21:55:58.490 # +monitor master mymaster 10.9.8.1 6379 quorum 2

服务启动时 Slave2 的输出:

root@poolec:/etc/redis# systemctl start redis-sentinel
Job for redis-sentinel.service failed because the control process exited with error code. See "systemctl status redis-sentinel.service" and "journalctl -xe" for details.
root@poolec:/etc/redis# systemctl status redis-sentinel

    ● redis-sentinel.service - Advanced key-value store
   Loaded: loaded (/lib/systemd/system/redis-sentinel.service; enabled; vendor preset: enabled)
   Active: inactive (dead) (Result: exit-code) since Tue 2018-02-27 05:57:09 UTC; 5s ago
     Docs: http://redis.io/documentation,
           man:redis-sentinel(1)
  Process: 4130 ExecStart=/usr/bin/redis-sentinel /etc/redis/sentinel.conf (code=exited, status=1/FAILURE)
  Process: 4127 ExecStartPre=/bin/run-parts --verbose /etc/redis/redis-sentinel.pre-up.d (code=exited, status=0/SUCCESS)

Feb 27 05:57:09 poolec systemd[1]: redis-sentinel.service: Unit entered failed state.
Feb 27 05:57:09 poolec systemd[1]: redis-sentinel.service: Failed with result 'exit-code'.
Feb 27 05:57:09 poolec systemd[1]: redis-sentinel.service: Service hold-off time over, scheduling restart.
Feb 27 05:57:09 poolec systemd[1]: Stopped Advanced key-value store.
Feb 27 05:57:09 poolec systemd[1]: redis-sentinel.service: Start request repeated too quickly.
Feb 27 05:57:09 poolec systemd[1]: Failed to start Advanced key-value store.

他们都没有留下任何输出/var/log/redis/

有任何想法吗?

非常感谢!

答案1

似乎可以通过以下方法解决,请在此处找到:Redis 没有使用 systemctl 启动

查看配置文件:

如果您从 upstart 或 systemd 运行 Redis,Redis 可以与您的监督树交互。选项:supervised no - 无监督交互 supervised upstart - 通过将 Redis 置于 SIGSTOP 模式向 upstart 发出信号 supervised systemd - 通过将 READY=1 写入 $NOTIFY_SOCKET 向 systemd 发出信号 supervised auto - 根据 UPSTART_JOB 或 NOTIFY_SOCKET 环境变量检测 upstart 或 systemd 方法 注意:这些监督方法仅发出“进程已准备就绪”的信号。它们不会启用持续的活跃 ping 功能以返回到您的主管。

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 将以此模式运行。

相关内容