Accepting request 633784 from home:darix:apps

- make check && true -> make check || true
  This was probably meant to catch an error in the test suite, but
  with && it would only return true if it would return true
  already.

- added systemd unit file file redis-sentinel
  - the unit file uses the same multiple instance mechanism as the
    normal redis unit file
    systemctl start redis-sentinel@default will look for
    /etc/redis/sentinel-default.conf
    and expects a pid file
    /var/run/redis/sentinel-default.pid
    Please make sure your sentinel config sets the pid file.
  - adapted the default sentinel.conf.example to set the pid file
    and the log file similar to the normal redis.conf:
    /var/log/redis/sentinel-<instancename>.log
    /var/run/redis/sentinel-<instancename>.pid
    The unit file checks for the pid file so please adapt your
    local sentinel configs.
    Changed: redis-conf.patch
  - adapt and restructure README.SUSE
    - move the LimitNoFile to the service file itself so the user
      do not have to manually do that step for every instance
    - move the apache integration into its own section
    - add section for redis-sentinel
  - install sentinel example config with group write permissions
    to indicate that the actually config needs to be writable.

OBS-URL: https://build.opensuse.org/request/show/633784
OBS-URL: https://build.opensuse.org/package/show/server:database/redis?expand=0&rev=120
This commit is contained in:
Adam Majer 2018-09-06 19:15:00 +00:00 committed by Git OBS Bridge
parent c46087f639
commit dbfb16fd73
7 changed files with 158 additions and 27 deletions

View File

@ -1,19 +1,79 @@
README.SUSE
-------------
1. copy /etc/redis/default.conf.example to /etc/redis/default.conf (or
/etc/redis/otherapp.conf and so on) For the example we will use
otherapp.conf
Redis Server
==============
1. cp -a /etc/redis/default.conf.example /etc/redis/instancename.conf
We use the "cp -a" here, so that our permissions are preserved.
In case you copied the file with out the "-a"
chown root:redis /etc/redis/instancename.conf
chmod u=rw,g=r,o= /etc/redis/instancename.conf
2. change at least pidfile, logfile and dir setting
# the pid file *has* to match your config filename without the ".conf"
pidfile /var/run/redis/otherapp.pid
logfile /var/log/redis/otherapp.log
dir /var/lib/redis/otherapp/
pidfile /var/run/redis/instancename.pid
logfile /var/log/redis/instancename.log
dir /var/lib/redis/instancename/
If you want to run more than one instance you also have to change the
socket path and/or the ip:port combination.
e.g. /var/run/redis/otherapp.sock
e.g. /var/run/redis/instancename.sock
Also make sure if you copy configurations from somewhere, that "daemonize"
should be set to "no".
3. create the database dir:
$ install -d -o redis -g redis -m 0750 /var/lib/redis/instancename/
4. systemctl start redis@instancename
5. systemctl enable redis@instancename
6. To stop/restart all instances at the same time use:
systemctl restart redis.target
systemctl stop redis.target
Redis Sentinel
================
1. cp -a /etc/redis/sentinel.conf.example /etc/redis/sentinel-instancename.conf
We use the "cp -a" here, so that our permissions are preserved.
In case you copied the file with out the "-a"
chown root:redis /etc/redis/sentinel-instancename.conf
chmod u=rw,g=rw,o= /etc/redis/sentinel-instancename.conf
Please note that the sentinel config needs write permissions for the group.
The chmod line differs from the line for the normal redis server.
2. change at least pidfile, logfile setting
# the pid file *has* to match your config filename without the ".conf"
pidfile /var/run/redis/instancename.pid
logfile /var/log/redis/instancename.log
If you want to run more than one instance you also have to change the
socket path and/or the ip:port combination.
e.g. /var/run/redis/instancename.sock
Also make sure if you copy configurations from somewhere, that "daemonize"
should be set to "no".
4. systemctl start redis-sentinel@instancename
5. systemctl enable redis-sentinel@instancename
6. To stop/restart all instances at the same time use:
systemctl restart redis-sentinel.target
systemctl stop redis-sentinel.target
Integration with apache when using unix domain sockets
=========================================================
If you plan to use redis in combination with apache, then you should
add 'redis' to apache group and set 'unixsocketperm 770':
@ -21,21 +81,4 @@ $ usermod -a -G redis wwwrun
$ systemctl restart apache2
then apache is able to connect to redis socket
Also make sure if you copy configurations from somewhere, that "daemonize"
should be set to "no".
3a. create the database dir:
$ install -d -o redis -g redis -m 0750 /var/lib/redis/otherapp/
3b. add limits (ulimit) to each service
$ install -d -m 0755 /etc/systemd/system/redis@otherapp.service.d
$ echo "[Service]
LimitNOFILE=10240" > /etc/systemd/system/redis@otherapp.service.d/limits.conf
4. systemctl start redis@otherapp
5. systemctl enable redis@otherapp
6. to interact with all instances at the same time use:
systemctl restart redis.target
systemctl stop redis.target

View File

@ -48,3 +48,21 @@ Index: redis.conf
################################# REPLICATION #################################
Index: sentinel.conf
===================================================================
--- sentinel.conf.orig
+++ sentinel.conf
@@ -1,4 +1,8 @@
# Example sentinel.conf
+#
+pidfile /var/run/redis/sentinel-default.pid
+loglevel notice
+logfile /var/log/redis/sentinel-default.log
# *** IMPORTANT ***
#
@@ -202,4 +206,3 @@ sentinel failover-timeout mymaster 18000
# to get the program executed.
sentinel deny-scripts-reconfig yes
-

