編寫指令碼自動部署反向 Proxy、web、nfs

來源:互聯網
上載者:User

標籤:伺服器端   代理   emctl   echo   exp   $?   nfs   lan   conf   

伺服器端
#!/bin/bashfunction nginx_install(){if [[ -f /usr/sbin/nginx ]]; thenecho ‘Nginx has been installed.‘exitelseflag1=3while [[ $flag1 -gt 0 ]]; doyum install epel-release -y && yum install nginx -yif [[ $? -ne 0 ]]; then((flag1--))elseecho ‘Nginx has been installed.‘exitfidoneecho ‘Nginx install failed.‘fisystemctl start nginx}function nginx_balancer(){msg1=‘upstream myapp1 { server 192.168.60.129; server 192.168.60.130; server 192.168.60.131; }‘msg2=‘proxy_pass http://myapp1;‘sed -ri "/^http/a $msg1" /etc/nginx/nginx.confsed -ri "/^ *location \/ \{$/a $msg2" /etc/nginx/nginx.confsystemctl reload nginx}function nfs_install(){rpm -qa |grep rpcbind >> /dev/nullif [[ $? -eq 0 ]]; thenecho ‘RPCbind has been installed‘elseflag2=3while [[ $flag2 -gt 0 ]]; doyum install rpcbind -yif [[ $? -ne 0 ]]; then((flag2--))elseecho ‘RPCbind has been installed.‘exitfidoneecho ‘RPCbind install failed.‘firpm -qa |grep nfs-utils >> /dev/nullif [[ $? -eq 0 ]]; thenecho ‘nfs-utils has been installed‘elseflag3=3while [[ $flag3 -gt 0 ]]; doyum install nfs-utils -yif [[ $? -ne 0 ]]; then((flag3--))elseecho ‘nfs-utils has been installed.‘exitfidoneecho ‘nfs-utils install failed.‘fi}function nfs_server(){mkdir /sharetouch /share/index.htmlecho ‘---NFS---Hello---‘ > /share/index.htmlchmod -R o+w /shareecho ‘/share 192.168.60.0/24(rw,sync,fsid=0)‘ >> /etc/exportssystemctl start rpcbind.service && systemctl start nfs-server.serviceif [[ $? -eq 0 ]]; thenecho ‘NFS server running.‘fisystemctl enable rpcbind.service && systemctl enable nfs-server.service}nginx_installnginx_balancernfs_installnfs_server

  

用戶端
#!/bin/bashfunction nginx_install(){if [[ -f /usr/sbin/nginx ]]; thenecho ‘Nginx has been installed.‘exitelseflag1=3while [[ $flag1 -gt 0 ]]; doyum install epel-release -y && yum install nginx -yif [[ $? -ne 0 ]]; then((flag1--))elseecho ‘Nginx has been installed.‘exitfidoneecho ‘Nginx install failed.‘fisystemctl start nginx}function nfs_install(){rpm -qa |grep rpcbind >> /dev/nullif [[ $? -eq 0 ]]; thenecho ‘RPCbind has been installed‘elseflag2=3while [[ $flag2 -gt 0 ]]; doyum install rpcbind -yif [[ $? -ne 0 ]]; then((flag2--))elseecho ‘RPCbind has been installed.‘exitfidoneecho ‘RPCbind install failed.‘firpm -qa |grep nfs-utils >> /dev/nullif [[ $? -eq 0 ]]; thenecho ‘nfs-utils has been installed‘elseflag3=3while [[ $flag3 -gt 0 ]]; doyum install nfs-utils -yif [[ $? -ne 0 ]]; then((flag3--))elseecho ‘nfs-utils has been installed.‘exitfidoneecho ‘nfs-utils install failed.‘fi}function nfs_client(){systemctl start rpcbind.service && systemctl start nfs-server.servicesystemctl enable rpcbind.service && systemctl enable nfs-server.servicemount -t nfs 192.168.60.128:/share /usr/share/nginx/html/df |grep 192.168.60.128 >> /dev/nullif [[ $? -eq 0 ]]; thenecho ‘NFS client running.‘fi}nginx_installnfs_installnfs_client

  

編寫指令碼自動部署反向 Proxy、web、nfs

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.