无法启动 Redis 数据存储服务器(Ubuntu 16.04.1 LTS)

无法启动 Redis 数据存储服务器(Ubuntu 16.04.1 LTS)

我刚刚安装了 redis,当尝试使用命令启动服务时它根本不起作用:

sudo service redis-server start

这是结果journalctl -xe

Subject: Unit redis-server.service has finished shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit redis-server.service has finished shutting down.
Mar 02 13:22:46 aaa-notebook systemd[1]: redis-server.service: Start request repeated too quickly.
Mar 02 13:22:46 aaa-notebook systemd[1]: Failed to start Redis Datastore Server.

结果如下systemctl status redis-server.service

 redis-server.service - Redis Datastore Server
 Loaded: loaded (/lib/systemd/system/redis-server.service; enabled; vendor preset: enabled)
 Active: inactive (dead) (Result: resources) since Kam 2017-03-02 13:22:46 WIB; 5min ago
 Process: 12120 ExecStart=/usr/local/bin/redis-server /etc/redis/redis.conf (code=exited, status=0/SUCCESS)

Mar 02 13:22:46 aaa-notebook systemd[1]: Failed to start Redis Datastore Server.
Mar 02 13:22:46 aaaaa-notebook systemd[1]: redis-server.service: Unit entered failed state.
Mar 02 13:22:46 aaa-notebook systemd[1]: redis-server.service: Failed with result 'resources'.
Mar 02 13:22:46 aaa-notebook systemd[1]: redis-server.service: Service hold-off time over, scheduling restart.
Mar 02 13:22:46 aaa-notebook systemd[1]: Stopped Redis Datastore Server.
Mar 02 13:22:46 aaa-notebook systemd[1]: redis-server.service: Start request repeated too quickly.
Mar 02 13:22:46 aaa-notebook systemd[1]: Failed to start Redis Datastore Server.

答案1

我遇到了同样的问题,但找不到任何可行的解决方案。经过一番搜索,以下修复对我有用(Ubuntu 16.04)

/etc/systemd/system/redis.service在该部分下添加以下内容[Service]

Type=forking

答案2

使用任意编辑器打开您的服务。

vim /etc/systemd/system/redis.service

看看你的[Service]部分,ExecStart我的是:

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

运行此命令查看发生了哪些错误。我的响应如下:

 Fatal error, can't open config file '/etc/redis/redis.conf'

所以我刚刚将该行更新为此(我的实际配置文件所在的位置)

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

这是 redis quickstart 默认放置它的位置...:)

答案3

/var/log/redis就我而言,我在文件中提到的日志目录( )/etc/redis/redis.conf不存在

我如何找到错误

尝试

/usr/local/bin/redis-server /etc/redis/redis.conf

这是我的/etc/systemd/system/redis.service文件中存在的相同命令

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

解决方案

1)创建日志目录

sudo mkdir -p /var/log/redis

2)授予创建和写入日志的适当权限

sudo chown redis:redis /var/log/redis

尝试再次启动该服务

sudo service redis-server start 

或者

sudo service redis start

答案4

我遇到了同样的错误。但对我来说原因完全不同:这是由于我的redis.conf文件中的拼写错误造成的。更正后sudo systemctl restart redis-server立即重新启动 redis。这种情况也会抛出同样的错误,这很具误导性。

相关内容