#!/bin/sh
CURRENT_DIR=$(pwd)
make_default_config() {
echo "daemonize no" >> $REDIS_DIR/redis.conf
echo "pidfile /var/run/redis.pid" >> $REDIS_DIR/redis.conf
echo "tcp-backlog 511" >> $REDIS_DIR/redis.conf
echo "port 6379" >> $REDIS_DIR/redis.conf
echo "timeout 0" >> $REDIS_DIR/redis.conf
echo "tcp-keepalive 0" >> $REDIS_DIR/redis.conf
echo "loglevel notice" >> $REDIS_DIR/redis.conf
if [[ -z "$AG_HOME" ]]; then
echo "logfile \"$HOME/ag/logs/redis.log\"" >> $REDIS_DIR/redis.conf
else
echo "logfile \"$AG_HOME/logs/redis.log\"" >> $REDIS_DIR/redis.conf
fi
echo "databases 16" >> $REDIS_DIR/redis.conf
echo "save 900 1" >> $REDIS_DIR/redis.conf
echo "save 300 10" >> $REDIS_DIR/redis.conf
echo "save 60 10000" >> $REDIS_DIR/redis.conf
echo "stop-writes-on-bgsave-error yes" >> $REDIS_DIR/redis.conf
echo "rdbcompression yes" >> $REDIS_DIR/redis.conf
echo "rdbchecksum yes" >> $REDIS_DIR/redis.conf
echo "dbfilename \"dump.rdb\"" >> $REDIS_DIR/redis.conf
if [[ -z "$REDIS_HOME" ]]; then
echo "dir \"$HOME/ag/redis\"" >> $REDIS_DIR/redis.conf
else
echo "dir \"$REDIS_HOME\"" >> $REDIS_DIR/redis.conf
fi
echo "slave-serve-stale-data yes" >> $REDIS_DIR/redis.conf
echo "slave-read-only yes" >> $REDIS_DIR/redis.conf
echo "repl-disable-tcp-nodelay no" >> $REDIS_DIR/redis.conf
echo "slave-priority 100" >> $REDIS_DIR/redis.conf
echo "appendonly yes" >> $REDIS_DIR/redis.conf
echo "appendfilename \"appendonly.aof\"" >> $REDIS_DIR/redis.conf
echo "appendfsync everysec" >> $REDIS_DIR/redis.conf
echo "no-appendfsync-on-rewrite no" >> $REDIS_DIR/redis.conf
echo "auto-aof-rewrite-percentage 100" >> $REDIS_DIR/redis.conf
echo "auto-aof-rewrite-min-size 64mb" >> $REDIS_DIR/redis.conf
echo "lua-time-limit 5000" >> $REDIS_DIR/redis.conf
echo "slowlog-max-len 128" >> $REDIS_DIR/redis.conf
echo "notify-keyspace-events \"\"" >> $REDIS_DIR/redis.conf
echo "hash-max-ziplist-entries 512" >> $REDIS_DIR/redis.conf
echo "hash-max-ziplist-value 64" >> $REDIS_DIR/redis.conf
echo "list-max-ziplist-entries 512" >> $REDIS_DIR/redis.conf
echo "list-max-ziplist-value 64" >> $REDIS_DIR/redis.conf
echo "set-max-intset-entries 512" >> $REDIS_DIR/redis.conf
echo "zset-max-ziplist-entries 128" >> $REDIS_DIR/redis.conf
echo "zset-max-ziplist-value 64" >> $REDIS_DIR/redis.conf
echo "hll-sparse-max-bytes 3000" >> $REDIS_DIR/redis.conf
echo "activerehashing yes" >> $REDIS_DIR/redis.conf
echo "client-output-buffer-limit normal 0 0 0" >> $REDIS_DIR/redis.conf
echo "client-output-buffer-limit slave 256mb 64mb 60" >> $REDIS_DIR/redis.conf
echo "client-output-buffer-limit pubsub 32mb 8mb 60" >> $REDIS_DIR/redis.conf
echo "hz 10" >> $REDIS_DIR/redis.conf
echo "aof-rewrite-incremental-fsync yes" >> $REDIS_DIR/redis.conf
echo "maxclients 8160" >> $REDIS_DIR/redis.conf
}
DOWN_BASE_URL="http://download.redis.io/releases/"
BASE_PREFIX="redis-"
BASE_SUFFIX=".tar.gz"
# Check Input Parameters
while getopts "l:v:" o;
do
case "${o}" in
l)
LOCATE=${OPTARG}
;;
v)
VERSION=${OPTARG}
;;
*)
echo "Invalid Parameter."
exit 1
;;
\?)
echo "Invalid Parameter."
exit 1
;;
esac
done
echo "Step 1 : Check redis server source package....."
sleep 1
if [[ -z "$LOCATE" ]]; then
LOCATE="local"
fi
if [[ -z "$VERSION" ]]; then
VERSION="2.8.12"
fi
if [[ "$LOCATE" == "remote" ]]; then
wget $DOWN_BASE_URL$BASE_PREFIX$VERSION$BASE_SUFFIX
else
cd $CURRENT_DIR
if [ -f "$BASE_PREFIX$VERSION$BASE_SUFFIX" ]; then
echo " $BASE_PREFIX$VERSION$BASE_SUFFIX exists in current directory."
else
echo " $BASE_PREFIX$VERSION$BASE_SUFFIX does not exist in current directory."
exit 1
fi
fi
echo " done"
sleep 1
echo "Step 2 : Unpackage the redis server source...."
sleep 1
if [ -d "$BASE_PREFIX$VERSION" ]; then
rm -rf $BASE_PREFIX$VERSION
fi
if [ -f "$BASE_PREFIX$VERSION$BASE_SUFFIX" ]; then
tar -zxvf $BASE_PREFIX$VERSION$BASE_SUFFIX
wait $!
else
echo " Error. $BASE_PREFIX$VERSION$BASE_SUFFIX does not exist."
exit 1
fi
echo " done"
sleep 1
REDIS_DIR=$CURRENT_DIR/$BASE_PREFIX$VERSION
echo "Step 3 : Default redis configuration file create...."
sleep 1
mv $REDIS_DIR/redis.conf $REDIS_DIR/redis.conf.bak
touch $REDIS_DIR/redis.conf
make_default_config
echo " done"
sleep 1
echo "Step 4 : Repackage the redis server source...."
sleep 1
cd $CURRENT_DIR
mv $BASE_PREFIX$VERSION redis
tar -zcvf redis.tar.gz redis
wait $!
rm -rf redis
echo " done"
댓글을 달아 주세요
댓글 RSS 주소 : http://www.yongbi.net/rss/comment/600