install_redis.sh
#!/bin/bash
#config
install_dir="/$USER/software"
redis_source="http://download.redis.io/releases/redis-3.0.6.tar.gz"
redis_gz_file="redis-3.0.6.tar.gz"
redis_file="redis-3.0.6"
redis_log="/var/log/redis_install.log"
rm -rf "$redis_log"
if [ ! -d "$install_dir" ] ; then
mkdir "$install_dir"
else
echo "$install_dir it is exist" >> "$redis_log"
fi
cd $install_dir
result=$(rpm -qa | grep tcl)
if [ `echo $result|wc -L` -gt 0 ] ; then
echo "tcl is installed" >> "$redis_log"
else
yum install -y tcl
fi
wget "$redis_source"
tar xvzf $redis_gz_file
cd $redis_file
make
cd src
make test
cp ../utils/redis_init_script /etc/init.d/redis
cp redis-server /usr/local/bin
mkdir /etc/redis
mkdir /var/redis
mkdir /var/redis/log
mkdir /var/redis/run
cp $install_dir/$redis_file/redis.conf /etc/redis/6379.conf
sed -i 's/daemonize no/daemonize yes/' /etc/redis/6379.conf
sed -i 's/pidfile \/var\/run\/redis.pid/pidfile \/var\/run\/redis_6379\.pid/' /etc/redis/6379.conf
sed -i 's/logfile ""/logfile "\/var\/redis\/log\/redis_6379\.log"/' /etc/redis/6379.conf
service redis start
#test step
#1:cp /root/software/redis-3.0.6/src/redis-cli /usr/local/bin/redis-cli test
#2:redis-cli
#3:set name test
#4:get name
#eg:
## cp /root/software/redis-3.0.6/src/redis-cli /usr/local/bin/redis-cli
## redis-cli
# 127.0.0.1:6379> set name test
# OK
# 127.0.0.1:6379> get name
# "test"