Redis Rocky Linux Setup: 7 Easy Steps, Avoid Mistakes
A Redis Rocky Linux setup is short, but the old version of this post, written for Rocky Linux and CentOS 8, no longer works as written on Rocky Linux 9, and two of its settings can leave your server open to the whole network. This rewrite re-runs every step on Rocky Linux 9.8 in two containers on one network (a server and a client). Containers have no systemd, so I started redis-server directly with the packaged configuration file instead of using systemctl; the service unit is shown below, but not run. The Redis version installed was 6.2.24.
Contents
- Step 1: install Redis on Rocky Linux 9 from AppStream
- Step 2: see what the Redis Rocky Linux package installed
- Step 3: know the Redis Rocky Linux defaults in redis.conf
- Step 4: allow remote access to Redis, carefully
- Step 5: the pidfile setting for Redis on Rocky Linux
- Step 6: persistence for Redis on Rocky Linux with appendonly
- Step 7: benchmark Redis on Rocky Linux, and give access safely
- Redis Rocky Linux mistakes to avoid
- FAQ
Step 1: install Redis on Rocky Linux 9 from AppStream
The old post added the Remi repository for version 8. On Rocky 9 that package cannot be installed:
$ dnf -y install https://rpms.remirepo.net/enterprise/remi-release-8.rpm
Problem: conflicting requests
- nothing provides epel-release = 8 needed by remi-release-8.10-2.el8.remi.noarch from @commandline
- nothing provides system-release(releasever) = 8 needed by remi-release-8.10-2.el8.remi.noarch from @commandline
You do not need it for a Redis Rocky Linux install. Redis is in the Rocky 9 AppStream repository:
$ dnf -y install redis
Installing:
redis x86_64 6.2.24-1.el9_8 appstream 1.3 M
$ redis-server --version
Redis server v=6.2.24 sha=00000000:0 malloc=jemalloc-5.1.0 bits=64 build=bd9d9bb4bf15744a
There is a twist in the Redis Rocky Linux packaging. dnf module list redis shows a module stream redis 7 with the profile common [d], and dnf module info redis:7 lists 7.2.x builds (7.2.11, 7.2.14 and 7.2.16 in the output). Yet a plain dnf install redis installed 6.2.24. If you need Redis 7, enable the stream first (dnf module enable redis:7); I did not test that, so check the installed version afterwards with redis-server --version.
Step 2: see what the Redis Rocky Linux package installed
$ rpm -ql redis | grep -E "conf|systemd|bin/"
/etc/redis/redis.conf
/etc/redis/sentinel.conf
/usr/bin/redis-benchmark
/usr/bin/redis-check-aof
/usr/bin/redis-check-rdb
/usr/bin/redis-cli
/usr/bin/redis-sentinel
/usr/bin/redis-server
/usr/lib/systemd/system/redis.service
$ id redis
uid=998(redis) gid=998(redis) groups=998(redis)
The packaged unit starts the server with ExecStart=/usr/bin/redis-server /etc/redis/redis.conf --daemonize no --supervised systemd, as the user redis, with Type=notify and RuntimeDirectory=redis. On a real server, start it with sudo systemctl enable --now redis as the old post did.
Step 3: know the Redis Rocky Linux defaults in redis.conf
$ grep -E "^(bind|protected-mode|port|daemonize|pidfile|dir|appendonly)" /etc/redis/redis.conf
bind 127.0.0.1 -::1
protected-mode yes
port 6379
daemonize no
pidfile /var/run/redis_6379.pid
dir /var/lib/redis
appendonly no
These defaults are safe for a single-host Redis Rocky Linux server. The commented line # requirepass is the only password setting. With these defaults, a client on another machine cannot connect at all:
$ redis-cli -h 10.89.1.2 ping
Could not connect to Redis at 10.89.1.2:6379: Connection refused
Step 4: allow remote access to Redis, carefully
Remote access is where a Redis Rocky Linux setup goes wrong most often. The old post set bind 0.0.0.0 first and only then a password. That order is the dangerous one. I started Redis with --bind 0.0.0.0 and no password, and protected-mode still said yes, yet a client on another container got an answer:
$ redis-cli -h 10.89.1.2 ping
PONG
Protected mode did not help, because the bind address had been set explicitly. Anyone who can reach port 6379 could read and change your data at this point. Now add the old post's password line, requirepass devopsroles.com, and try again from the client:

