shell脚本一键安装redis
支持识别离线包和联网安装,自动修改使用后台运行模式,离线安装的方法是,将离线包和脚本放在同一个文件夹, 它会先识别有没有离线包, 有离线包就先安装离线包, 没有离线包就安装进行判断机器是否能联网, 能联网的情况下自动请求源安装,一切自动化。下面演示一下
#!/bin/bash
#------------------------------------------------------------------------------------------------------------------#
#| Some people die at the age of 25 and don't bury themselves in the earth until they are 75 |#
#------------------------------------------------------------------------------------------------------------------#
#| $$$$ $$ $$ $$$$$$ $$ $$ $$$$$$ $$ $$$$$$ $$$$$$ |#
#| $$ $$ $$ $$ $$ $$ $$ $$ $$ $$ $$ |#
#| $$ $$$$$$$ $$$$$ $$ $$ $ $$ $$$$$$ $$ $$$$$ $$$$$ |#
#| $$ $$ $$ $$ $$ $ $ $$ $$ $$ $$ $$ |#
#| $$$$ $$ $$ $$$$$$ $$ $$ $$$$$ $$ $$$$$$ $$$$$$ $$$$$$ |#
#------------------------------------------------------------------------------------------------------------------#
onversion="4.0.3"
offversion=`basename redis-*.tar.gz .tar.gz | awk -F '-' '{print$2}'`
installdir=$(cd `dirname $0`; pwd) function initize(){
installdir=$(cd `dirname $0`; pwd)
} function checkroot(){
if [ $UID -ne 0 ]
then
echo "|----------------------------------------------------------------------------------------------------------------|"
echo "|------------------------------------------[权限不足...请切换至root用户]-----------------------------------------|"
echo "|----------------------------------------------------------------------------------------------------------------|"
exit;
fi
} function judge(){
echo
offfile=`ls | grep redis-*.tar.gz`
if [[ "$offfile" != "" ]]
then
echo "|----------------------------------------------------------------------------------------------------------------|"
echo "|-------------------------------------------------[发现离线包]---------------------------------------------------|"
echo "|----------------------------------------------------------------------------------------------------------------|"
/usr/bin/sleep 3
offinstall
else
echo "|----------------------------------------------------------------------------------------------------------------|"
echo "|-------------------------------------------------[未发现离线包]-------------------------------------------------|"
echo "|--------------------------------------------[开始判断是否连接外网安装]------------------------------------------|"
/usr/bin/sleep 3
network
fi
} function offinstall(){
echo "|----------------------------------------------------------------------------------------------------------------|"
echo "|------------------------------------------------[离线包安装中]--------------------------------------------------|"
echo "|----------------------------------------------------------------------------------------------------------------|"
tar -zxvf redis-${offversion}.tar.gz >/dev/null 2>&1
redis="redis-${offversion}"
cd ${redis}/src && make >/dev/null 2>&1
if [[ $? -ne 0 ]]; then
echo "编译出错"
else
echo "|----------------------------------------------------------------------------------------------------------------|"
echo "|---------------------------------------------------[编译完成]---------------------------------------------------|"
echo "|----------------------------------------------------------------------------------------------------------------|"
/usr/bin/sleep 3
intend
fi
} function network(){
httpcode=`curl -I -m 10 -o /dev/null -s -w %{http_code}'\n' http://www.baidu.com`
net1=$(echo $httpcode | grep "200")
if [[ "$net1" != "" ]]
then
echo "|----------------------------------------------------------------------------------------------------------------|"
echo "|-----------------------------------------------------[联网]-----------------------------------------------------|"
echo "|-------------------------------------------------[准备联网安装]-------------------------------------------------|"
echo "|----------------------------------------------------------------------------------------------------------------|"
/usr/bin/sleep 3
online
else
echo "|----------------------------------------------------------------------------------------------------------------|"
echo "|-------------------------------------------[未联网,无离线安装包,准备退出]---------------------------------------|"
echo "|----------------------------------------------------------------------------------------------------------------|"
/usr/bin/sleep 3
exit;
fi
}
function online(){
wget_v=`which wget`
wget_vv=$(echo $wget_v | grep wget)
if [[ "$wget_vv" != "" ]]
then
echo "|----------------------------------------------------------------------------------------------------------------|"
echo "|--------------------------------------`wget -V |head -n 1`---------------------------------------|"
echo "|----------------------------------------------------------------------------------------------------------------|"
wget http://download.redis.io/releases/redis-${onversion}.tar.gz
installon
else
echo "|----------------------------------------------------------------------------------------------------------------|"
echo "|----------------------------------------[检测到wget没有安装, 准备安装wget]---------------------------------------|"
echo "|----------------------------------------------------------------------------------------------------------------|"
yum install wget -y
echo "|----------------------------------------------------------------------------------------------------------------|"
echo "|--------------------------------------`wget -V |head -n 1`---------------------------------------|"
echo "|----------------------------------------------------------------------------------------------------------------|"
wget http://download.redis.io/releases/redis-${onversion}.tar.gz
installon
fi
} function installon(){
echo "|----------------------------------------------------------------------------------------------------------------|"
echo "|------------------------------------------------[在线包安装中]--------------------------------------------------|"
echo "|----------------------------------------------------------------------------------------------------------------|"
tar -zxvf redis-${onversion}.tar.gz >/dev/null 2>&1
redis="redis-${onversion}"
cd ${redis}/src && make >/dev/null 2>&1
if [[ $? -ne 0 ]]; then
echo "编译出错"
else
echo "|----------------------------------------------------------------------------------------------------------------|"
echo "|--------------------------------------------------[编译完成]----------------------------------------------------|"
echo "|----------------------------------------------------------------------------------------------------------------|"
/usr/bin/sleep 3
intend
fi
} function intend(){
echo "|----------------------------------------------------------------------------------------------------------------|"
echo "|-------------------------------------------------[开始迁移文件]-------------------------------------------------|"
echo "|----------------------------------------------------------------------------------------------------------------|"
mkdir -p ${installdir}/redis/{logs,nodes,conf,bin}
cp redis-cli redis-server ${installdir}/redis/bin
cp redis-trib.rb ${installdir}/redis
cp ../redis.conf ${installdir}/redis/conf
echo "|----------------------------------------------------------------------------------------------------------------|"
echo "|-------------------------------------------------[数据迁移完成]-------------------------------------------------|"
echo "|----------------------------------------------------------------------------------------------------------------|"
/usr/bin/sleep 2
echo "|----------------------------------------------------------------------------------------------------------------|"
echo "|-------------------------------------------------[清理多余文件]-------------------------------------------------|"
echo "|----------------------------------------------------------------------------------------------------------------|"
finish
/usr/bin/sleep 2
echo "|----------------------------------------------------------------------------------------------------------------|"
echo "|-------------------------------------------------[配置快捷启动]-------------------------------------------------|"
echo "|----------------------------------------------------------------------------------------------------------------|"
service
/usr/bin/sleep 2
echo "|----------------------------------------------------------------------------------------------------------------|"
echo "|-------------------------------------------------[修改配置文件]-------------------------------------------------|"
echo "|----------------------------------------------------------------------------------------------------------------|"
configfile
/usr/bin/sleep 2
echo "|****************************************************************************************************************|"
echo "| WW WW EEEEEEE LL CCCCC OOOOOO MM MM EEEEEEE |"
echo "| WW WWWW WW EE LL CC OO OO MMMM MMMM EE |"
echo "| WW WW WW WW EEEEE LL CC OO OO MM MM MM MM EEEEE |"
echo "| WW W W WW EE LL CC OO OO MM M M MM EE |"
echo "| WW WW EEEEEEE LLLLLL CCCCC OOOOOO MM MMM MM EEEEEEE |"
echo "|****************************************************************************************************************|"
}
function finish(){
echo
rm -rf ${installdir}/redis-*
}
function service(){
cd ${installdir}/redis && echo "./bin/redis-server conf/redis.conf" > start.sh
chmod +x start.sh
}
function configfile(){
cd ${installdir}/redis/conf
#后台
sed -i 's/daemonize no/daemonize yes/' redis.conf
#端口
sed -i 's/port 6379/port 7000/' redis.conf
#日志输出文件
sed -i 's/logfile ""/logfile "\/usr\/local\/src\/redis\/logs\/redis.logs"/' redis.conf
}
function main(){
checkroot
judge
}
main
离线安装的效果
在线安装的效果
shell脚本一键安装redis的更多相关文章
- shell脚本一键安装redis集群[最终版]
直接上shell了. #!/bin/bash #---------------------------------------------------------------------------- ...
- shell脚本一键安装redis集群
简介: 明天再写,上脚本 #!/bin/bash #-------------------------------------------------------------------------- ...
- Centos 6.4上面用Shell脚本一键安装vsftpd
Centos 6.4上面用Shell脚本一键安装vsftpd install.sh #!/bin/bash if [ `uname -m` == "x86_64" ];then m ...
- Centos 6.4上面用Shell脚本一键安装mysql 5.6.15
Centos 6.4上面用Shell脚本一键安装mysql 5.6.15 #!/bin/bash if [ `uname -m` == "x86_64" ];then machi ...
- 安装完Ubuntu后通过shell脚本一键安装软件
安装完Ubuntu后通过shell脚本一键安装软件 以下代码中#是单行注释 :<<! ! 是多行注释. 运行的时候需要把多行注释去掉. 比如把以下代码保存为install.sh, 那么在终 ...
- shell脚本一键安装mysql5.7.x
使用脚本一键安装mysql5.7.x,初始化数据库.启动数据库---- mysql版本号:源代码mysql5.7.10 linux版本号:centos6.5 x86_64 #!/bin/bash GR ...
- shell脚本一键安装mysql5.7.x(免安装版)
使用脚本一键安装mysql5.7.x,初始化数据库,启动数据库---- mysql版本:源码mysql5.7.10 linux版本:centos6.5 x86_64 #!/bin/bash GROUP ...
- Shell脚本一键安装LNMP环境
https://sourceforge.net/projects/opensourcefile/files/ Nginx是一款高性能的HTTP和反向代理服务器.Nginx在反向代理,Rewrite规则 ...
- shell脚本一键安装jdk
直接上shell #!/bin/bash #offline jdk install ipath="/usr/local" installpath=$(cd `dirname $0` ...
随机推荐
- Express web框架 upload file
哈哈,敢开源,还是要有两把刷子的啊 今天,看看node.js 的web框架 Express的实际应用 //demo1 upload file <html><head><t ...
- ROSETTA使用技巧随笔--蛋白蛋白对接
先写简略版,以后再详细写. 1. 对输入结构进行预处理(refine) $> relax.default.linuxgccrelease -in:file:s input_files/from_ ...
- (已解决)#warning:尚未配置[微信]URL Scheme:wx4868b35061f87884, 无法使用进行授权。
#warning:尚未配置[微信]URL Scheme:wx4868b35061f87884, 无法使用进行授权. (说白了就是注册白名单) ” -canOpenURL: failed for URL ...
- Sublime text3 经常出现 “ There are no packages avaliable for installation” 解决方法
对应这个问题,一开始在度娘上找到很多答案,包括将json文件放在本地然后通过 package setting 更改的,发现其实不好使,原因未知. 后来测试了在hosts文件添加sublime text ...
- 关于plsqldev无法正常加载oracle instantclient中的oci.dll的其中一个原因
事情的经过是这样的: 1. 新安装了windows10 系统,装了plsqldev 和 oracle instantclient,以及 instantclient sqlplus. 2.设置好了ORA ...
- Unity3d之如何截屏
Unity3d中有时有截屏的需求,那如何截屏呢,代码如下: /// <summary> /// 截屏 /// </summary> /// <param name=&qu ...
- VS2013打包程序步骤
VS自带的打包程序默认是没有安装的,如果有打包的需要,需要自己去下载一个安装程序 1.右击解决方案,选择添加项目,在打开的对话框中找到[已安装]-[模板]-[其他项目]-[安装和部署],如图示.第一 ...
- PCH 文件 和 ProjectName-Bridging-Header 配置
1.简介 PCH文件是Xcode编程中全局引用共享的文件.可以在这里引入头文件或者宏定义来方便程序中多个文件访问. 2.PCH文件创建 打开工程 New File… -> iOS Other - ...
- QWidget 的 close 与 Qt::WA_DeleteOnClose
[1]close 与 Qt::WA_DeleteOnClose简介 1.1 Qt源码 /*! Closes this widget. Returns \c true if the widget was ...
- plsql注册-转
注册码:Product Code:4t46t6vydkvsxekkvf3fjnpzy5wbuhphqzserial Number:601769 password:xs374ca https://blo ...