7

i just installed redis and it doesnt work at all when trying to start service with command:

sudo service redis-server start

this is result of 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.

and this is the result of 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.
12

I had the same issue and could not find a working solution anywhere. After some searching, the following fix worked for me ( Ubuntu 16.04 )

In /etc/systemd/system/redis.service add the following under the [Service] section.

Type=forking
  • Mine too, thanks! How did you discover to add this? What does it actually do? – fpghost Jan 27 '18 at 2:05
3

Open your service using whatever editor.

vim /etc/systemd/system/redis.service

Look at your [Service] section at ExecStart mine was:

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

Run this command to see what errors are occuring. Mine responded with this:

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

So I just updated that line to this (where my actual config file was)

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

Which is where redis quickstart places it by default... :)

2

I faced the same error. But for me the reason was totally different: It was due to a typo in my redis.conf file. Correcting that and doing sudo systemctl restart redis-server restarted redis instantly. It is misleading that same error is being thrown for this case also.

1

redis.service file is missing in "/etc/systemd/system/" directory

sudo nano /etc/systemd/system/redis.service

then copy and paste these lines

[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

save and close this file

next modify the directory permisssions

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

next start the redis server

$ sudo systemctl start redis

check if its running now

$ sudo systemctl status redis

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

0

Please check your redis.log. You should see something like this:

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

Therefore check your system limits and maybe file permissions of your redis AOF (/var/lib/redis/*). For system limits, here is a good guide.

0

I needed both a /var/lib/redis folder and a redis user and group.

I used Kevin Upton's https://askubuntu.com/a/981641/451682 advice to find my issues: vim /etc/systemd/system/redis.service led me to /usr/local/bin/redis-server /etc/redis/redis.conf which responded with Can't chdir to '/var/lib/redis': No such file or directory which I created with sudo mkdir /var/lib/redis.

Then, though, I also needed to create the redis user and group and plop that on the /var/lib/redis dir, following Rishik Rohan's https://askubuntu.com/a/918408/451682 :

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

Thanks you two!

0

after making all conf try these commands

sudo systemctl daemon-reload

sudo chown redis:redis /var/lib/redis

sudo chmod 770 /var/lib/redis

And after

sudo systemctl start redis
0

Steps to resolve that issue:- +==============+ A. Set memory limit in redis.conf in 566 number line

566 maxmemory 256mb 567 maxmemory-policy allkeys-lru

B. set the Linux kernel overcommit memory setting to 1:

$ sudo sysctl vm.overcommit_memory=1

or /etc/sysctl.conf and change it to 1.

C. Restart the redis server now.

$ systemctl restart redis

Please check now Redis status.

And if the still issue persists then Go and edit and redis service file.

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

You will see like this:-

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

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

Type=Forking

[Install] WantedBy=multi-user.target

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

to

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

Now, Start the redis service

$ systemctl start redis

Now Redis will start without giving any error.

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

Testing the redis:-

[root@server]# redis-cli 127.0.0.1:6379> ping Use the echo command to echo a given string: 127.0.0.1:6379> echo "Tecmint is testing Redis" You can also set a key value using the set command like this: 127.0.0.1:6379> set mykey "is testing Redis" Now view the value of mykey: 127.0.0.1:6379> get mykey "is testing Redis" 127.0.0.1:6379> exit [root@server]#

Now redis started successfully and running.

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

Thanks & Regards

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.