Last active
December 16, 2015 22:20
-
-
Save jasonayre/5506542 to your computer and use it in GitHub Desktop.
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 | |
redis_version=2.6.11 | |
# from here: http://www.codingsteps.com/install-redis-2-6-on-amazon-ec2-linux-ami-or-centos/ | |
# and here: https://raw.github.com/gist/257849/9f1e627e0b7dbe68882fa2b7bdb1b2b263522004/redis-server | |
############################################### | |
# To use: | |
# wget https://gist.github.com/jasonayre/5506542/raw/bafca63f0ee08d19ad6f4c6ba131262e086a218c/install-redis.sh | |
# chmod +x install-redis.sh | |
# ./install-redis.sh | |
############################################### | |
echo "*****************************************" | |
echo " 1. Prerequisites: Install updates, set time zones, install GCC and make" | |
echo "*****************************************" | |
sudo yum -y update | |
sudo ln -sf /usr/share/zoneinfo/America/Denver /etc/localtime | |
sudo yum -y install gcc make tcl | |
echo "*****************************************" | |
echo " 2. Download, Untar, Make Redis 2.6 and test" | |
echo "*****************************************" | |
cd /usr/local/src | |
sudo wget http://redis.googlecode.com/files/redis-${redis_version}.tar.gz | |
sudo tar xzf redis-${redis_version}.tar.gz | |
sudo rm redis-${redis_version}.tar.gz -f | |
cd redis-${redis_version} | |
sudo make | |
sudo make test | |
if [ $? -ne 0 ]; then | |
echo "Error running tests, aborting. Please run \`make test\` manually" | |
echo "to further debug." | |
exit 1 | |
fi | |
echo "*****************************************" | |
echo " 3. Create Directories and Copy Redis Files" | |
echo "*****************************************" | |
sudo mkdir /etc/redis /var/lib/redis | |
sudo cp src/redis-server src/redis-cli src/redis-benchmark /usr/local/bin | |
echo "*****************************************" | |
echo " 4. Configure redis.conf" | |
echo "*****************************************" | |
echo " Edit redis.conf as follows:" | |
echo " 1: ... daemonize yes" | |
echo " 2: ... dir /var/lib/redis" | |
echo " 3: ... loglevel notice" | |
echo " 4: ... logfile /var/log/redis.log" | |
echo " 5: ... timeout 300" | |
echo " 6: ... tcp-keepalive 60" | |
echo "*****************************************" | |
sudo cp redis.conf /etc/redis/redis.conf | |
sudo sed -i -e "s/^daemonize no$/daemonize yes/" -e "s/^dir \.\//dir \/var\/lib\/redis\//" -e "s/^loglevel verbose$/loglevel notice/" -e "s/^logfile stdout$/logfile \/var\/log\/redis.log/" -e "s/^timeout 0$/timeout 300/" -e "s/^tcp-keepalive 0$/tcp-keepalive 60/" /etc/redis/redis.conf | |
echo "*****************************************" | |
echo " 5. Download init Script" | |
echo "*****************************************" | |
sudo wget https://raw.github.com/gist/2777433/e64b4b8ad7d38676f7e7f70b24f3f004b4f10b74/redis-server | |
echo "*****************************************" | |
echo " 6. Move and Configure Redis-Server" | |
echo "*****************************************" | |
sudo mv redis-server /etc/init.d | |
sudo chmod +x /etc/init.d/redis-server | |
echo "*****************************************" | |
echo " 7. Auto-Enable Redis-Server" | |
echo "*****************************************" | |
sudo chkconfig --add redis-server | |
sudo chkconfig --level 345 redis-server on | |
echo "*****************************************" | |
echo " 8. Start Redis Server" | |
echo "*****************************************" | |
sudo service redis-server start | |
echo "*****************************************" | |
echo " Complete!" | |
echo " You can test your redis installation using the redis console:" | |
echo " $ src/redis-cli" | |
echo " redis> set foo bar" | |
echo " OK" | |
echo " redis> get foo" | |
echo " bar" | |
echo "*****************************************" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment