Shell脚本-自动化部署反向代理、WEB、nfs
部署nginx反向代理三个web服务,调度算法使用加权轮询(由于物理原因只开启两台服务器)
AutoNginxNfsService.sh
#/bin/bash systemctl status nginx if(($?==4))then yum install -y nginxif(($?==0))then#echo 'Yes!'systemctl start nginxif(($?==0))thenecho "Congratulations!! Nginx start OK!!"elseecho "Sorry is Fail!!!" fielseecho"sorry install is Fail!!!"fi elif(($?==3))thensystemctl start nginxif(($?==0))thenecho "Congratulations!! Nginx start OK!!!"elseecho "sorry!!"fi elif(($?==0))thenecho "OKOKOK!!!" else echo "I am so sorry" fi echo "config writing...." grep 'upstream' /etc/nginx/nginx.conf if(($?!=0))thensed -ri '/^http/a upstream Yanlong {' /etc/nginx/nginx.confsed -ri '/^upst/a server yanlongweb1 weight=3\;' /etc/nginx/nginx.confsed -ri '/^server yanlongweb1/a server yanlongweb2\;' /etc/nginx/nginx.confsed -ri '/^server yanlongweb2/a \}' /etc/nginx/nginx.confsed -ri '/^(\ +)(location)(\ )(\/)/a proxy_pass http:\/\/Yanlong\;' /etc/nginx/nginx.conf fi echo "config write is OK!" systemctl reload nginx if(($?==0))thenecho "HTTP load balancer is OK!" elseecho "Sorry!!" fi systemctl status nfs if(($?==4))then yum install rpcbind nfs-utils -yif(($?==0))then#echo 'Yes!'systemctl start nfsif(($?==0))thenecho "Congratulations!! nfs start OK!!"elseecho "Sorry is Fail!!!" fielseecho"sorry install is Fail!!!"fi elif(($?==3))thensystemctl start nfsif(($?==0))thenecho "Congratulations!! nfs start OK!!!"elseecho "sorry!!"fi elif(($?==0))thenecho "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(($?==0))thenecho "NFS service is OK!" elseecho "Sorry!!" fi
所有web服务使用共享存储nfs,保证所有web都对其有读写权限,保证数据一致性
#/bin/bash systemctl status nginx if(($?==4))thenyum install -y nginxif(($?==0))then#echo 'Yes!'systemctl start nginxif(($?==0))thenecho "Congratulations!! Nginx start OK!!"elseecho "Sorry is Fail!!!" fielseecho"sorry install is Fail!!!"fi elif(($?==3))thensystemctl start nginxif(($?==0))thenecho "Congratulations!! Nginx start OK!!!"elseecho "sorry!!"fi elif(($?==0))thenecho "OKOKOK!!!" elseecho "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(($?==0))thenecho "HTTP load balancer YanlongWEBservice is OK!" elseecho "Sorry!!" fi systemctl status nfs if(($?==4))then yum install rpcbind nfs-utils -yif(($?==0))then#echo 'Yes!'systemctl start nfsif(($?==0))thenecho "Congratulations!! nfs start OK!!"elseecho "Sorry is Fail!!!" fielseecho"sorry install is Fail!!!"fi elif(($?==3))thensystemctl start nfsif(($?==0))thenecho "Congratulations!! nfs start OK!!!"elseecho "sorry!!"fi elif(($?==0))thenecho "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(($?==0))thenecho "NFS service is OK!" elseecho "Sorry!!" fi
转载于:https://www.cnblogs.com/DragonFire/p/6612414.html
Shell脚本-自动化部署反向代理、WEB、nfs相关推荐
- shell脚本自动化部署服务
shell脚本自动化部署 !/bin/bash#export PATH=$PATH:/export/maven/binrun_flag_dir="/data0/shell/deploy_wo ...
- SHELL脚本自动化部署MFS分布式文件系统
前言:在我们运维中,最常见的文件存储系统大概就是NFS了,但是随着网站压力不断增加,NFS渐渐不能满足企业数据增长需求,有木有自动扩展.高效.部署.实施方便快捷的分布式存储供我们使用呢?那我们来看一下 ...
- docker $PWD路径_Docker安装Jenkins+Shell脚本自动化部署项目
本文同名博客老炮说Java:https://www.laopaojava.com/,每天更新Spring/SpringMvc/SpringBoot/实战项目等文章资料 Sentinel+Nacos 是 ...
- 编写脚本自动部署反向代理、web、nfs
服务器端 #!/bin/bashfunction nginx_install(){if [[ -f /usr/sbin/nginx ]]; thenecho 'Nginx has been insta ...
- Lync Server外部访问系列PART4:部署反向代理
在外部访问系列中,到此位置的三篇文章,都是准备-部署的形式,因为我想借助这样的结构让大家能够知道哪些是准备工作而哪些是在准备充分的基础上做的工作即我们的部署.但其实部署和准备严格来说都是部署,但我们在 ...
- 通过shell脚本自动化量产SD启动卡
通过shell脚本自动化量产SD启动卡 首先感谢米联客提供的高质量的脚本文件,我这里根据他的脚本文件稍作修改,使用更加便捷,量产SD卡,使用脚本操作,方便快捷.是针对大批量定制SD卡的一种自动化操作. ...
- shell脚本 一键部署 Lnmp 及社区论坛 服务架构
shell脚本 一键部署 Lnmp 一键部署 Lnmp 一键部署 注:亲,记得把所需要的软件包,先放到/opt目录中:以及该机子的内存大小.核数先设置好! #!/bin/bash #先配置好yum e ...
- PHP服务器脚本实例,Shell脚本实现的一个简易Web服务器例子分享_linux shell
这篇文章主要介绍了Shell脚本实现的一个简易Web服务器例子分享,本文实现的Web服务器非常简单实用,可以在你不想安装nginx.apache等大型WEB服务器时使用,需要的朋友可以参考下 假设你想 ...
- shell脚本一键部署lnmp架构
shell脚本一键部署lnmp架构 1. 创建存放脚本的目录 2. 创建脚本文件 3. 编写脚本 4. 通过IP地址直接访问PHP界面 1. 创建存放脚本的目录 [root@localhost ~]# ...
最新文章
- ORACLE相关的SHELL编程
- java boxplot_Matlab Boxplots
- 字符串是单一字符的无序组合吗_Python学习笔记(八)组合数据类型
- [html] 网站如何自适应手机屏幕
- mysql hash切分_轻松优化MySQL-之数据库切分1
- 单选框,下拉菜单美化
- python同时执行多个py文件_【经验分享】如何同时运行多个python脚本
- Autofac 依赖注入框架 使用
- centos eclipse php,centos打不开eclipse怎么办?
- mysql数据库xp下载64位_navicat premium 64位
- 目标检测:SSD目标检测中PriorBox代码解读
- /分数化简和加减乘除
- 车间和仓库可以一起吗_车间和仓库可以划分为一个防火分区吗
- python用schedule库实现定时功能,可每天定时运行程序。
- 为 “超级大脑”构建支撑能力,腾讯云聚焦AI技术落地
- web 中怎么实现斜线表头效果?
- python俗称_python中文叫什么
- 网络切片技术缺点_什么是网络切片?
- 考研计算机专业的优点和缺点,领航考研:跨专业考研优缺点分析
- 「Matlab」“矩阵对矩阵求导的方法”讲解
热门文章
- LeetCode 1486. 数组异或操作
- LeetCode 467. 环绕字符串中唯一的子字符串(思维转换)
- LeetCode 1002. 查找常用字符(哈希)
- 贪心算法(Greedy Algorithm)之霍夫曼编码
- 数据结构--二叉查找树 Binary Search Tree
- POJ 1064 分割线缆(二分查找)
- python rpc webservice_PythonXMLRPC服务器端和客户端实例
- java 程序输出 赵_编写一个完整的JAVA的程序
- springboot 多了8小时_日本人不明白:中国的奶茶有多好喝,值得排队8小时去买?...
- Power BI 数据可视化软件实现共享报表