$ redis-cli -h 10.89.1.2 ping
NOAUTH Authentication required.
$ redis-cli -h 10.89.1.2 -a devopsroles.com ping
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
PONG
Use a long random password, not the example, and add --no-auth-warning in scripts only after you understand the warning: a password on the command line is visible in the process list. The official Redis security guide recommends keeping Redis off untrusted networks, so also limit port 6379 with a firewall, as shown in the iptables post.
Step 5: the pidfile setting for Redis on Rocky Linux
The old post added pidfile /var/run/redis/redis-server.pid. In a missing directory, Redis still started, and quietly wrote no pid file:
$ redis-server /etc/redis/redis.conf --daemonize yes --pidfile /var/run/redis/redis-server.pid
$ redis-cli ping
PONG
$ ls /var/run/redis
ls: cannot access '/var/run/redis': No such file or directory
After mkdir -p /var/run/redis the file appeared (4 bytes, owned by root because I ran the test as root). Under systemd you do not need to manage this: the unit has RuntimeDirectory=redis and Type=notify, so skip the pidfile line unless a tool asks for it.
Step 6: persistence for Redis on Rocky Linux with appendonly
The old post set appendonly yes and appendfilename "appendonly.aof". In Redis 6.2 the append-only file is one file in the dir folder:
$ redis-cli -a devopsroles.com --no-auth-warning SET site huuphan
OK
$ ls -la /var/lib/redis
-rw-r--r--. 1 root root 59 Nov 2 08:30 appendonly.aof
$ redis-cli -a devopsroles.com --no-auth-warning shutdown
$ redis-server /tmp/old.conf --daemonize yes
$ redis-cli -a devopsroles.com --no-auth-warning GET site
huuphan
$ redis-cli -a devopsroles.com --no-auth-warning DBSIZE
1
The key survived a restart, which is what you want from Redis on Rocky Linux when it is more than a cache. (Redis 7 and later keep the append-only files in a subfolder, so check which version you installed.) Back up /var/lib/redis if the data matters.
Step 7: benchmark Redis on Rocky Linux, and give access safely
The old benchmark command ran against the server from the client, 10,000 requests with 20 connections. On the container network it reported about 98,000 to 130,000 requests per second for PING, SET, GET, INCR and LPUSH. Treat that as a smoke test of the setup; it says nothing about your hardware. For access control beyond one shared password, create a user with only the commands and keys it needs:
$ redis-cli -a devopsroles.com --no-auth-warning ACL SETUSER app on ">app-pass-1" "~app:*" "+get" "+set"
OK
$ redis-cli --user app --pass app-pass-1 --no-auth-warning SET app:1 x
OK
$ redis-cli --user app --pass app-pass-1 --no-auth-warning SET other:1 x
NOPERM this user has no permissions to access one of the keys used as arguments
$ redis-cli --user app --pass app-pass-1 --no-auth-warning FLUSHALL
NOPERM this user has no permissions to run the 'flushall' command or its subcommand
Redis Rocky Linux mistakes to avoid
- Following a Redis Rocky Linux guide for version 8 on version 9, and copying the Remi release package onto Rocky 9.
- Setting
bind 0.0.0.0before a password exists. - Expecting protected mode to save you after you set bind yourself.
- Putting a real password in a command line or a blog post.
- Assuming the installed version is the module stream you saw in
dnf module list.
If you run Redis in a container instead, keep its data on a volume; the Docker volumes post shows how volumes behave in a real test.
FAQ
Does this Redis Rocky Linux setup work on CentOS 8? The commands are the same dnf commands, but the Remi steps in the old post were written for version 8 and were not re-tested here.
Is a Redis Rocky Linux server safe with only requirepass? It is better than nothing, but keep port 6379 behind a firewall and prefer an ACL user for applications.
Was systemctl tested? No. The lab used containers without systemd, so only the unit file contents were checked.
How do I check the Redis version? Run redis-server --version, or redis-cli INFO server, which showed redis_version:6.2.24 in the lab.
Comments
Post a Comment