因为开发的同事想在它本地的虚拟机玩一下redis缓存,立即给他写了一个脚本,如今贴在这里,有须要的朋友能够看看:(此脚本大体包含了建立用户以及密码,下载编译安装redis,修改配置文件,启动redis服务,仍是比较简单的)redis
############################ install_redis.sh ###############################缓存
#!/bin/bashbash
# define the function of create passwordide
create_passwd(){spa
a=(a b c d e f A B C D E F @ $ % 0 1 2 3 4 5 6 7 8 9)server
for ((i=0;i<10;i++));do开发
echo -n ${a[$RANDOM % ${#a[@]}]}get
done虚拟机
echoit
}
# create redis user and give it password
useradd redis
password=`create_passwd`
echo $password >> /home/redis/redis_password.txt
echo $password | passwd --stdin redis
# after download redis,compile and install redis
yum -y install wget
cd /root/src/ || mkdir -p /root/src && cd /root/src/
wget http://download.redis.io/releases/redis-3.2.3.tar.gz
tar xf redis-3.2.3.tar.gz
cd /root/src/redis-3.2.3
make
make PREFIX=/usr/local/redis install
cp /root/src/redis-3.2.3/redis.conf /usr/local/redis/
sed -i 's/daemonize no/daemonize yes/g' /usr/local/redis/redis.conf
# change the authority of redis-installed dir and startup redis service
chown -R redis:redis /usr/local/redis/
su - redis
cd /usr/local/redis/bin/
./redis-server ../redis.conf
echo "welcome to use redis service"
大体上就这么多,具体脚本展现的美化部分,你们根据本身的审美看着来吧,到此一游.......