日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Shell脚本-自动化部署反向代理、WEB、nfs

發布時間:2024/7/19 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。