Skip to content

Instantly share code, notes, and snippets.

@sawanoboly
Created April 6, 2012 05:57
Show Gist options
  • Save sawanoboly/2317450 to your computer and use it in GitHub Desktop.
Save sawanoboly/2317450 to your computer and use it in GitHub Desktop.
redis 2.4.x install
#!/bin/bash
cat >/etc/init.d/redis-server<<'EOFEOF'
#!/bin/sh
### BEGIN INIT INFO
# Provides: redis-server
# Required-Start: $syslog $remote_fs
# Required-Stop: $syslog $remote_fs
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: redis-server - Persistent key-value db
# Description: redis-server - Persistent key-value db
### END INIT INFO
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/local/bin/redis-server
DAEMON_ARGS=/etc/redis.conf
NAME=redis-server
DESC=redis-server
PIDFILE=/var/run/redis.pid
test -x $DAEMON || exit 0
set -e
case "$1" in
start)
echo -n "Starting $DESC: "
touch $PIDFILE
# chown redis:redis $PIDFILE
# if start-stop-daemon --start --quiet --umask 007 --pidfile $PIDFILE --chuid redis:redis --exec $DAEMON -- $DAEMON_ARGS
if start-stop-daemon --start --quiet --umask 007 --pidfile $PIDFILE --exec $DAEMON -- $DAEMON_ARGS
then
echo "$NAME."
else
echo "failed"
fi
;;
stop)
echo -n "Stopping $DESC: "
if start-stop-daemon --stop --retry 10 --quiet --oknodo --pidfile $PIDFILE --exec $DAEMON
then
echo "$NAME."
else
echo "failed"
fi
rm -f $PIDFILE
;;
restart|force-reload)
${0} stop
${0} start
;;
status)
echo -n "$DESC is "
if start-stop-daemon --stop --quiet --signal 0 --name ${NAME} --pidfile ${PIDFILE}
then
echo "running"
else
echo "not running"
exit 1
fi
;;
*)
echo "Usage: /etc/init.d/$NAME {start|stop|restart|force-reload}" >&2
exit 1
;;
esac
exit 0
EOFEOF
chmod +x /etc/init.d/redis-server
update-rc.d redis-server defaults
#!/bin/bash
cat >/etc/logrotate.d/redis-server <<'EOFEOF'
/var/log/redis/*.log {
weekly
missingok
copytruncate
rotate 12
compress
notifempty
}
EOFEOF
#!/bin/bash
TMP_SRCDIR=/usr/local/src/redis24/
TMP_REDIS=redis-2.4.10
mkdir -p $TMP_SRCDIR
cd $TMP_SRCDIR
wget http://redis.googlecode.com/files/$TMP_REDIS.tar.gz
tar xzf $TMP_REDIS.tar.gz
cd $TMP_REDIS
make
make test
make install
mkdir -p /var/log/redis
mkdir -p /var/lib/redis
cp redis.conf /etc/
check process redis-server with pidfile /var/run/redis.pid
start program = "/usr/sbin/service redis-server start"
stop program = "/usr/sbin/service redis-server stop"
if failed host localhost port 6379 type tcp
then restart
if 2 restarts within 3 cycles then timeout
daemonize yes
pidfile /var/run/redis.pid
port 6379
bind 127.0.0.1
timeout 0
loglevel verbose
logfile /var/log/redis/redis-server.log
databases 16
save 900 1
save 300 10
save 60 10000
rdbcompression yes
dbfilename dump.rdb
dir /var/lib/redis
slave-serve-stale-data yes
appendonly no
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
slowlog-log-slower-than 10000
slowlog-max-len 1024
vm-enabled no
vm-swap-file /var/lib/redis/redis.swap
vm-max-memory 0
vm-page-size 32
vm-pages 134217728
vm-max-threads 4
hash-max-zipmap-entries 512
hash-max-zipmap-value 64
list-max-ziplist-entries 512
list-max-ziplist-value 64
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
activerehashing yes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment