自動下載安裝redis

     因爲開發的同事想在它本地的虛擬機玩一下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"


大體上就這麼多,具體腳本展現的美化部分,你們根據本身的審美看着來吧,到此一遊.......

相關文章
相關標籤/搜索