3
redis-sentinel.target Normal file
View File

@ -0,0 +1,3 @@
[Unit]
Description=Redis Sentinel target allowing to start/stop all redis-sentinel@.service instances at once

17
redis-sentinel@.service Normal file
View File

@ -0,0 +1,17 @@
[Unit]
Description=Redis
After=network.target
PartOf=redis-sentinel.target
[Service]
Type=simple
User=redis
Group=redis
PrivateTmp=true
PIDFile=/var/run/redis/sentinel-%i.pid
ExecStart=/usr/sbin/redis-sentinel /etc/redis/sentinel-%i.conf
LimitNOFILE=10240
Restart=on-failure
[Install]
WantedBy=multi-user.target redis.target

View File

@ -1,3 +1,45 @@
-------------------------------------------------------------------
Thu Sep 6 19:03:06 UTC 2018 - Marcus Rueckert <mrueckert@suse.de>
- make check && true -> make check || true
This was probably meant to catch an error in the test suite, but
with && it would only return true if it would return true
already.
-------------------------------------------------------------------
Thu Sep 6 17:01:14 UTC 2018 - Marcus Rueckert <mrueckert@suse.de>
- added systemd unit file file redis-sentinel
- the unit file uses the same multiple instance mechanism as the
normal redis unit file
systemctl start redis-sentinel@default will look for
/etc/redis/sentinel-default.conf
and expects a pid file
/var/run/redis/sentinel-default.pid
Please make sure your sentinel config sets the pid file.
- adapted the default sentinel.conf.example to set the pid file
and the log file similar to the normal redis.conf:
/var/log/redis/sentinel-<instancename>.log
/var/run/redis/sentinel-<instancename>.pid
The unit file checks for the pid file so please adapt your
local sentinel configs.
Changed: redis-conf.patch
- adapt and restructure README.SUSE
- move the LimitNoFile to the service file itself so the user
do not have to manually do that step for every instance
- move the apache integration into its own section
- add section for redis-sentinel
- install sentinel example config with group write permissions
to indicate that the actually config needs to be writable.
-------------------------------------------------------------------
Thu Sep 6 15:08:28 UTC 2018 - Marcus Rueckert <mrueckert@suse.de>

View File

@ -12,7 +12,7 @@
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
@ -34,6 +34,8 @@ Source3: %{name}@.service
Source4: %{name}.tmpfiles.d
Source5: README.SUSE
Source6: %{name}.sysctl
Source7: %{name}-sentinel@.service
Source8: %{name}-sentinel.target
# PATCH-FIX-OPENSUSE -- openSUSE-style init script
Patch0: %{name}-initscript.patch
# PATCH-MISSING-TAG -- See https://wiki.opensuse.org/openSUSE:Packaging_Patches_guidelines
@ -95,7 +97,7 @@ ln -sfv ../sbin/redis-server %{buildroot}%{_sbindir}/%{name}-sentine
perl -p -i -e 's|daemonize yes|daemonize no|g' %{name}.conf
install -Dm 0640 redis.conf %{buildroot}%{_conf_dir}/default.conf.example
install -Dm 0640 sentinel.conf %{buildroot}%{_conf_dir}/sentinel.conf.example
install -Dm 0660 sentinel.conf %{buildroot}%{_conf_dir}/sentinel.conf.example
# some sysctl stuff
install -Dm 0644 %{SOURCE6} %{buildroot}%{_sysconfdir}/sysctl.d/00-%{name}.conf
@ -103,6 +105,9 @@ install -Dm 0644 %{SOURCE1} %{buildroot}%{_sysconfdir}/logrotate.d/%{name}
install -Dm 0644 %{SOURCE2} %{buildroot}%{_unitdir}/%{name}.target
install -Dm 0644 %{SOURCE3} %{buildroot}%{_unitdir}/%{name}@.service
install -Dm 0644 %{SOURCE4} %{buildroot}%{_libexecdir}/tmpfiles.d/%{name}.conf
install -Dm 0644 %{SOURCE7} %{buildroot}%{_unitdir}/%{name}-sentinel@.service
install -Dm 0644 %{SOURCE8} %{buildroot}%{_unitdir}/%{name}-sentinel.target
ln -sf %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}
cp %{SOURCE5} README.SUSE
@ -114,7 +119,7 @@ The test suite often fails to start a server, with
'child process exited abnormally' -- sometimes it works.
---------------------------------------------------
EOF
make %{?_smp_mflags} test && true
make %{?_smp_mflags} test || true
%endif
%pre
@ -146,6 +151,8 @@ echo "See %{_docdir}/%{name}/README.SUSE to continue"
%{_libexecdir}/tmpfiles.d/%{name}.conf
%{_unitdir}/%{name}@.service
%{_unitdir}/%{name}.target
%{_unitdir}/%{name}-sentinel@.service
%{_unitdir}/%{name}-sentinel.target
%doc README.SUSE
%config(noreplace) %attr(-,root,%{name}) %{_conf_dir}/
%dir %attr(0750,%{name},%{name}) %{_data_dir}

View File

@ -10,6 +10,7 @@ Group=redis
PrivateTmp=true
PIDFile=/var/run/redis/%i.pid
ExecStart=/usr/sbin/redis-server /etc/redis/%i.conf
LimitNOFILE=10240
Restart=on-failure
[Install]