部署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的更多相关文章

  1. shell脚本安装部署反向代理 监控进程 计划任务

    1.编写脚本自动部署反向代理.web.nfs: 要求: I.部署nginx反向代理三个web服务,调度算法使用加权轮询: 反向代理服务器脚本配置脚本 #!/bin/bash #安装eple和nginx ...

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

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

  3. shell脚本自动化部署

    由于公司技术部团队较小,没有专门的运维团队,所以运维工作技术部承包了. 一.纯人工部署是这样的: 1. 本地打包:一般 maven clean package 2. 借助xftp上传到服务器对应目录 ...

  4. linux下使用shell脚本自动化部署项目

    在Java开发项目时经常要把正在开发的项目发布到测试服务器中去测试,一般的话是要把项目先打成war包,然后把war包发布到服务器中,关闭服务器, 最后重新启动服务器,虽然这过程不是很繁琐,但如果是多个 ...

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

    服务器端 #!/bin/bash function nginx_install(){ if [[ -f /usr/sbin/nginx ]]; then echo 'Nginx has been in ...

  6. Shell脚本-自动化部署WEB

    #! /bin/ ] then echo "#### 参数有误,\$1:构建号必填" exit fi cd /root/workspace/xinya_erp/xinya_web ...

  7. shell脚本自动化部署Zabbix4.2(修改脚本替换版本)

    #!/bin/bash # 检查操作系统版本,该脚本只能运行在 Centos 7.x 系统上 cat /etc/redhat-release |grep -i centos |grep '7.[[:d ...

  8. shell脚本自动化部署XX的案例(附数组使用)

    #!/bin/sh #Auto Make install MFS Files # cat <<EOF ++++++++++++++++Welcome To Use Auto Install ...

  9. 脚本自动部署及监控 web

    1.编写脚本自动部署反向代理.web.nfs: I.部署nginx反向代理两个web服务,调度算法使用加权轮询 II.所有web服务使用共享存储nfs,保证所有web都对其有读写权限,保证数据一致性: ...

随机推荐

  1. 【vue】router-link 与 router-view

    1 router-link <router-link :to="{ path: '/hello', component: HelloWorld }">hello< ...

  2. VNC Server (Ubuntu 16.04.3 GNOME)

    1. 安装VNC服务 sudo apt-get install vnc4server -y 2. 启动VNC服务 vncserver :1 3. 此时客户端连上后你会发现灰屏,原因出在~/.vnc/x ...

  3. Linux下CPU信息的查看

    逻辑CPU个数: cat /proc/cpuinfo | grep "processor" | wc -l     //32 物理CPU个数: cat /proc/cpuinfo ...

  4. [转帖]windows 2008 Server R2 /Win7启用TLS 1.2

    来自新浪博客的 一个文章 自己很早之前曾经看过 iis的加密工具 但是当时没有认识到TLS1.2协议的问题 这里 晚上学习了一下.  http://blog.sina.com.cn/s/blog_16 ...

  5. 如何调换antd中Modal对话框确认按钮和取消按钮两个按钮的位置

    今天有个工作是把所有的确认按钮放在取消按钮的左边,类似于下图这样的,公司用的时antd组件 但是antd组件的按钮时确认键放在右边的 可以采用下面的方式,将按钮调换过来: 对的,就是在modal里面的 ...

  6. java.lang.IllegalArgumentException: Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986

    微信小程序前后台使用get方式传参时报错如图.但在微信开发平台和苹果测试都没事,在安卓手机上就报这个错,猜想原因是get传递了汉字的原因. 尝试了下在后台输出从前台获取的参数,但是后台什么也没有获取到 ...

  7. QML——添加自定义模块

    一.模块的定义 在使用QML时,我们常常看到类似这样的语句: import QtQuick 2.0 import QtSensors 5.0 通过这些import语句,我们就能使用QML中的相关控件了 ...

  8. Jackson 使用

    // 序列化出来的 JSON, 不包含值为 NULL 类型字段. mapper.setSerializationInclusion(Include.NON_NULL); Jackson provide ...

  9. hao123劫持主页

    转自:https://www.zhihu.com/question/39881858 第一步 Firefox.打开Firefox,按Alt+H弹出帮助菜单,点“故障排除信息” 第二步 点“配置文件夹” ...

  10. 【NOI 2018】归程(Kruskal重构树)

    题面在这里就不放了. 同步赛在做这个题的时候,心里有点纠结,很容易想到离线的做法,将边和询问一起按水位线排序,模拟水位下降,维护当前的各个联通块中距离$1$最近的距离,每次遇到询问时输出所在联通块的信 ...