Accepting request 634217 from server:database

OBS-URL: https://build.opensuse.org/request/show/634217
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/redis?expand=0&rev=45
This commit is contained in:
Yuchen Lin 2018-09-11 15:15:47 +00:00 committed by Git OBS Bridge
commit 8ae610416d
7 changed files with 185 additions and 34 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,58 @@
-------------------------------------------------------------------
Fri Sep 7 12:03:31 UTC 2018 - Marcus Rueckert <mrueckert@suse.de>
- make sure that disabling/restarting servers works
https://nordisch.org/posts/hooking-up-instantiated-services-with-rpm/
-------------------------------------------------------------------
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>
- replace some duplicate binaries with symlinks similar to what the
fedora package does
-------------------------------------------------------------------
Fri Aug 17 00:33:26 UTC 2018 - ilya@ilya.pp.ua

View File

@ -12,12 +12,14 @@
# 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 http://bugs.opensuse.org/
#
%define _data_dir %{_localstatedir}/lib/%{name}
%define _log_dir %{_localstatedir}/log/%{name}
%define _conf_dir %{_sysconfdir}/%{name}
Name: redis
Version: 4.0.11
Release: 0
@ -32,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
@ -72,6 +76,7 @@ make %{?_smp_mflags} CFLAGS="%{optflags}" V=1
%install
install -m 0750 -d \
%{buildroot}%{_sbindir} \
%{buildroot}%{_log_dir} \
%{buildroot}%{_data_dir} \
%{buildroot}%{_conf_dir} \
@ -80,15 +85,19 @@ install -m 0750 -d \
install -Dpm 0755 src/%{name}-benchmark %{buildroot}%{_bindir}/%{name}-benchmark
install -Dpm 0755 src/%{name}-cli %{buildroot}%{_bindir}/%{name}-cli
install -Dpm 0755 src/%{name}-check-aof %{buildroot}%{_bindir}/%{name}-check-aof
install -Dpm 0755 src/%{name}-check-rdb %{buildroot}%{_bindir}/%{name}-check-rdb
install -Dpm 0755 src/%{name}-trib.rb %{buildroot}%{_bindir}/%{name}-trib.rb
install -Dpm 0755 src/%{name}-server %{buildroot}%{_sbindir}/%{name}-server
ln -sfv redis-server %{buildroot}%{_sbindir}/%{name}-sentinel
ln -sfv ../sbin/redis-server %{buildroot}%{_bindir}/%{name}-check-aof
ln -sfv ../sbin/redis-server %{buildroot}%{_bindir}/%{name}-check-rdb
ln -sfv ../sbin/redis-server %{buildroot}%{_sbindir}/%{name}-check-aof
ln -sfv ../sbin/redis-server %{buildroot}%{_sbindir}/%{name}-check-rdb
ln -sfv ../sbin/redis-server %{buildroot}%{_sbindir}/%{name}-sentinel
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
@ -96,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
@ -107,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
@ -115,18 +127,18 @@ getent group %{name} >/dev/null || %{_sbindir}/groupadd -r %{name} || :
getent passwd %{name} >/dev/null || \
%{_sbindir}/useradd -g %{name} -s /bin/false -r \
-c "User for %{name} key-value store" -d %{_data_dir} %{name} || :
%service_add_pre %{name}.target
%service_add_pre redis.target redis@.service redis-sentinel.target redis-sentinel@.service
%post
systemd-tmpfiles --create %{_libexecdir}/tmpfiles.d/%{name}.conf || true
%service_add_post %{name}.target
%service_add_post redis.target redis@.service redis-sentinel.target redis-sentinel@.service
echo "See %{_docdir}/%{name}/README.SUSE to continue"
%preun
%service_del_preun %{name}.target
%service_del_preun redis.target redis@.service redis-sentinel.target redis-sentinel@.service
%postun
%service_del_postun %{name}.target
%service_del_postun redis.target redis@.service redis-sentinel.target redis-sentinel@.service
%files
%license COPYING
@ -139,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]