8

We've been running redis-server on a number of AWS EC2 Ubuntu instances (14.04.4 LTS) with no problems. I spun up a test server to try the upgrade to Ubuntu 16.04.1 LTS, and now redis won't work.

If I try to start redis manually, I get this:

~$ sudo service redis-server restart
Job for redis-server.service failed because the control process exited with error code. See "systemctl status redis-server.service" and "journalctl -xe" for details.

Error info:

~$ systemctl status redis-server.service  
● redis-server.service - Advanced key-value store
  Loaded: loaded (/lib/systemd/system/redis-server.service; enabled; vendor preset: enabled)
  Active: inactive (dead) (Result: exit-code) since Wed 2016-10-19 19:26:06 UTC; 25min ago
    Docs: http://redis.io/documentation,
          man:redis-server(1)
 Process: 3730 ExecStart=/usr/bin/redis-server /etc/redis/redis.conf (code=exited, status=1/FAILURE)
 Process: 3724 ExecStartPre=/bin/run-parts --verbose /etc/redis/redis-server.pre-up.d (code=exited, status=0/SUCCESS)

Oct 19 19:26:06 ip-x-y-z-w systemd[1]: redis-server.service: Control process exited, code=exited status=1
Oct 19 19:26:06 ip-x-y-z-w systemd[1]: Failed to start Advanced key-value store.
Oct 19 19:26:06 ip-x-y-z-w systemd[1]: redis-server.service: Unit entered failed state.
Oct 19 19:26:06 ip-x-y-z-w systemd[1]: redis-server.service: Failed with result 'exit-code'.
Oct 19 19:26:06 ip-x-y-z-w systemd[1]: redis-server.service: Service hold-off time over, scheduling restart.
Oct 19 19:26:06 ip-x-y-z-w systemd[1]: Stopped Advanced key-value store.
Oct 19 19:26:06 ip-x-y-z-w systemd[1]: redis-server.service: Start request repeated too quickly.
Oct 19 19:26:06 ip-x-y-z-w systemd[1]: Failed to start Advanced key-value store.

I've tried the following:

  • restarted the server
  • run our deployment script, which includes a redis restart
  • used sudo apt-get to uninstall and re-install redis-server
  • done the installation twice, once accepting the new /etc/redis/redis.conf file from the package, and once keeping our original file

Any suggestions?

  • not an answer, but might help: You can run redis as a docker container. – pLumo Mar 13 '18 at 12:05
5

I installed redis using apt-get install redis-server

The problem for me: the tutorials I've found eg. the other reply to this question assume that redis binaries are located in /usr/local/bin .

On my install they're located in /usr/bin so a fix for that is changing /etc/systemd/system/redis.service to reflect this.

At this point I can at start /usr/bin/redis-server /etc/redis/redis.conf manually and successfully run sudo systemctl start redis.

So what you need to do to get redis working on 16.04 is:

  1. Make sure you installed using apt-get install redis-server, don't download the tar, then make & install.
  2. Create or edit the redis service by running sudo vi /etc/systemd/system/redis.service
  3. Edit it to look like this then save:
[Unit]
Description=Redis Datastore Server
After=network.target

[Service]
Type=forking
PIDFile=/var/run/redis/redis_6379
User=redis
Group=redis

Environment=statedir=/var/run/redis
PermissionsStartOnly=true
ExecStartPre=/bin/mkdir -p ${statedir}
ExecStartPre=/bin/chown -R redis:redis ${statedir}
ExecStart=/usr/bin/redis-server /etc/redis/redis.conf
ExecReload=/bin/kill -USR2 $MAINPID
ExecStop=/usr/bin/redis-cli shutdown
Restart=always

[Install]
WantedBy=multi-user.target
  1. Quit vi back to bash. You should be able to start the service now with sudo systemctl start redis
  2. If point 4 doesn't work you can probably at least start it manually by running sudo /usr/bin/redis-server /etc/redis/redis.conf .

The important part that I had to edit was making sure that

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

ExecStop=/usr/bin/redis-cli shutdown

lines didn't point to usr/local/bin/foo - need to remove the /local

1

I had the same problem but the cause was different.

I used redis for testing on a VM with dhcp client.

The config /etc/redis/redis.conf was pointing at the wrong (old) local IP and thus it could not bind the service to the new assigned IP from DHCP.

Here is the log for such problem:

mar 13 12:47:53 dev-vm systemd[1]: Failed to start Advanced key-value store.
mar 13 12:47:53 dev-vm systemd[1]: redis-server.service: Unit entered failed state.
mar 13 12:47:53 dev-vm systemd[1]: redis-server.service: Failed with result 'resources'.
mar 13 12:47:53 dev-vm systemd[1]: redis-server.service: Service hold-off time over, scheduling restart.
mar 13 12:47:53 dev-vm systemd[1]: Stopped Advanced key-value store.
mar 13 12:47:53 dev-vm systemd[1]: redis-server.service: Start request repeated too quickly.
mar 13 12:47:53 dev-vm systemd[1]: Failed to start Advanced key-value store.
0

Maybe try this, here is a working config for /lib/systemd/system/redis.service see if this maybe works for you.

[Unit]
Description=Redis Datastore Server
After=network.target

[Service]
Type=forking
PIDFile=/var/run/redis/redis_6379
User=redis
Group=redis

Environment=statedir=/var/run/redis
PermissionsStartOnly=true
ExecStartPre=/bin/mkdir -p ${statedir}
ExecStartPre=/bin/chown -R redis:redis ${statedir}
ExecStart=/usr/local/bin/redis-server /etc/redis/redis.conf 
ExecReload=/bin/kill -USR2 $MAINPID
ExecStop=/usr/local/bin/redis-cli shutdown
Restart=always

[Install]
WantedBy=multi-user.target

Then check the log file specified in the config /etc/redis/redis.conf to make sure you have correct permissions.

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.