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:
--
-- 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. 0 11 Answers
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 1 Open your service using whatever editor.
vim /etc/systemd/system/redis.serviceLook at your [Service] section at ExecStart mine was:
ExecStart=/usr/local/bin/redis-server /etc/redis/redis.confRun 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.confWhich is where redis quickstart places it by default... :)
In my case , the log directory (/var/log/redis) which I mention in /etc/redis/redis.conf file was not present
How I find the error
Try
/usr/local/bin/redis-server /etc/redis/redis.confThis is same command present in my /etc/systemd/system/redis.service file
ExecStart=/usr/local/bin/redis-server /etc/redis/redis.confSolution
1) Create the log directory
sudo mkdir -p /var/log/redis2) Give proper access to create and write logs
sudo chown redis:redis /var/log/redisTry to start the service again
sudo service redis-server start or
sudo service redis start 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.targetsave 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/redisnext start the redis server
$ sudo systemctl start redis
check if its running now
$ sudo systemctl status redis
REFERENCE :
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.
after making all conf try these commands
sudo systemctl daemon-reload
sudo chown redis:redis /var/lib/redis
sudo chmod 770 /var/lib/redisAnd after
sudo systemctl start redis 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 systemTherefore check your system limits and maybe file permissions of your redis AOF (/var/lib/redis/*). For system limits, here is a good guide.
I needed both a /var/lib/redis folder and a redis user and group.
I used Kevin Upton's 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 :
sudo adduser --system --group --no-create-home redis
sudo chown redis:redis /var/lib/redis
sudo chmod 770 /var/lib/redisThanks you two!
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
Although Even rebooting the system could not help, in my case it was because of a running background process which was found using :
ss -tulpn
killed it.
kill [process id/number]
Afterwards I could start redis service again.
service redis start
When updating from versions <6 to 6 and above, systemd support has been added in by default.
But your old config might have an old setting supervised = no inside.
That won't work with the Systemd Service Type notify.
Set the option supervised = systemd in your (/etc/redis/redis-conf) redis.conf and it should work.