部署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相关推荐

  1. shell脚本自动化部署服务

    shell脚本自动化部署 !/bin/bash#export PATH=$PATH:/export/maven/binrun_flag_dir="/data0/shell/deploy_wo ...

  2. SHELL脚本自动化部署MFS分布式文件系统

    前言:在我们运维中,最常见的文件存储系统大概就是NFS了,但是随着网站压力不断增加,NFS渐渐不能满足企业数据增长需求,有木有自动扩展.高效.部署.实施方便快捷的分布式存储供我们使用呢?那我们来看一下 ...

  3. docker $PWD路径_Docker安装Jenkins+Shell脚本自动化部署项目

    本文同名博客老炮说Java:https://www.laopaojava.com/,每天更新Spring/SpringMvc/SpringBoot/实战项目等文章资料 Sentinel+Nacos 是 ...

  4. 编写脚本自动部署反向代理、web、nfs

    服务器端 #!/bin/bashfunction nginx_install(){if [[ -f /usr/sbin/nginx ]]; thenecho 'Nginx has been insta ...

  5. Lync Server外部访问系列PART4:部署反向代理

    在外部访问系列中,到此位置的三篇文章,都是准备-部署的形式,因为我想借助这样的结构让大家能够知道哪些是准备工作而哪些是在准备充分的基础上做的工作即我们的部署.但其实部署和准备严格来说都是部署,但我们在 ...

  6. 通过shell脚本自动化量产SD启动卡

    通过shell脚本自动化量产SD启动卡 首先感谢米联客提供的高质量的脚本文件,我这里根据他的脚本文件稍作修改,使用更加便捷,量产SD卡,使用脚本操作,方便快捷.是针对大批量定制SD卡的一种自动化操作. ...

  7. shell脚本 一键部署 Lnmp 及社区论坛 服务架构

    shell脚本 一键部署 Lnmp 一键部署 Lnmp 一键部署 注:亲,记得把所需要的软件包,先放到/opt目录中:以及该机子的内存大小.核数先设置好! #!/bin/bash #先配置好yum e ...

  8. PHP服务器脚本实例,Shell脚本实现的一个简易Web服务器例子分享_linux shell

    这篇文章主要介绍了Shell脚本实现的一个简易Web服务器例子分享,本文实现的Web服务器非常简单实用,可以在你不想安装nginx.apache等大型WEB服务器时使用,需要的朋友可以参考下 假设你想 ...

  9. shell脚本一键部署lnmp架构

    shell脚本一键部署lnmp架构 1. 创建存放脚本的目录 2. 创建脚本文件 3. 编写脚本 4. 通过IP地址直接访问PHP界面 1. 创建存放脚本的目录 [root@localhost ~]# ...

最新文章

  1. ORACLE相关的SHELL编程
  2. java boxplot_Matlab Boxplots
  3. 字符串是单一字符的无序组合吗_Python学习笔记(八)组合数据类型
  4. [html] 网站如何自适应手机屏幕
  5. mysql hash切分_轻松优化MySQL-之数据库切分1
  6. 单选框,下拉菜单美化
  7. python同时执行多个py文件_【经验分享】如何同时运行多个python脚本
  8. Autofac 依赖注入框架 使用
  9. centos eclipse php,centos打不开eclipse怎么办?
  10. mysql数据库xp下载64位_navicat premium 64位
  11. 目标检测:SSD目标检测中PriorBox代码解读
  12. /分数化简和加减乘除
  13. 车间和仓库可以一起吗_车间和仓库可以划分为一个防火分区吗
  14. python用schedule库实现定时功能,可每天定时运行程序。
  15. 为 “超级大脑”构建支撑能力,腾讯云聚焦AI技术落地
  16. web 中怎么实现斜线表头效果?
  17. python俗称_python中文叫什么
  18. 网络切片技术缺点_什么是网络切片?
  19. 考研计算机专业的优点和缺点,领航考研:跨专业考研优缺点分析
  20. 「Matlab」“矩阵对矩阵求导的方法”讲解

热门文章

  1. LeetCode 1486. 数组异或操作
  2. LeetCode 467. 环绕字符串中唯一的子字符串(思维转换)
  3. LeetCode 1002. 查找常用字符(哈希)
  4. 贪心算法(Greedy Algorithm)之霍夫曼编码
  5. 数据结构--二叉查找树 Binary Search Tree
  6. POJ 1064 分割线缆(二分查找)
  7. python rpc webservice_PythonXMLRPC服务器端和客户端实例
  8. java 程序输出 赵_编写一个完整的JAVA的程序
  9. springboot 多了8小时_日本人不明白:中国的奶茶有多好喝,值得排队8小时去买?...
  10. Power BI 数据可视化软件实现共享报表