Shell脚本-自动化部署反向代理、WEB、nfs
生活随笔
收集整理的這篇文章主要介紹了
Shell脚本-自动化部署反向代理、WEB、nfs
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
部署nginx反向代理三個(gè)web服務(wù),調(diào)度算法使用加權(quán)輪詢(由于物理原因只開啟兩臺(tái)服務(wù)器)
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服務(wù)使用共享存儲(chǔ)nfs,保證所有web都對(duì)其有讀寫權(quán)限,保證數(shù)據(jù)一致性
#/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?
轉(zhuǎn)載于:https://www.cnblogs.com/DragonFire/p/6612414.html
總結(jié)
以上是生活随笔為你收集整理的Shell脚本-自动化部署反向代理、WEB、nfs的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: c# ref和out参数
- 下一篇: centos 环境变量配置