標籤:伺服器端 代理 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