Created
April 6, 2012 05:57
-
-
Save sawanoboly/2317450 to your computer and use it in GitHub Desktop.
redis 2.4.x install
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
cat >/etc/logrotate.d/redis-server <<'EOFEOF' | |
/var/log/redis/*.log { | |
weekly | |
missingok | |
copytruncate | |
rotate 12 | |
compress | |
notifempty | |
} | |
EOFEOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
make test needs tcl8.5 package.
curl -# -f https://raw.github.com/gist/2317450/415359659ea1c3e3f322d1a6e6e6c68e0e19c18b/install_redis.sh | bash
curl -# -f https://raw.github.com/gist/2317450/2d4d254a35eb04f700d1ee5ec5881e29a263d3e0/redis.conf -o /etc/redis.conf
curl -# -f https://raw.github.com/gist/2317450/083d636c9405bf5bd6bca16c89ccd7d69c7f5bc2/etc_init.d_redis-server.sh | bash
[optional] logrotate
curl -# -f https://raw.github.com/gist/2317450/81056aca708f98438f398bf34eab03fa394e07f0/etc_logrotate.d_redis-server.sh | bash
service redis-server start
redis-cli INFO