【问题标题】:start redis with supervisor用主管启动 redis
【发布时间】:2015-08-23 21:12:51
【问题描述】:

当用supervisor启动redis时,redis进程正在运行,但是在supervisor中它显示退避。

vagrant@jinming:~$ sudo supervisorctl -c /etc/conf/supervisor/supervisord.conf
redis                            BACKOFF   Exited too quickly (process log may have details)

在主管日志中,显示如下:

2015-06-09 07:09:28,407 CRIT Supervisor running as root (no user in config file)
2015-06-09 07:09:28,407 WARN Included extra file "/etc/conf/supervisor/conf.d/redis_local.conf" during parsing
2015-06-09 07:09:28,407 INFO RPC interface 'supervisor' initialized
2015-06-09 07:09:28,407 CRIT Server 'unix_http_server' running without any HTTP authentication checking
2015-06-09 07:09:28,407 INFO supervisord started with pid 23191
2015-06-09 07:09:29,410 INFO spawned: 'redis' with pid 23332
2015-06-09 07:09:29,416 INFO exited: redis (exit status 0; not expected)
2015-06-09 07:09:30,418 INFO spawned: 'redis' with pid 23334
2015-06-09 07:09:30,425 INFO exited: redis (exit status 0; not expected)
2015-06-09 07:09:32,429 INFO spawned: 'redis' with pid 23336  
2015-06-09 07:09:32,434 INFO exited: redis (exit status 0; not expected)
2015-06-09 07:09:36,067 INFO spawned: 'redis' with pid 23342
2015-06-09 07:09:36,072 INFO exited: redis (exit status 0; not expected)
2015-06-09 07:09:37,073 INFO gave up: redis entered FATAL state, too many start retries too quickly
2015-06-09 07:11:04,079 CRIT Supervisor running as root (no user in config file)
2015-06-09 07:11:04,079 WARN Included extra file "/etc/conf/supervisor/conf.d/redis_local.conf" during parsing
2015-06-09 07:11:04,080 INFO RPC interface 'supervisor' initialized
2015-06-09 07:11:04,080 CRIT Server 'unix_http_server' running without any HTTP authentication checking
2015-06-09 07:11:04,080 INFO supervisord started with pid 23191
2015-06-09 07:11:05,083 INFO spawned: 'redis' with pid 23486
2015-06-09 07:11:05,089 INFO exited: redis (exit status 0; not expected)

任何人都可以帮助我,谢谢。

【问题讨论】:

  • 我想通了,设置 daemonize no 然后用 supervisor 启动 redis。
  • 嗨,你能告诉我你的 /etc/conf/supervisor/conf.d/redis_local.conf 配置是什么吗?我似乎无法将 /etc/redis/redis.conf 的路径传递给可执行文件并让主管成功启动 redis。谢谢!
  • @einarc,它只是redis配置文件,你可以用sudo启动supervisor,也可以用sudo启动redis,也许这对你有帮助。
  • 我认为问题在于 redis 二进制文件没有启动服务,因为 redis.conf 文件存在配置问题。一旦解决了这个问题,主管就能够正确加载 redis。没有必要进行任何更改。谢谢!

标签: redis supervisord


【解决方案1】:

当使用 Supervisord 管理服务器程序(如经常产生或守护进程的数据库)时,请在启动命令或配置文件中查找标志。像 MySQL 这样的数据库有一个例外,推荐的做法是使用代理启动 mysqld_safe 并让它管理子进程。

redis.conf 中,对于较新的版本(即 3.x),默认是禁用守护程序,但它可能已被您的包编辑。还要确保您没有安装会重新生成的新贵脚本。

Redis 配置文件部分

# By default Redis does not run as a daemon. Use 'yes' if you need it.
# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
daemonize no

Supervisor 配置示例

【讨论】:

  • 我在下面对另一个解决方案发表了评论,但值得注意的是,这里发生了一些奇怪的事情。如果没有指定的配置文件,Redis 将使用其默认配置。但是,这不是使用默认配置文件。默认配置规范 daemonize no 而默认配置文件 (/etc/redis/redis.conf) 规范 daemonize yes。我的想法是最好的解决方案是使用配置文件,但将其更新为daemonize no
  • 请注意,该帖子已有 5 年历史,情况可能已发生变化,但是您会看到“但它可能已被您的包编辑过”,所以是的,最好是明确的并将其设置为你想要什么。 ;-)
【解决方案2】:

问题

redis-server 不适用于下面的supervisord.conf

尤其是redis-server 带有 conf 文件位置参数的命令

redis-server --version

Redis server v=2.8.17 sha=00000000:0 malloc=jemalloc-3.6.0 bits=64 build=5b70b85861dcf95e

supervisord.conf

[program:redis-server]
command=redis-server /etc/redis/redis.conf # PLEASE NOTE THIS LINE
autostart=true
autorestart=true
user=root
stdout_logfile=/var/log/redis/stdout.log
stderr_logfile=/var/log/redis/stderr.log

my_redis.conf

# By default Redis does not run as a daemon. Use 'yes' if you need it.
# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
daemonize no

Dockerfile

RUN cp -f my_redis.conf /etc/redis/redis.conf &&\

supervisorctl

通过命令行测试

解决方案

没有自定义 conf 文件位置,一切正常。

就我而言,我用my_redis.conf 覆盖了/etc/redis/redis.conf 中的默认配置

[program:redis-server]
command=redis-server # JUST REMOVE EXTRA CONF FILE LOCATION, EVERYTHING WORKS WELL
autostart=true
autorestart=true
user=root
stdout_logfile=/var/log/redis/stdout.log
stderr_logfile=/var/log/redis/stderr.log

ps。这个redis版本有bug吗?还是我的配置错了?

【讨论】:

  • 这里发生的情况是,当 Redis 在没有配置文件的情况下启动时,它会 deamonize(即daemonize no)。但是,默认/包含的配置文件确实 守护进程(即daemonize yes)。此解决方案将使用 Redis 的默认配置,而不是默认配置文件。更好的解决方案是更新保持指定的配置文件,并将其更新为包含daemonize no
猜你喜欢
  • 2015-03-18
  • 1970-01-01
  • 2021-11-06
  • 2011-06-18
  • 2019-04-08
  • 2017-02-04
  • 2023-03-21
  • 2011-06-17
  • 1970-01-01
相关资源
最近更新 更多