AWS的16.04.01 LTS-Redis不再起作用


10

我们一直在许多AWS EC2 Ubuntu实例(14.04.4 LTS)上运行redis-server,没有问题。我启动了一个测试服务器,尝试升级到Ubuntu 16.04.1 LTS,现在redis无法正常工作。

如果我尝试手动启动Redis,则会得到以下信息:

~$ sudo service redis-server restart
Job for redis-server.service failed because the control process exited with error code. See "systemctl status redis-server.service" and "journalctl -xe" for details.

错误信息:

~$ systemctl status redis-server.service  
● redis-server.service - Advanced key-value store
  Loaded: loaded (/lib/systemd/system/redis-server.service; enabled; vendor preset: enabled)
  Active: inactive (dead) (Result: exit-code) since Wed 2016-10-19 19:26:06 UTC; 25min ago
    Docs: http://redis.io/documentation,
          man:redis-server(1)
 Process: 3730 ExecStart=/usr/bin/redis-server /etc/redis/redis.conf (code=exited, status=1/FAILURE)
 Process: 3724 ExecStartPre=/bin/run-parts --verbose /etc/redis/redis-server.pre-up.d (code=exited, status=0/SUCCESS)

Oct 19 19:26:06 ip-x-y-z-w systemd[1]: redis-server.service: Control process exited, code=exited status=1
Oct 19 19:26:06 ip-x-y-z-w systemd[1]: Failed to start Advanced key-value store.
Oct 19 19:26:06 ip-x-y-z-w systemd[1]: redis-server.service: Unit entered failed state.
Oct 19 19:26:06 ip-x-y-z-w systemd[1]: redis-server.service: Failed with result 'exit-code'.
Oct 19 19:26:06 ip-x-y-z-w systemd[1]: redis-server.service: Service hold-off time over, scheduling restart.
Oct 19 19:26:06 ip-x-y-z-w systemd[1]: Stopped Advanced key-value store.
Oct 19 19:26:06 ip-x-y-z-w systemd[1]: redis-server.service: Start request repeated too quickly.
Oct 19 19:26:06 ip-x-y-z-w systemd[1]: Failed to start Advanced key-value store.

我尝试了以下方法:

  • 重新启动服务器
  • 运行我们的部署脚本,其中包括redis重新启动
  • 用于sudo apt-get卸载并重新安装redis-server
  • 完成两次安装,一次/etc/redis/redis.conf从软件包中接受新文件,一次保留我们的原始文件

有什么建议么?


不是答案,但可能会有所帮助:您可以将redis作为docker容器运行。
pLumo

Answers:


5

我使用安装Redis apt-get install redis-server

对我来说,问题是:我找到了教程。对这个问题的另一种回答是假设redis二进制文件位于中/usr/local/bin

在我的安装中,它们位于此位置,/usr/bin因此对此的更改正在更改,/etc/systemd/system/redis.service以反映出这一点。

此时,我可以/usr/bin/redis-server /etc/redis/redis.conf 手动启动并成功运行sudo systemctl start redis

因此,要使redis在16.04上正常运行,您需要做的是:

  1. 确保使用安装apt-get install redis-server不要下载tar,然后进行安装。
  2. 通过运行来创建或编辑Redis服务 sudo vi /etc/systemd/system/redis.service
  3. 编辑它看起来像这样,然后保存:
[Unit]
Description=Redis Datastore Server
After=network.target

[Service]
Type=forking
PIDFile=/var/run/redis/redis_6379
User=redis
Group=redis

Environment=statedir=/var/run/redis
PermissionsStartOnly=true
ExecStartPre=/bin/mkdir -p ${statedir}
ExecStartPre=/bin/chown -R redis:redis ${statedir}
ExecStart=/usr/bin/redis-server /etc/redis/redis.conf
ExecReload=/bin/kill -USR2 $MAINPID
ExecStop=/usr/bin/redis-cli shutdown
Restart=always

[Install]
WantedBy=multi-user.target
  1. 退出vi重击。您现在应该可以通过以下方式启动服务sudo systemctl start redis
  2. 如果第4点不起作用,则可能至少可以通过运行手动启动它sudo /usr/bin/redis-server /etc/redis/redis.conf

我必须编辑的重要部分是确保

ExecStart = / usr / bin / redis-server /etc/redis/redis.conf

ExecStop = / usr / bin / redis-cli关闭

行没有指向usr/local/bin/foo-需要删除/local


1

我有同样的问题,但原因不同。

我使用redis在具有dhcp客户端的VM上进行测试。

配置/etc/redis/redis.conf指向错误的(旧)本地IP,因此无法将服务绑定到来自DHCP的新分配的IP。

这是此类问题的日志:

mar 13 12:47:53 dev-vm systemd[1]: Failed to start Advanced key-value store.
mar 13 12:47:53 dev-vm systemd[1]: redis-server.service: Unit entered failed state.
mar 13 12:47:53 dev-vm systemd[1]: redis-server.service: Failed with result 'resources'.
mar 13 12:47:53 dev-vm systemd[1]: redis-server.service: Service hold-off time over, scheduling restart.
mar 13 12:47:53 dev-vm systemd[1]: Stopped Advanced key-value store.
mar 13 12:47:53 dev-vm systemd[1]: redis-server.service: Start request repeated too quickly.
mar 13 12:47:53 dev-vm systemd[1]: Failed to start Advanced key-value store.

0

也许尝试一下,这是一个有效的配置,/lib/systemd/system/redis.service看这是否适合您。

[Unit]
Description=Redis Datastore Server
After=network.target

[Service]
Type=forking
PIDFile=/var/run/redis/redis_6379
User=redis
Group=redis

Environment=statedir=/var/run/redis
PermissionsStartOnly=true
ExecStartPre=/bin/mkdir -p ${statedir}
ExecStartPre=/bin/chown -R redis:redis ${statedir}
ExecStart=/usr/local/bin/redis-server /etc/redis/redis.conf 
ExecReload=/bin/kill -USR2 $MAINPID
ExecStop=/usr/local/bin/redis-cli shutdown
Restart=always

[Install]
WantedBy=multi-user.target

然后检查配置中指定的日志文件 /etc/redis/redis.conf,以确保您具有正确的权限。


0

如果您使用的是Ubuntu,则应该在supervised systemd/etc/redis/redis.conf


0

打开您的终端并运行命令ifconfig,您将获得IP地址,如192.168.0.109,然后通过运行命令sudo nano /etc/redis/redis.conf编辑配置,此处nano是编辑器。您可以使用任何其他编辑器,然后根据需要搜索绑定并输入IP地址,例如

绑定127.0.0.1 192.168.0.109这里我的IP是192.168.0.109然后通过此命令重新启动服务器sudo systemctl restart redis.service检查服务器状态sudo systemctl status redis然后您会发现它处于活动状态

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.