今天在ubuntu上使用apt-get安装redis-server。报如下错误:
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)
后来发现是系统禁用了ipv6的原因。
解决方法:
取消禁用ipv6,修改/proc/sys/net/ipv6/conf/eth0/disable_ipv6的状态即可。
也可以作永久取消处理
vim /etc/sysctl.conf
#net.ipv6.conf.all.disable_ipv6 = 1 #注释这条。
net.ipv6.conf.eth0.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
保存完毕,执行下面的命令使其生效。
sysctl -p
重新安装redis-server,OK。