I updated from Redis 5.0.9 to 6.0.1 by yum and the connection started to be denied. I can register with Systemd by setting "daemonize yes" to "no" in redis.conf and start redis-server. Did Redis 6.0 change the way redis is daemonized?

I can start redis-server in /etc/systemd/system/redis.service with "SIMPLE" for Type, or if I don't write the Type, I can start redis-server. But I can't connect to the 6379 port.

[Unit]
Description=Redis
After=network.target rc-local.service

[Service]
Type=notify
ExecStart=/usr/bin/redis-server /etc/redis/6379.conf
ExecStop=/usr/bin/redis-cli -a REDISPASSWORD shutdown

User=redis
Group=redis

Restart=on-failure
RestartSec=10

[Install]
WantedBy=multi-user.target

CentOS 7.7

Comment From: gcox

@Bables55 Do you have the libsystemd-dev package installed?

I did not and it prevented me from running Redis 6.x with systemd using Type=notify.

You can confirm this is the problem by commenting out the Restart and RestartSec lines, then adding TimeoutStartSec=5 to your unit file and try to restart Redis. It should fail due to a timeout if you don't have libsystemd-dev installed. That's because server.c - redisCommunicateSystemd is effectively a no-op when libsystemd-dev isn't installed, which means Redis silently fails to notify systemd with "READY=1" so systemd never thinks the process finished starting.

Here's a commit that mentions systemd related build changes in Redis 6.x.

If this is your issue, just install the pkg-config and libsystemd-dev packages, recompile and reinstall redis. Unless you have another problem, it should start now.

Comment From: Bables55

I used yum to install systemd-devel. Does this not include the libsystemd-dev? Redis 6.0.2 has been released. 6.0.2 could not be started as well as 6.0.1.

Comment From: JJJollyjim

Note for others googling for this issue: if you have daemonize=yes, you will see

systemd[1]: redis.service: Failed with result 'protocol'.

The solution is the same.

Comment From: Bables55

You can confirm this is the problem by commenting out the Restart and RestartSec lines, then adding TimeoutStartSec=5 to your unit file and try to restart Redis.

The following is the result of changing the settings as shown above. Redis is ver. 6.0.3.

$ sudo systemctl status redis -l
● redis6.service - Redis
   Loaded: loaded (/etc/systemd/system/redis.service; disabled; vendor preset: disabled)
   Active: failed (Result: protocol) since TIME
  Process: 11371 ExecStart=/usr/bin/redis-server /etc/redis/6379.conf (code=exited, status=0/SUCCESS)
 Main PID: 11371 (code=exited, status=0/SUCCESS)
   Status: "Redis is loading..."

Starting Redis...
Got notification message from PID 11372, but reception only permitted for main PID 11371
Got notification message from PID 11372, but reception only permitted for main PID 11371
Got notification message from PID 11372, but reception only permitted for main PID which is currently not known
Failed to start Redis.
Unit redis6.service entered failed state.
redis.service failed.

I don't know about installing systemd-dev and pkg-config in CentOS7. I am currently exploring it.

Comment From: gcox

@Bables55 Can you post your /etc/redis/6379.conf file? Sounds like you may have specified a PID file in the conf (you don't need that if systemd is handling the daemonization). Also, make sure you have daemonize no in there too. Like @JJJollyjim said, daemonize yes will produce this unhelpful error, "failed (Result: protocol)".

Comment From: Bables55

The attachment below is my 6379 file. For now, I ported the 5.0.9 setting to 6.0. 6379_60.txt

Comment From: gcox

@Bables55 You have "daemonize yes" and you're specifying a pid file. My last comment suggested that you do the opposite. Change "daemonize yes" to "daemonize no". Comment out the pidfile setting.

Comment From: Bables55

@Bables55 You have "daemonize yes" and you're specifying a pid file. My last comment suggested that you do the opposite. Change "daemonize yes" to "daemonize no". Comment out the pidfile setting.

I was able to get a redis6(6.0.3) connection with "daemonize no". Was I just lucky enough to use Redis in the Redis5 era with the wrong settings?

Comment From: gcox

@Bables55 Yeah, having daemonize yes while running it with systemd and Type=notify was always incorrect, but just didn't seem to cause a problem in Redis 5. FWIW, I had the same problem when I upgraded to Redis 6. IMO the comments in the conf file for that setting are inadequate, they should clarify that the purpose of the setting is to tell Redis whether or not to run itself as a daemon, and that it is not to tell Redis that it will be daemonized by something.

One other thing to note, make sure that sudo systemctl status redis shows that the service is "Active" and not "Activating". If it is the latter, something is still not configured correctly.

Comment From: Bables55

One other thing to note, make sure that sudo systemctl status redis shows that the service is "Active" and not "Activating". If it is the latter, something is still not configured correctly.

Redis is in an "active: active (running)" state, so it's not a problem.

Comment From: gcox

@Bables55 Can you close this issue? It sounds like you're all set now.

Comment From: Fruchuxs

Same problem here. Compiled redis, tcl, pkg-config and libsystemd-dev installed. Tests are fine, daemonize no, supervised systemd, no pid file specified. Redis starts, but systemctl doesn't recognize this.

Edit: Set BUILD_WITH_SYSTEMD=no to yes in src/Makefile. Nothing changed... Edit2: Set export USE_SYSTEMD=yes before use make. Nothing changed. I will write a service which uses screen. I'm realy unhappy with this: Your documentation says "please compile by yourself to get the newest version". Okay, I do want you say... And then the quickstart guide suggest me to use init.d? Guys, which distribution uses init.d nowadays? Please update your documentation if you want, that peoples don't uses outdated redis versions through repos, or support a official PPA. Edit3: For others googled this: make BUILD_WITH_SYSTEMD=yes USE_SYSTEMD=yes MALLOC=libc is the correct make command. Only use MALLOC=libc if make fails with an error.

Comment From: yoonghm

Thanks. redis-server works now systemd. I use this command

make USE_SYSTEMD=yes MALLOC=jemalloc V=1 PREFIX=/home/s BUILD_TLS=yes install

I am using redis 6.0.5.

Comment From: itamarhaber

Here - should the docs/conf be updated to include the make flag? I feel like yes, but I'd like more feedback.

Comment From: solracsf

Please note that:

When Redis is supervised by upstart or systemd, this parameter has no impact.

so setting it to no is not a problem.

See https://github.com/redis/redis/pull/8036