首页 > 代码库 > shell脚本编写
shell脚本编写
自动部署、初始配置、并启动nginx反向代理服务;自动部署、初始配置、并启动两台web
#!/bin/bash yum install epel-release -y yum install nginx -y ps aux |grep nginx |grep -v ‘grep‘ if [ $? -ne 0 ] then systemctl start nginx fi sed -ri ‘/^http/a upstream xzhweb\{‘ /etc/nginx/nginx.conf sed -ri ‘/^upstream/a server 192.168.16.99‘ /etc/nginx/nginx.conf sed -ri ‘/^server/a }‘ /etc/nginx/nginx.conf sed -ri ‘/^server/a server 192.168.16.175‘ /etc/nginx/nginx.conf sed -ri ‘/^\ +location \/ /a proxy_pass http://xzhweb;‘ /etc/nginx/nginx.conf systemctl stop firewalld setenforce 0 systemctl restart nginx if [ $? -ne 0 ] then echo wellcome to congratulation fi
192.168.16.27 为反向代理
监控脚本:监控每台机器的内存使用率>70%,则输出报警信息
#!/bin/bash mem_used=`free | awk ‘NR==2{print $3}‘` mem_total=`free | awk ‘NR==2{print $2}‘` x=`expr "scale=2; $mem_used/$mem_total" |bc -l |cut -d. -f2` if ((x>70)); then echo "Your memory is using $x\%, please handle as soon as possible." else echo "Your memory usage is $x%, can be at ease use!" fi
shell脚本编写
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。