脚本自动部署构架集群和监控状态
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了脚本自动部署构架集群和监控状态相关的知识,希望对你有一定的参考价值。
脚本自动部署构架集群和监控状态
shell脚本编写
自动部署、初始配置、并启动nginx反向代理服务
1 #!/bin/bash 2 systemctl disable firewalld 3 systemctl stop firewalld 4 setenforce 0 5 #### 6 yum install epel-release -y 7 yum -y install zlib zlib-devel openssl openssl--devel pcre pcre-devel 8 yum install nginx -y 9 echo ‘nginx 服务已经安装好‘ 10 #### 11 systemctl start nginx 12 read -p "please input the ip of the proxy:" proxy 13 echo "$proxy proxy" >> /etc/hosts 14 read -p "please input the ip of the web1:" web1 15 echo "$web1 web1" >> /etc/hosts 16 read -p "please input the ip of the web2:" web2 17 echo "$web2 web2" >> /etc/hosts 18 #### 19 sed -i -r ‘/http( )(\{)/a\upstream ruan {\nserver web1:80;\nserver web2:80;\n}‘ /etc/nginx/nginx.conf 20 sed -i -r ‘/(^ +)location( )(\/)/a\ proxy_pass http://ruan;‘ /etc/nginx/nginx.conf 21 22 echo "nginx配置完成" 23 systemctl restart nginx 24 echo ‘nginx 已经运行‘ 25 #### 26 yum install rpcbind nfs-utils -y 27 echo "nfs安装完成" 28 #### 29 if [ ! -d /share ];then 30 mkdir -p /share 31 chmod -R o+w /share 32 fi 33 #### 34 echo ‘/share 192.168.16.0/24(rw,sync,fsid=0)‘ > /etc/exports 35 systemctl enable rpcbind.service 36 systemctl enable nfs-server.service 37 systemctl start rpcbind.service 38 systemctl start nfs-server.service 39 echo "nfs已经启动" 40 ~
自动部署、初始配置、并启动三台web
1 #!/bin/bash 2 systemctl disable firewalld 3 systemctl stop firewalld 4 setenforce 0 5 #### 6 yum install epel-release -y 7 yum -y install zlib zlib-devel openssl openssl--devel pcre pcre-devel 8 yum install nginx -y 9 echo ‘nginx 服务已经安装好‘ 10 #### 11 systemctl start nginx 12 #read -p "please input the ip of the web1:" web1 13 #echo "$web1 web1" >> /etc/hosts 14 read -p "please input the ip of the proxy:" proxy 15 echo "$proxy proxy" >> /etc/hosts 16 #### 17 #sed -i -r ‘/http( )(\{)/a\upstream ruan {\nserver web1:80;\nserver web2:80;\n}‘ /etc/nginx/nginx.conf 18 sed -i -r ‘/(^ +)location( )(\/)/a\ root /var/www/html;\nindex index.html;‘ /etc/nginx/nginx.conf 19 mkdir -p /var/www/html 20 echo `hostname` > /var/www/html/index.html 21 echo "nginx配置完成" 22 systemctl restart nginx 23 echo ‘nginx 已经运行‘ 24 #### 25 yum install rpcbind nfs-utils -y 26 echo "nfs服务安装完成" 27 #### 28 systemctl enable rpcbind.service 29 systemctl enable nfs-server.service 30 systemctl start rpcbind.service 31 systemctl start nfs-server.service 32 mount -t nfs $proxy:/share /var/www/html/ 33 echo "welcome" > /var/www/html/index.html
编写监控脚本,监控集群中nginx、nfs以及机器运行状况。异常则发送报警邮件
以上是关于脚本自动部署构架集群和监控状态的主要内容,如果未能解决你的问题,请参考以下文章
mongodb 监控工具 mongo-monitor 安装部署
Terraform 和 GCP:Google kubernetes 集群问题:看不到工作负载(部署、状态集)内部的监控部分(内存和 cpu)