简体   繁体   English

无法在 ubuntu 18.04 上安装 redis-server

[英]cannot install redis-server on ubuntu 18.04

I have upgraded to ubuntu 18.04 from 17.10.我已经从 17.10 升级到 ubuntu 18.04。 The redis-server package cannot be fully installed. redis-server package 无法完全安装。 I looked at /var/log/syslog and it says我查看了 /var/log/syslog,它说

==> /var/log/syslog <==
Jun  3 13:04:10 qaz-mko systemd[1]: redis-server.service: Can't open PID file /var/run/redis/redis-server.pid (yet?) after start: No such file or directory
Jun  3 13:05:01 qaz-mko CRON[3429]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Jun  3 13:05:40 qaz-mko systemd[1]: redis-server.service: Start operation timed out. Terminating.
Jun  3 13:05:40 qaz-mko systemd[1]: redis-server.service: Failed with result 'timeout'.
Jun  3 13:05:40 qaz-mko systemd[1]: Failed to start Advanced key-value store.
Jun  3 13:05:40 qaz-mko systemd[1]: redis-server.service: Service hold-off time over, scheduling restart.
Jun  3 13:05:40 qaz-mko systemd[1]: redis-server.service: Scheduled restart job, restart counter is at 13.
Jun  3 13:05:40 qaz-mko systemd[1]: Stopped Advanced key-value store.
Jun  3 13:05:40 qaz-mko systemd[1]: Starting Advanced key-value store...
Jun  3 13:05:40 qaz-mko systemd[1]: redis-server.service: Can't open PID file /var/run/redis/redis-server.pid (yet?) after start: No such file or directory

==> /var/log/redis/redis-server.log <==
3416:C 03 Jun 13:02:39.637 # Configuration loaded
3417:M 03 Jun 13:02:39.639 # Creating Server TCP listening socket ::1:6379: bind: Cannot assign requested address
3423:C 03 Jun 13:04:10.121 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
3423:C 03 Jun 13:04:10.121 # Redis version=4.0.9, bits=64, commit=00000000, modified=0, pid=3423, just started
3423:C 03 Jun 13:04:10.122 # Configuration loaded
3424:M 03 Jun 13:04:10.124 # Creating Server TCP listening socket ::1:6379: bind: Cannot assign requested address
3435:C 03 Jun 13:05:40.602 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
3435:C 03 Jun 13:05:40.602 # Redis version=4.0.9, bits=64, commit=00000000, modified=0, pid=3435, just started
3435:C 03 Jun 13:05:40.602 # Configuration loaded
3436:M 03 Jun 13:05:40.604 # Creating Server TCP listening socket ::1:6379: bind: Cannot assign requested address

However then it times out and does not start the redis deamon.然而,它超时并且不会启动 redis 守护程序。 The config file is the one that came with the package.配置文件是 package 附带的配置文件。

Do you want to continue? [Y/n] Y
Setting up redis-server (5:4.0.9-1) ...
Job for redis-server.service failed because a timeout was exceeded.
See "systemctl status redis-server.service" and "journalctl -xe" for details.
invoke-rc.d: initscript redis-server, action "start" failed.
● redis-server.service - Advanced key-value store
   Loaded: loaded (/lib/systemd/system/redis-server.service; disabled; vendor preset: enabled)
   Active: activating (auto-restart) (Result: timeout) since Sun 2018-06-03 12:47:34 EDT; 14ms ago
     Docs: http://redis.io/documentation,
           man:redis-server(1)
  Process: 2156 ExecStart=/usr/bin/redis-server /etc/redis/redis.conf (code=exited, status=0/SUCCESS)
dpkg: error processing package redis-server (--configure):
 installed redis-server package post-installation script subprocess returned error exit status 1
dpkg: dependency problems prevent configuration of redis:
 redis depends on redis-server (<< 5:4.0.9-1.1~); however:
  Package redis-server is not configured yet.
 redis depends on redis-server (>= 5:4.0.9-1); however:
  Package redis-server is not configured yet.

