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


10

我刚刚安装了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.

Answers:


14

我遇到了同样的问题,在任何地方都找不到有效的解决方案。经过一番搜索后,以下修复程序对我有用(Ubuntu 16.04)

/etc/systemd/system/redis.service中,在本[Service]节下添加以下内容。

Type=forking

1
我的也是,谢谢!您是如何发现添加此内容的?它实际上是做什么的?
fpghost

4

使用任何编辑器打开服务。

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快速入门默认将其放置在其中... :)


2

我遇到了同样的错误。但是对我来说,原因是完全不同的:这是由于我的redis.conf档案中有错字。更正该问题并sudo systemctl restart redis-server立即重新启动redis。在这种情况下也会引发相同的错误,这是令人误解的。


2

就我而言,文件中/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

1

“ / etc / systemd / system /”目录中缺少redis.service文件

须藤nano /etc/systemd/system/redis.service

然后复制并粘贴这些行

[Unit]
Description=Redis In-Memory Data Store
After=network.target

[Service]
User=redis
Group=redis
ExecStart=/usr/local/bin/redis-server /etc/redis/redis.conf
ExecStop=/usr/local/bin/redis-cli shutdown
Restart=always

[Install]
WantedBy=multi-user.target

保存并关闭此文件

接下来修改目录权限

$ sudo adduser --system --group --no-create-home redis
$ sudo chown redis:redis /var/lib/redis
$ sudo chmod 770 /var/lib/redis

接下来启动redis服务器

$ sudo systemctl启动redis

检查它现在是否正在运行

$ sudo systemctl status redis

参考:https : //www.digitalocean.com/community/tutorials/how-to-install-and-configure-redis-on-ubuntu-16-04


0

请检查您的redis.log。您应该会看到以下内容:

41393:M 07 Jun 17:02:19.034 # You requested maxclients of 10000 requiring at least 10032 max file descriptors.
41393:M 07 Jun 17:02:19.034 # Server can't set maximum open files to 10032 because of OS error: Operation not permitted.
41393:M 07 Jun 17:02:19.034 # Current maximum open files is 4096. maxclients has been reduced to 4064 to compensate for low ulimit. If you need higher maxclients increase 'ulimit -n'.
41393:M 07 Jun 17:02:19.034 # Can't open the append-only file: Read-only file system

因此,请检查您的系统限制以及redisAOF(/var/lib/redis/*)的文件权限。对于系统限制,这是一个很好的指南


0

我需要一个/ var / lib / redis文件夹以及一个redis用户和组。

我使用凯文·厄普顿(Kevin Upton)的https://askubuntu.com/a/981641/451682建议来查找我的问题:vim /etc/systemd/system/redis.service导致我 /usr/local/bin/redis-server /etc/redis/redis.conf做出了回应,并Can't chdir to '/var/lib/redis': No such file or directory由此创建了sudo mkdir /var/lib/redis

但是,然后,我还需要按照Rishik Rohan的https://askubuntu.com/a/918408/451682在/ var / lib / redis目录上创建redis用户和组并将其放下:

sudo adduser --system --group --no-create-home redis
sudo chown redis:redis /var/lib/redis
sudo chmod 770 /var/lib/redis

谢谢你们两个!


0

完成所有配置后,请尝试以下命令

sudo systemctl daemon-reload

sudo chown redis:redis /var/lib/redis

sudo chmod 770 /var/lib/redis

之后

sudo systemctl start redis

0

解决此问题的步骤:-+ ============= ++ A.在566数字行的redis.conf中设置内存限制

566 maxmemory 256mb 567 maxmemory-policy allkeys-lru

B.将Linux内核过量使用内存设置设置为1:

$ sudo sysctl vm.overcommit_memory = 1

或/etc/sysctl.conf并将其更改为1。

C.现在重新启动Redis服务器。

$ systemctl重新启动redis

请立即检查Redis状态。

如果仍然存在问题,请继续编辑并重新创建服务文件。

========= vi /etc/systemd/system/redis.service

您将看到以下内容:

[Unit]描述= Redis之后的内存数据存储= network.target

[服务]用户=根组=根ExecStart = / usr / local / bin / redis-server /etc/redis/redis.conf ExecStop = / usr / local / bin / redis-cli shutdown重新启动=始终

类型=分叉

[安装] WantedBy = multi-user.target

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

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

现在,启动redis服务

$ systemctl启动redis

现在,Redis将启动而不会给出任何错误。

+ ============== +

测试Redis:-

[root @ server]#redis-cli 127.0.0.1:6379> ping使用echo命令回显给定的字符串:127.0.0.1:6379> echo“ Tecmint正在测试Redis”您还可以使用set命令设置键值像这样:127.0.0.1:6379>设置mykey“正在测试Redis”现在查看mykey的值:127.0.0.1:6379> get mykey“正在测试Redis” 127.0.0.1:6379> exit [root @ server]#

现在,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.