偷懒到一定境界了,又吃多了写一个redis自动安装shell脚本。再说自己确实非常的懒,多次搞得事情都脚本来实现吧,手工安装太麻烦了。当然,也可以自己yum安装(yum安装的版本过低,一般就rpm安装了)。
平台:centos 6.x 64
redis版本:redis 2.8or 3.0
参数优化:未优化,需自己根据生产环境进行优化。
#!/bin/bash
#function: Install redis for centos 6.x_64bit
#author:21yunwei
downloaddir=/usr/local/src
function menu(){
echo "###############################################################"
cat < <EOF
Please choose redis version which you want to install:
1,Redis 2.8.24-5.el6.art.x86_64
2,Redis 3.0.7-4.el6.art.x86_64
EOF
echo "###############################################################"
}
function checkroot(){
if [ $UID -ne 0 ]
then
echo "Please login as root"
exit;
fi
}
function msgbox(){
if [ $? -eq 0 ] ;then
echo "This step sucess"
else
echo "This step failed,please check"
exit;
fi
}
function check_env(){
echo -e "checking epel\n"
rpm -qa | grep epel
if [ $? -eq 0 ]; then
echo -e "epel has been installed\nInstall required libs:"
yum install jemalloc -y >/dev/null
else
echo "epel does not install,now install epel"
yum install epel-release -y > /dev/null
echo "Install required libs:"
yum install jemalloc -y >/dev/null
fi
}
function redis_version(){
read -p "please choose redis version that you want to install:" flag
}
function redis_install(){
case $flag in
1)
version="redis-2.8.24-5.el6.art.x86_64"
echo "Redis 2.8.X will be install" && wget -O ${downloaddir}/${version}.rpm http://www6.atomicorp.com/channels/atomic/centos/6/x86_64/RPMS/${version}.rpm
rpm -ih ${downloaddir}/${version}.rpm
;;
2)
version="redis-3.0.7-4.el6.art.x86_64"
echo "Redis 3.0.X will be install" && wget -O ${downloaddir}/${version}.rpm http://www6.atomicorp.com/channels/atomic/centos/6/x86_64/RPMS/${version}.rpm
rpm -ih ${downloaddir}/${version}.rpm
;;
*)
echo "Please input 1 or 2,other novalid"
redis_version
redis_install
esac
}
function check_install_status(){
/etc/init.d/redis start
netstat -tunlp | grep 6379
if [ $? -eq 0 ]; then
echo "Redis install sucess"
chkconfig redis on
else
echo "Redis install failed,please check"
exit;
fi
}
function main(){
checkroot
check_env
menu
redis_version
redis_install
check_install_status
}
main
转载请注明:西数超哥博客www.ysidc.top» [原创]redis 自动安装shell脚本
https://www.ysidc.top 西数超哥博客,数据库,西数超哥,虚拟主机,域名注册,域名,云服务器,云主机,云建站,ysidc.top