dpkg: error processing package redis (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
                                                                                                          Errors were encountered while processing:
 redis-server
 redis
E: Sub-process /usr/bin/dpkg returned an error code (1)

I have tried creating the pid file by hand and giving it lots of permissions.我尝试手动创建 pid 文件并赋予它很多权限。 But that does not seem to work.但这似乎不起作用。

sudo touch /var/run/redis/redis-server.pid
# sudo chown redis:redis /var/run/redis/redis-server.pid
# sudo chmod 777 /var/run/redis/redis-server.pid
# sudo ls -alh /var/run/redis/
total 0
drwxr-sr-x  2 redis redis  60 Jun  3 12:54 .
drwxr-xr-x 33 root  root  940 Jun  3 12:53 ..
-rwxrwxrwx  1 redis redis   0 Jun  3 12:54 redis-server.pid

It is possible to get redis-server running even when IPv6 is disabled.即使禁用了 IPv6,也可以让 redis-server 运行。

Simply remove the ::1 IPv6 loopback address from the bind config option (by default located in /etc/redis/redis.conf ):只需从bind配置选项中删除::1 IPv6 环回地址(默认位于/etc/redis/redis.conf ):

- bind 127.0.0.1 ::1
+ bind 127.0.0.1

Now redis will not try to use the IPv6 network.现在 redis 不会尝试使用 IPv6 网络。

I found the culprit.我找到了罪魁祸首。 I had disabled ipv6 a while back.不久前我禁用了 ipv6。 I turned it back on and it installed fine and started up fine.我重新打开它,它安装正常并且启动正常。 You could probably alter the redis.conf file to force it to use IPv4 if it supports that mode only and then maybe you could run it without IPv6.如果 redis.conf 文件仅支持该模式,您可能会更改它以强制它使用 IPv4,然后也许您可以在没有 IPv6 的情况下运行它。

I also failed to install redis-server and after trying many ways, I was able to install it on Windows using Ubuntu following these steps:我也没有安装 redis-server,在尝试了很多方法之后,我能够按照以下步骤使用 Ubuntu 在 Windows 上安装它:

sudo apt-add-repository ppa:redislabs/redis
sudo apt-get update

then make sure u was install redis-tools & libglib2.0-0.然后确保你安装了 redis-tools & libglib2.0-0。 If not, install these:如果没有,请安装这些:

sudo apt-get install redis-tools
sudo apt-get install -y libglib2.0-0

next:下一个:

sudo apt-get install redis-server

Then start the Redis server like so:然后像这样启动 Redis 服务器:

sudo service redis-server start

U can read more on: https://redis.io/docs/getting-started/installation/install-redis-on-windows/你可以阅读更多: https://redis.io/docs/getting-started/installation/install-redis-on-windows/

Well, I just had a similar issue upgrading from Ubuntu 16.04 to 18.04.好吧,我刚刚从 Ubuntu 16.04 升级到 18.04 时遇到了类似的问题。 The solution above (disabling ipv6) didn't help here.上面的解决方案(禁用 ipv6)在这里没有帮助。 It could very well be me, but I also don't understand why that would help, as the important part of the error appears to be很可能是我,但我也不明白为什么这会有所帮助,因为错误的重要部分似乎是

Jun  3 13:05:40 qaz-mko systemd[1]: redis-server.service: Can't open PID file /var/run/redis/redis-server.pid (yet?) after start: No such file or directory

Obviously, creating the file itself does not necessarily solve that issue.显然,创建文件本身并不一定能解决这个问题。 What does help, though, is to create the directory and give it the necessary permissions:但是,有什么帮助是创建目录并为其授予必要的权限:

mkdir -p /var/run/redis
chown redis:redis /var/run/redis

It doesn't persist over reboots.它不会在重新启动后持续存在。 While I'm still trying to figure out a solution for this, the quick and dirty work-around is to put the above lines into rc.local虽然我仍在尝试为此找到解决方案,但快速而肮脏的解决方法是将上述行放入 rc.local

Possible remove PID from systemd Unit /etc/systemd/system/redis-cluster-node@.service can help可能从 systemd 单元中删除 PID /etc/systemd/system/redis-cluster-node@.service 可以提供帮助

[Unit]
Description=redis cluster instance at port %i
After=network.target
Documentation=http://redis.io/documentation, man:redis-server(1)

[Service]
Type=forking
ExecStart=/usr/bin/redis-server /etc/redis/redis.conf \
--cluster-enabled yes \
--dbfilename dump_%i.rdb \
--port %i --cluster-config-file nodes_%i.conf \
--logfile /var/log/redis/redis-server_%i.log \
--supervised systemd

TimeoutStopSec=0
Restart=always
User=redis
Group=redis
RunTimeDirectory=redis

ExecStop=/usr/local/bin/redis-cli -h 127.0.0.1:%i shutdown

UMask=007
PrivateTmp=yes
LimitNOFILE=65535
PrivateDevices=yes
ProtectHome=yes
ReadOnlyDirectories=/
ReadWriteDirectories=-/var/lib/redis
ReadWriteDirectories=-/var/log/redis
ReadWriteDirectories=-/var/run/redis
CapabilityBoundingSet=~CAP_SYS_PTRACE

# redis-server writes its own config file when in cluster mode so we allow
# writing there (NB. ProtectSystem=true over ProtectSystem=full)
ProtectSystem=true
ReadWriteDirectories=-/etc/redis

[Install]
WantedBy=multi-user.target

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM