Shell脚本-自动化部署反向代理、WEB、nfs
部署nginx反向代理三个web服务,调度算法使用加权轮询(由于物理原因只开启两台服务器)
AutoNginxNfsService.sh
#/bin/bash
systemctl status nginx
if(($?==))
then
yum install -y nginx
if(($?==))
then
#echo 'Yes!'
systemctl start nginx
if(($?==))
then
echo "Congratulations!! Nginx start OK!!"
else
echo "Sorry is Fail!!!"
fi
else
echo"sorry install is Fail!!!" fi
elif(($?==))
then
systemctl start nginx
if(($?==))
then
echo "Congratulations!! Nginx start OK!!!"
else
echo "sorry!!"
fi
elif(($?==))
then
echo "OKOKOK!!!"
else
echo "I am so sorry"
fi
echo "config writing...."
grep 'upstream' /etc/nginx/nginx.conf
if(($?!=))
then
sed -ri '/^http/a upstream Yanlong {' /etc/nginx/nginx.conf
sed -ri '/^upst/a server yanlongweb1 weight=3\;' /etc/nginx/nginx.conf
sed -ri '/^server yanlongweb1/a server yanlongweb2\;' /etc/nginx/nginx.conf
sed -ri '/^server yanlongweb2/a \}' /etc/nginx/nginx.conf
sed -ri '/^(\ +)(location)(\ )(\/)/a proxy_pass http:\/\/Yanlong\;' /etc/nginx/nginx.conf
fi
echo "config write is OK!"
systemctl reload nginx
if(($?==))
then
echo "HTTP load balancer is OK!"
else
echo "Sorry!!"
fi
systemctl status nfs
if(($?==))
then
yum install rpcbind nfs-utils -y
if(($?==))
then
#echo 'Yes!'
systemctl start nfs
if(($?==))
then
echo "Congratulations!! nfs start OK!!"
else
echo "Sorry is Fail!!!"
fi
else
echo"sorry install is Fail!!!" fi
elif(($?==))
then
systemctl start nfs
if(($?==))
then
echo "Congratulations!! nfs start OK!!!"
else
echo "sorry!!"
fi
elif(($?==))
then
echo "OKOKOK!!!"
else
echo "I am so sorry"
fi
echo "config writing...."
echo "/webindex 192.168.16.0/24(rw,sync,fsid=0)" > /etc/exports
echo "config write is OK!"
systemctl reload nfs
if(($?==))
then
echo "NFS service is OK!"
else
echo "Sorry!!"
fi
所有web服务使用共享存储nfs,保证所有web都对其有读写权限,保证数据一致性
#/bin/bash
systemctl status nginx
if(($?==))
then
yum install -y nginx
if(($?==))
then
#echo 'Yes!'
systemctl start nginx
if(($?==))
then
echo "Congratulations!! Nginx start OK!!"
else
echo "Sorry is Fail!!!"
fi
else
echo"sorry install is Fail!!!" fi
elif(($?==))
then
systemctl start nginx
if(($?==))
then
echo "Congratulations!! Nginx start OK!!!"
else
echo "sorry!!"
fi
elif(($?==))
then
echo "OKOKOK!!!"
else
echo "I am so sorry"
fi
echo "config writing...."
sed -ri '/^(\ +)(location)(\ )(\/)/a root\ \/nginxwebservice\;' /etc/nginx/nginx.conf
sed -ri '/^root\ \/nginxwebservice/a index\ web.html\;' /etc/nginx/nginx.conf
echo "config write is OK!"
systemctl reload nginx
if(($?==))
then
echo "HTTP load balancer YanlongWEBservice is OK!"
else
echo "Sorry!!"
fi
systemctl status nfs
if(($?==))
then
yum install rpcbind nfs-utils -y
if(($?==))
then
#echo 'Yes!'
systemctl start nfs
if(($?==))
then
echo "Congratulations!! nfs start OK!!"
else
echo "Sorry is Fail!!!"
fi
else
echo"sorry install is Fail!!!" fi
elif(($?==))
then
systemctl start nfs
if(($?==))
then
echo "Congratulations!! nfs start OK!!!"
else
echo "sorry!!"
fi
elif(($?==))
then
echo "OKOKOK!!!"
else
echo "I am so sorry"
fi
echo "config writing...."
mount -t nfs 192.168.16.120:/webindex/ /nginxwebservice/
echo "config write is OK!"
systemctl reload nfs
if(($?==))
then
echo "NFS service is OK!"
else
echo "Sorry!!"
fi
Shell脚本-自动化部署反向代理、WEB、nfs的更多相关文章
- shell脚本安装部署反向代理 监控进程 计划任务
1.编写脚本自动部署反向代理.web.nfs: 要求: I.部署nginx反向代理三个web服务,调度算法使用加权轮询: 反向代理服务器脚本配置脚本 #!/bin/bash #安装eple和nginx ...
- shell脚本自动化部署服务
shell脚本自动化部署 !/bin/bash #export PATH=$PATH:/export/maven/bin run_flag_dir="/data0/shell/deploy_ ...
- shell脚本自动化部署
由于公司技术部团队较小,没有专门的运维团队,所以运维工作技术部承包了. 一.纯人工部署是这样的: 1. 本地打包:一般 maven clean package 2. 借助xftp上传到服务器对应目录 ...
- linux下使用shell脚本自动化部署项目
在Java开发项目时经常要把正在开发的项目发布到测试服务器中去测试,一般的话是要把项目先打成war包,然后把war包发布到服务器中,关闭服务器, 最后重新启动服务器,虽然这过程不是很繁琐,但如果是多个 ...
- 编写脚本自动部署反向代理、web、nfs
服务器端 #!/bin/bash function nginx_install(){ if [[ -f /usr/sbin/nginx ]]; then echo 'Nginx has been in ...
- Shell脚本-自动化部署WEB
#! /bin/ ] then echo "#### 参数有误,\$1:构建号必填" exit fi cd /root/workspace/xinya_erp/xinya_web ...
- shell脚本自动化部署Zabbix4.2(修改脚本替换版本)
#!/bin/bash # 检查操作系统版本,该脚本只能运行在 Centos 7.x 系统上 cat /etc/redhat-release |grep -i centos |grep '7.[[:d ...
- shell脚本自动化部署XX的案例(附数组使用)
#!/bin/sh #Auto Make install MFS Files # cat <<EOF ++++++++++++++++Welcome To Use Auto Install ...
- 脚本自动部署及监控 web
1.编写脚本自动部署反向代理.web.nfs: I.部署nginx反向代理两个web服务,调度算法使用加权轮询 II.所有web服务使用共享存储nfs,保证所有web都对其有读写权限,保证数据一致性: ...
随机推荐
- Java 使用 dom4j 读取 xml文档 demo
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://www. ...
- 先验算法(Apriori algorithm) - 机器学习算法
Apriori is an algorithm for frequent item set mining and association rule learning over transactiona ...
- .net MVC4 来一个简单的分页代码
action VodeEntities db = new NewVode.Models.VodeEntities(); ; ) { var sql = "select * ,row_numb ...
- 远程连接工具SSH和linux的连接
实际开发中,Linux服务器都在其他的地方,我们要通过远程的方式去连接Linux并操作它,Linux远程的操作工具有很多,企业中常用的有Puttty.secureCRT.SSH Secure等.我使用 ...
- HBase介绍及简易安装
HBase简介 HBase是Apache Hadoop的数据库,能够对大型数据提供随机.实时的读写访问,是Google的BigTable的开源实现.HBase的目标是存储并处理大型的数据,更具体地说仅 ...
- 【NOI】荷马史诗
追逐影子的人,自己就是影子 ——荷马 Allison最近迷上了文学.她喜欢在一个慵懒的午后,细细地品上一杯卡布奇诺,静静地阅读她爱不释手的<荷马史诗>.但是由<奥德赛>和< ...
- BZOJ 2521: [Shoi2010]最小生成树
2521: [Shoi2010]最小生成树 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 445 Solved: 262[Submit][Statu ...
- 【ARC068F】Solitaire
Description 你有一个双端队列和 \(N\) 个数字,先按 \(1\) 到 \(N\) 的顺序每次从任意一端插入当前数字,再进行 \(N\) 次操作每次可以从两端弹出,求有多少种弹出序列 ...
- 中行P1签名及验签
分享中国银行快捷.NET P1签名和验签方法代码中ReturnValue为自定义类型请无视 #region 验证签名 /// <summary> /// 验证签名 /// </sum ...
- 单点登录(一)-----理论-----单点登录SSO的介绍和CAS+选型
什么是单点登录(SSO) 单点登录主要用于多系统集成,即在多个系统中,用户只需要到一个中央服务器登录一次即可访问这些系统中的任何一个,无须多次登录. 单点登录(Single Sign On),简称为 ...