Hi,
I came to the following basis:

--- redis.service
+++ redis-server@.service
@@ -1,12 +1,12 @@
 [Unit]
-Description=Advanced key-value store
+Description=Advanced key-value store (%I)
 After=network.target
 Documentation=http://redis.io/documentation, man:redis-server(1)
 
 [Service]
 Type=forking
-ExecStart=/usr/bin/redis-server /etc/redis/redis.conf
-PIDFile=/var/run/redis/redis-server.pid
+ExecStart=/usr/bin/redis-server /etc/redis/redis-%i.conf
+PIDFile=/var/run/redis/redis-server-%i.pid
 TimeoutStopSec=0
 Restart=always
 User=redis
@@ -48,4 +48,3 @@
 
 [Install]
 WantedBy=multi-user.target
-Alias=redis.service

Note the new file name and the removal of the Alias at the last line.
The alias was creating warnings when enabling instances.

> We need to keep the "redis" namespacing to avoid conflicts with
> sentinel :)
I'm not familiar enough with sentinel to understand this: does it means
that the RuntimeDirectory should be the same for every instance?

My use case is a bit different that many users: I'm self-hosting a lot
of services on a small server, without any container or VM. So I'd like
to isolate (a bit) all redis instances from each other, to avoid two
issues: 1) one client overwriting keys by mistake and 2) one rogue
client trying to read data from everyone else.
So my redis instances are running using different users, and listening
only on a UNIX socket with 760 permissions, using the same user/group as
the application itself. There might be a flaw in this setting, but it
seems to be better that one instance for everyone anyway.

In this approach, every instance have different RuntimeDirectory, and
the redis-%i.conf is modified accordingly for both pidfile and
unixsocket directives. For log files, I made it simpler by logging to
stdout (logfile ""). The working directory (dir directive) is also set
to a different value.

If you (or someone) find this seperation desirable, maybe it could be
integrated into redis-server@.service by changing RuntimeDirectory to
redis-%i and ReadWriteDirectory accordingly. It is probably a bad idea
for all users, though.

Thanks for maintaining redis and have a nice day,

Adrien

Reply via email to