Running Redis as a systemd service

54 views
Skip to first unread message

Eric Fetzer

unread,
Aug 26, 2021, 3:42:11 PMAug 26
to Redis DB
So I'm not sure how to even figure out what's happening.  Running redis-server version 6.2.5 on RHEL 7.9.  I can start REDIS with the user I want to run it as from the command line.  But when  I try to start it as a systemd service with the REDIS.service file:

[Unit]
Description=REDIS Service
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=simple
User=myuser
Group=myuser
WorkingDirectory=/app/redis
ExecStart=/bin/redis-server /app/redis/primary.conf
Restart=on-failure
[Install]
WantedBy=multi-user.target

It fails.  All I see from status is:

â— REDIS.service - REDIS Service
   Loaded: loaded (/etc/systemd/system/REDIS.service; enabled; vendor preset: disabled)
   Active: failed (Result: start-limit) since Thu 2021-08-26 14:38:45 CDT; 12s ago
  Process: 75670 ExecStart=/bin/redis-server /app/redis/primary.conf (code=exited, status=1/FAILURE)
 Main PID: 75670 (code=exited, status=1/FAILURE)

Aug 26 14:38:44 myServer systemd[1]: Unit REDIS.service entered failed state.
Aug 26 14:38:44 myServer systemd[1]: REDIS.service failed.
Aug 26 14:38:45 myServer systemd[1]: REDIS.service holdoff time over, scheduling restart.
Aug 26 14:38:45 myServer systemd[1]: Stopped REDIS Service.
Aug 26 14:38:45 myServer systemd[1]: start request repeated too quickly for REDIS.service
Aug 26 14:38:45 myServer systemd[1]: Failed to start REDIS Service.
Aug 26 14:38:45 myServer systemd[1]: Unit REDIS.service entered failed state.
Aug 26 14:38:45 myServer systemd[1]: REDIS.service failed.

How do I trouble shoot what's going on, it's not putting anything in the logfile I have set in the config file?

Thanks,
Eric

Eric Fetzer

unread,
Aug 27, 2021, 10:08:10 AMAug 27
to Redis DB
Apparently this group isn't too active.  None the less, I'll document what I find as I troubleshoot this for others future benefit.  Using journalctl -u REDIS.service, I found the following error happening:

Aug 27 08:57:18 nd155ap001 redis-server[119338]: 119338:C 27 Aug 2021 08:57:18.981 # Fatal error, can't open config file '/app/redis/primary.conf': Permission denied

I'm telling the service to run as the user that owns the /app/redis directory as well as primary.conf file.  It starts fine when I run it manually under that user using the same command in the REDIS.service systemd service file.  Gonna see what journalctl produces if I change the user to run under root.

Eric Fetzer

unread,
Aug 27, 2021, 10:25:42 AMAug 27
to Redis DB
Hmmmm, getting permission denied even under the root user.  At a loss...

Greg Andrews

unread,
Aug 28, 2021, 12:40:18 AMAug 28
to Redis DB
If Redis is able to read its config file in the stock location that was set up when the package was installed on your server, but not on the new custom location you're changing to, then I would ask myself whether SELinux is blocking the file access.

Eric Fetzer

unread,
Aug 30, 2021, 1:57:21 PMAug 30
to redi...@googlegroups.com
How do I know what the stock location is?  This was installed with yum and redis-server is in /bin.

Thanks,
Eric

--
You received this message because you are subscribed to a topic in the Google Groups "Redis DB" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/redis-db/EthS-o6cio8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to redis-db+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/redis-db/2762011f-785c-48c5-8fd2-4d5314002569n%40googlegroups.com.

Kunal Gangakhedkar

unread,
Aug 31, 2021, 2:41:49 AMAug 31
to redi...@googlegroups.com
On redhat based distros, you can query the contents of an installed package with:
$ rpm -ql <package-name>

So, assuming the package name of stock redis rpm was redis-server, this should list all files bundled in the package:
$ rpm -ql redis-server

Most likely, the default config locations would be:
/etc/sysconfig/redis-server - for arguments/env vars for the service unit
/etc/redis/redis.conf - redis server config

Here is the listing:
Check the "files" section on this page.

On the other hand, RHEL has SELinux in "enforcing" mode by default. Most likely, that's blocking access to the required files/directories and causing the permission denied error.
The default package would have added the required permissions for the directories it uses. You seem to use non-standard paths /app/redis.
Please search for how to configure proper permissions for selinux.

Hope this helps.

Kunal


You received this message because you are subscribed to the Google Groups "Redis DB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to redis-db+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/redis-db/CAByBicawYVDGE5tt2PTWPCvhh%3DdwnjKJH7ok8_ZNNyfDwTvq2A%40mail.gmail.com.

Eric Fetzer

unread,
Aug 31, 2021, 1:19:19 PMAug 31
to Redis DB
Upon further investigation, the server was very messed up.  There were multiple installs of redis, multiple service files  for redis/REDIS in /etc/systemd/system, the rpm database was corrupt, I'm not sure what all was messed up...  I did a bunch of cleanup and then a fresh install and it's working now.  Thanks for the trouble-shooting pointers Kunal!

Reynold Yick

unread,
Sep 1, 2021, 6:50:48 AMSep 1
to Redis DB
I would prefer to install Redis via REMI repository. There is the latest version for Redis.

You should install EPEL repository first and install REMI repository with https://rpms.remirepo.net/enterprise/remi-release-7.rpm
Use yum command to list redis and install redis. It will be installed into systemd.

Please download rpm file from REMI repo as well. This would be much easier to upgrade Redis after system security audit.

Thank you.

Eric Fetzer

unread,
Sep 1, 2021, 11:34:28 AMSep 1
to redi...@googlegroups.com
Thanks again Reynold.  Unfortunately, our Systems team (another organization) is opposed to me putting remi on there.  I suppose I could "yum-config-manager --enable/--disable" the repo and only use it for upgrades, but for now I'm just going to do local makes/installs...  Won't be tough to upgrade, local make/install then copy the executables to the servers using it...

--
You received this message because you are subscribed to a topic in the Google Groups "Redis DB" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/redis-db/EthS-o6cio8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to redis-db+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages