diff --git a/SOURCES/macros.redis b/SOURCES/macros.redis new file mode 100644 index 0000000..439cc2c --- /dev/null +++ b/SOURCES/macros.redis @@ -0,0 +1,2 @@ +%redis_modules_abi 1 +%redis_modules_dir %{_libdir}/redis/modules diff --git a/SOURCES/redis-limit-init b/SOURCES/redis-limit-init new file mode 100644 index 0000000..2986bfd --- /dev/null +++ b/SOURCES/redis-limit-init @@ -0,0 +1,6 @@ +# If you need to change max open file limit +# for example, when you change maxclient in configuration +# you can change the value below +# see "man limits.conf" for information +redis soft nofile 10240 +redis hard nofile 10240 diff --git a/SOURCES/redis-limit-systemd b/SOURCES/redis-limit-systemd new file mode 100644 index 0000000..8003c2f --- /dev/null +++ b/SOURCES/redis-limit-systemd @@ -0,0 +1,7 @@ +# If you need to change max open file limit +# for example, when you change maxclient in configuration +# you can change the LimitNOFILE value below +# see "man systemd.exec" for information + +[Service] +LimitNOFILE=10240 diff --git a/SOURCES/redis-sentinel.init b/SOURCES/redis-sentinel.init new file mode 100644 index 0000000..382d45d --- /dev/null +++ b/SOURCES/redis-sentinel.init @@ -0,0 +1,94 @@ +#!/bin/sh +# +# redis init file for starting up the redis-sentinel daemon +# +# chkconfig: - 21 79 +# description: Starts and stops the redis-sentinel daemon. +# +### BEGIN INIT INFO +# Provides: redis-sentinel +# Required-Start: $local_fs $remote_fs $network +# Required-Stop: $local_fs $remote_fs $network +# Short-Description: start and stop Sentinel server +# Description: A persistent key-value database +### END INIT INFO + +# Source function library. +. /etc/rc.d/init.d/functions + +name="redis-sentinel" +exec="/usr/bin/$name" +shut="/usr/libexec/redis-shutdown" +pidfile="/var/run/redis/sentinel.pid" +SENTINEL_CONFIG="/etc/redis-sentinel.conf" + +[ -e /etc/sysconfig/redis-sentinel ] && . /etc/sysconfig/redis-sentinel + +lockfile=/var/lock/subsys/redis + +start() { + [ -f $SENTINEL_CONFIG ] || exit 6 + [ -x $exec ] || exit 5 + echo -n $"Starting $name: " + daemon --user ${REDIS_USER-redis} "$exec $SENTINEL_CONFIG --daemonize yes --pidfile $pidfile" + retval=$? + echo + [ $retval -eq 0 ] && touch $lockfile + return $retval +} + +stop() { + echo -n $"Stopping $name: " + [ -x $shut ] && $shut $name + retval=$? + if [ -f $pidfile ] + then + # shutdown haven't work, try old way + killproc -p $pidfile $name + retval=$? + else + success "$name shutdown" + fi + echo + [ $retval -eq 0 ] && rm -f $lockfile + return $retval +} + +restart() { + stop + start +} + +rh_status() { + status -p $pidfile $name +} + +rh_status_q() { + rh_status >/dev/null 2>&1 +} + + +case "$1" in + start) + rh_status_q && exit 0 + $1 + ;; + stop) + rh_status_q || exit 0 + $1 + ;; + restart) + $1 + ;; + status) + rh_status + ;; + condrestart|try-restart) + rh_status_q || exit 0 + restart + ;; + *) + echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart}" + exit 2 +esac +exit $? diff --git a/SOURCES/redis-sentinel.service b/SOURCES/redis-sentinel.service new file mode 100644 index 0000000..15463cf --- /dev/null +++ b/SOURCES/redis-sentinel.service @@ -0,0 +1,16 @@ +[Unit] +Description=Redis Sentinel +After=network.target + +[Service] +ExecStart=/usr/bin/redis-sentinel /etc/redis-sentinel.conf --supervised systemd +ExecStop=/usr/libexec/redis-shutdown redis-sentinel +Type=notify +User=redis +Group=redis +RuntimeDirectory=redis +RuntimeDirectoryMode=0755 + +[Install] +WantedBy=multi-user.target + diff --git a/SOURCES/redis-shutdown b/SOURCES/redis-shutdown new file mode 100644 index 0000000..53b9f09 --- /dev/null +++ b/SOURCES/redis-shutdown @@ -0,0 +1,40 @@ +#!/bin/bash +# +# Wrapper to close properly redis and sentinel +test x"$REDIS_DEBUG" != x && set -x + +REDIS_CLI=/usr/bin/redis-cli + +# Retrieve service name +SERVICE_NAME="$1" +if [ -z "$SERVICE_NAME" ]; then + SERVICE_NAME=redis +fi + +# Get the proper config file based on service name +CONFIG_FILE="/etc/$SERVICE_NAME.conf" + +# Use awk to retrieve host, port from config file +HOST=`awk '/^[[:blank:]]*bind/ { print $2 }' $CONFIG_FILE | tail -n1` +PORT=`awk '/^[[:blank:]]*port/ { print $2 }' $CONFIG_FILE | tail -n1` +PASS=`awk '/^[[:blank:]]*requirepass/ { print $2 }' $CONFIG_FILE | tail -n1` +SOCK=`awk '/^[[:blank:]]*unixsocket\s/ { print $2 }' $CONFIG_FILE | tail -n1` + +# Just in case, use default host, port +HOST=${HOST:-127.0.0.1} +if [ "$SERVICE_NAME" = redis ]; then + PORT=${PORT:-6379} +else + PORT=${PORT:-26739} +fi + +# Setup additional parameters +# e.g password-protected redis instances +[ -z "$PASS" ] || ADDITIONAL_PARAMS="-a $PASS" + +# shutdown the service properly +if [ -e "$SOCK" ] ; then + $REDIS_CLI -s $SOCK $ADDITIONAL_PARAMS shutdown +else + $REDIS_CLI -h $HOST -p $PORT $ADDITIONAL_PARAMS shutdown +fi diff --git a/SOURCES/redis.logrotate b/SOURCES/redis.logrotate new file mode 100644 index 0000000..3a3d185 --- /dev/null +++ b/SOURCES/redis.logrotate @@ -0,0 +1,9 @@ +/var/log/redis/*.log { + weekly + rotate 10 + copytruncate + delaycompress + compress + notifempty + missingok +} diff --git a/SOURCES/redis.service b/SOURCES/redis.service new file mode 100644 index 0000000..88e9edc --- /dev/null +++ b/SOURCES/redis.service @@ -0,0 +1,16 @@ +[Unit] +Description=Redis persistent key-value database +After=network.target + +[Service] +ExecStart=/usr/bin/redis-server /etc/redis.conf --supervised systemd +ExecStop=/usr/libexec/redis-shutdown +Type=notify +User=redis +Group=redis +RuntimeDirectory=redis +RuntimeDirectoryMode=0755 + +[Install] +WantedBy=multi-user.target +