Created
June 10, 2014 17:57
-
-
Save tegansnyder/59fd3fc44d1a8448945d to your computer and use it in GitHub Desktop.
Redis setup script for multiple instances on different ports
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 | |
# make sure this script is executable | |
# place in /var/redis/ | |
# run by issuing: ./redis-setup.sh PORT_NUMBER | |
if [ "$(id -u)" != "0" ]; then | |
echo "This script must be run as root" 1>&2 | |
exit 1 | |
fi | |
if [ $# -gt 0 ]; then | |
REDISPORT=$1 | |
cat redis.init.conf | sed -e "s/\${REDISPORT}/$REDISPORT/" > /etc/init.d/redis_$REDISPORT | |
chmod 755 /etc/init.d/redis_$REDISPORT | |
echo "Redis startup script created at: /etc/init.d/redis_$REDISPORT" | |
cat redis.setup.conf | sed -e "s/\${REDISPORT}/$REDISPORT/" > /etc/redis/$REDISPORT.conf | |
echo "Redis config created at: /etc/redis/$REDISPORT.conf" | |
mkdir /var/redis/$REDISPORT | |
chmod 775 /var/redis/$REDISPORT | |
echo "Redis data at: /var/redis/$REDISPORT" | |
/etc/init.d/redis_$REDISPORT start | |
echo | |
echo "Ping your host to make sure it works by issuing:" | |
echo "redis-cli -p $REDISPORT" | |
else | |
echo 'No port number given' | |
fi |
redis.setup.conf
daemonize yes
pidfile /var/run/redis_${REDISPORT}.pid
port ${REDISPORT}
timeout 0
tcp-keepalive 0
loglevel notice
logfile /var/log/redis_${REDISPORT}.log
databases 16
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
dir /var/redis/${REDISPORT}
slave-serve-stale-data yes
slave-read-only yes
repl-disable-tcp-nodelay no
slave-priority 100
maxmemory 3gb
appendonly no
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
hash-max-ziplist-entries 512
hash-max-ziplist-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
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
aof-rewrite-incremental-fsync yes
Instructions to install Redis:
wget http://download.redis.io/redis-stable.tar.gz
tar xvzf redis-stable.tar.gz
cd redis-stable
make
make install
Then run the above setup script to create multiple instances of Redis running on separate ports.
sudo sh setup.sh PORT_NUMBER
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
redis.init.conf