web-dev-qa-db-ja.com

ubuntu 18.04にredis-serverをインストールできません

17.10。からubuntu 18.04にアップグレードしました。 redis-serverパッケージを完全にインストールすることはできません。/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

ただし、タイムアウトになり、Redisデーモンは開始されません。構成ファイルは、パッケージに付属しているものです。

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)

Pidファイルを手動で作成し、多くのアクセス許可を与えてみました。しかし、それはうまくいかないようです。

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
14
user964491

犯人を見つけました。しばらく前にipv6を無効にしていました。電源を入れ直すと、問題なくインストールされ、問題なく起動しました。おそらくredis.confファイルを変更して、IPv4がそのモードのみをサポートしている場合、強制的にIPv4を使用することができます。その後、IPv6なしで実行できます。

15
user964491

IPv6が無効になっている場合でも、redis-serverを実行することができます。

単に::1bind configオプションからのIPv6ループバックアドレス:

- bind 127.0.0.1 ::1
+ bind 127.0.0.1

これで、redisはIPv6ネットワークの使用を試行しなくなります。

11
cweiske