Shell指令碼-自動化部署反向 Proxy、WEB、nfs

來源:互聯網
上載者:User

標籤:使用   共用   web服務   shell   blog   sse   gre   else   long   

部署nginx反向 Proxy三個web服務,調度演算法使用加權輪詢(由於物理原因只開啟兩台伺服器)

AutoNginxNfsService.sh

#/bin/bashsystemctl status nginxif(($?==4))    then     yum install -y nginx    if(($?==0))        then        #echo ‘Yes!‘        systemctl start nginx        if(($?==0))            then            echo "Congratulations!! Nginx start OK!!"        else            echo "Sorry is Fail!!!"            fi    else        echo"sorry install is Fail!!!"            fi elif(($?==3))    then    systemctl start nginx    if(($?==0))        then        echo "Congratulations!! Nginx start OK!!!"    else        echo "sorry!!"    fielif(($?==0))    then    echo "OKOKOK!!!"else     echo "I am so sorry"    fiecho "config writing...."grep ‘upstream‘ /etc/nginx/nginx.confif(($?!=0))    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.conffiecho "config write is OK!"systemctl reload nginxif(($?==0))    then    echo "HTTP load balancer is OK!"else    echo "Sorry!!"fisystemctl status nfsif(($?==4))    then     yum install rpcbind nfs-utils -y    if(($?==0))        then        #echo ‘Yes!‘        systemctl start nfs        if(($?==0))            then            echo "Congratulations!! nfs start OK!!"        else            echo "Sorry is Fail!!!"            fi    else        echo"sorry install is Fail!!!"            fi elif(($?==3))    then    systemctl start nfs    if(($?==0))        then        echo "Congratulations!! nfs start OK!!!"    else        echo "sorry!!"    fielif(($?==0))    then    echo "OKOKOK!!!"else     echo "I am so sorry"    fiecho "config writing...."echo "/webindex 192.168.16.0/24(rw,sync,fsid=0)" > /etc/exportsecho "config write is OK!"systemctl reload nfsif(($?==0))    then    echo "NFS service is OK!"else    echo "Sorry!!"fi

所有web服務使用共用儲存nfs,保證所有web都對其有讀寫權限,保證資料一致性

#/bin/bashsystemctl status nginxif(($?==4))        then        yum install -y nginx        if(($?==0))                then                #echo ‘Yes!‘                systemctl start nginx                if(($?==0))                        then                        echo "Congratulations!! Nginx start OK!!"                else                        echo "Sorry is Fail!!!"                 fi        else                echo"sorry install is Fail!!!"        fielif(($?==3))        then        systemctl start nginx        if(($?==0))                then                echo "Congratulations!! Nginx start OK!!!"        else                echo "sorry!!"        fielif(($?==0))        then        echo "OKOKOK!!!"else        echo "I am so sorry"    fiecho "config writing...."sed -ri ‘/^(\ +)(location)(\ )(\/)/a root\ \/nginxwebservice\;‘ /etc/nginx/nginx.confsed -ri ‘/^root\ \/nginxwebservice/a index\ web.html\;‘ /etc/nginx/nginx.confecho "config write is OK!"systemctl reload nginxif(($?==0))        then        echo "HTTP load balancer YanlongWEBservice is OK!"else        echo "Sorry!!"fisystemctl status nfsif(($?==4))    then     yum install rpcbind nfs-utils -y    if(($?==0))        then        #echo ‘Yes!‘        systemctl start nfs        if(($?==0))            then            echo "Congratulations!! nfs start OK!!"        else            echo "Sorry is Fail!!!"            fi    else        echo"sorry install is Fail!!!"            fi elif(($?==3))    then    systemctl start nfs    if(($?==0))        then        echo "Congratulations!! nfs start OK!!!"    else        echo "sorry!!"    fielif(($?==0))    then    echo "OKOKOK!!!"else     echo "I am so sorry"    fiecho "config writing...."mount -t nfs 192.168.16.120:/webindex/ /nginxwebservice/echo "config write is OK!"systemctl reload nfsif(($?==0))    then    echo "NFS service is OK!"else    echo "Sorry!!"fi

 

Shell指令碼-自動化部署反向 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.