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 |
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.setup.conf