linux基础 -nginx和nfs代理 开发脚本自动部署及监控
开发脚本自动部署及监控 1.编写脚本自动部署反向代理、web、nfs; (1)、部署nginx反向代理三个web服务,调度算法使用加权轮询;
(2)、所有web服务使用共享存储nfs,保证所有web都对其有读写权限,保证数据一致性;
脚本如下
#!/bin/sh
Nginx_WebInstall(){
systemctl stop firewalld
setenforce
ps -aux | grep nginx |grep -v "grep"
if [ $? -ne ]
then
yum install epel-release -y &>/dev/null;
yum install nginx -y &>/dev/null;
systemctl start nginx;
echo "nginx is successful!!"
else
systemctl restart nginx fi
} Conf_Nginx(){
if [ -f "/etc/nginx/nginx.conf" ]
then
sed -ri '/^http/a upstream xyyweb { ' /etc/nginx/nginx.conf
sed -ri '/^upstream/a server 192.168.31.101 weight=3; \n }' /etc/nginx/nginx.conf
sed -ri '/^upstream/a server 192.168.31.164 weight=3;' /etc/nginx/nginx.conf
sed -ri '/^upstream/a server 192.168.31.131 weight=3;' /etc/nginx/nginx.conf
sed -ri '47a \\n\t location \/ {\n\t\t proxy_pass http://xyyweb;\n\t}' /etc/nginx/nginx.conf
elif [ $? -eq ]
then
systemctl restart nginx
else
echo "input file false."
fi
} Nginx_WebInstall ##这个命令只安装web服务器
Conf_Nginx ##这个是进行修改配置文件(两者同时运行时是安装代理服务器) Nfs_install(){
if [ -s "/etc/exports" ]
then
systemctl stop firewalld
setenforce
yum -y install rpcbind nfs-utils &>/dev/null;
echo "rpcbind and nfs is successful!!"
elif [ $? -eq ]
then
systemctl enable nfs-server.service;
systemctl enable rpcbind.service;
systemctl start rpcbind;
systemctl start nfs;
Rpc=`rpcinfo -p localhost|wc -l;`
ps -ef|grep nfsd
elif [ $Rpc -eq -o $? -eq ]
then
echo "rpcbind and nfs is start success!!"
fi
mkdir /share; echo "/share 192.168.31.0/24 (rw,sync,fsid=0)" >/etc/exports chmod /share }
Nfs_install ##安装nfs的命令;
web节点服务器挂载nfs是 只需在上面执行mount -t nfs ipaddress:/share /web-serverdir



安装nginx:


修改配置文件:




安装nfs:



2、编写监控脚本,监控集群内所有服务存活状态,内存、磁盘剩余率检测,异常则发送报警邮件
#!/bin/sh
NgxMonitor(){
ps -ef | grep nginx| grep -v grep
if [ $? -ne ]
then
msg="TIME:$(date +%F_%T)
HOSTNAME:$(hostname)
IPADDR:$(ifconfig |awk 'NR==2{print $2}')
MSG:Nginx program is crash, Waiting to restart"
echo $msg
/usr/bin/my_mail $msg
systemctl restart nginx
fi
} NfsMonitor(){
ps -ef | grep nfs| grep -v grep
if [ $? -ne ]
then
msg="TIME:$(date +%F_%T)
HOSTNAME:$(hostname)
IPADDR:$(ifconfig |awk 'NR==2{print $2}')
MSG:NFS program is crash, Waiting to restart"
echo $msg
/usr/bin/my_mail $msg
systemctl restart nginx
fi
} MemMonitor(){
mem_use=`free | awk 'NR==2{print $3}'`
mem_total=`free | awk 'NR==2{print $2}'`
mem_per=`echo "scale=2;$mem_use/$mem_total"|bc -l |cut -d . -f2` if (( $mem_per > ))
then
msg="TIME:$(date +%F_%T)
HOSTNAME:$(hostname)
IPADDR:$(ifconfig |awk 'NR==2{print $2}')
MSG:Memory usage exceeds the limit,current value is ${mem_per}%"
echo $msg
/usr/bin/my_mail $msg
fi
} DiskMonitor(){
space_use=`df $disk |awk 'NR==2{print $5}'|cut -d% -f1` if [ $space_use -gt ]
then
msg="TIME:$(date +%F_%T)
HOSTNAME:$(hostname)
IPADDR:$(/usr/sbin/ifconfig |awk 'NR==2{print $2}')
MSG:Disk space usage exceeds the limit,current value is ${space_use}%"
echo $msg
/usr/bin/my_mail $msg
fi
} NgxMonitor
NfsMonitor
MemMonitor
DiskMonitor
3.编写计划任务,定时运行监控脚本,完成监控操作


linux基础 -nginx和nfs代理 开发脚本自动部署及监控的更多相关文章
- linux开发脚本自动部署及监控
linux开发脚本自动部署及监控 开发脚本自动部署及监控一.编写脚本自动部署反向代理.web.nfs:要求:1.部署nginx反向代理三个web服务,调度算法使用加权轮询: #!/bin/sh ngx ...
- 脚本自动部署及监控 web
1.编写脚本自动部署反向代理.web.nfs: I.部署nginx反向代理两个web服务,调度算法使用加权轮询 II.所有web服务使用共享存储nfs,保证所有web都对其有读写权限,保证数据一致性: ...
- shell脚本自动部署及监控
一.shell脚本部署nginx反向代理和三个web服务 1 对反向代理服务器进行配置 #!/bin/bash #修改用户交互页面 用户输入参数执行相应的参数 #安装epel扩展包和nginx fun ...
- 010-- 开发脚本自动部署nginx_web和nfs及监控内存
1.编写脚本自动部署反向代理.web.nfs: #!/bin/bash #检测安装nginx function detection_nginx(){ if [ -f /etc/nginx/nginx. ...
- CentOS/Linux内存占用大,用Shell脚本自动定时清除/释放内存
CentOS/Linux内存占用大,用Shell脚本自动定时清除/释放内存来自:互联网 时间:2020-03-22 阅读:114以下情况可能造成Linux内存占用过高服务配置存在直接分配错误,或隐性分 ...
- windows/Linux下设置ASP.Net Core开发环境并部署应用
10分钟学会在windows/Linux下设置ASP.Net Core开发环境并部署应用 创建和开发ASP.NET Core应用可以有二种方式:最简单的方式是通过Visual Studio 2017 ...
- shell脚本编写-自动部署及监控
1.编写脚本自动部署反向代理.web.nfs: I.部署nginx反向代理两个web服务,调度算法使用加权轮询 II.所有web服务使用共享存储nfs,保证所有web都对其有读写权限,保证数据一致性: ...
- Linux安装Nginx使用反向代理
nginx的反向代理功能(自带了反向代理的功能,天生的二道贩子)1.实验环境准备准备2个服务器,都安装好nginx软件nginx1 192.168.13.79 作为web服务器 (理解为火车票售票点) ...
- 10分钟学会在windows/Linux下设置ASP.Net Core开发环境并部署应用
创建和开发ASP.NET Core应用可以有二种方式:最简单的方式是通过Visual Studio 2017 来创建,其优点是简单方便,但需要安装最新版本Visual Studio 2017 prev ...
随机推荐
- 【个人训练】(UVa146)ID Codes
题意与解析 这题其实特别简单,求给定排列的后继.使用stl(next_permutation)可以方便地解决这个问题.但是,想要自己动手解就是另外一回事了.我的解法是从后往前找到第一个$a_i$比$a ...
- Qt Qwdget 汽车仪表知识点拆解6 自定义控件
先贴上效果图,注意,没有写逻辑,都是乱动的 这里说一下控件自定义 图中标出的部分都是自定义的控件 这里如果我们有批量类似的功能,就可以使用自定义控件的方式,这里我已下面的自定义控件说一下,上面的在上一 ...
- 阿里云SLB上http强制跳转到https问题处理
背景: 最近一客户有一个需求,需要将外网所有http访问请求强制跳转到https,公网出口使用阿里云SLB,证书放在SLB上,SLB后端实例为ECS(webserver)web服务使用nginx, 网 ...
- Kindle 3(非常旧的版本) 隔一段时间自动重启问题
买了本新书后,kindle 3 自己没事就在那边重启,几分钟一次 查到解决方案1: https://answers.yahoo.com/question/index?qid=2014040815565 ...
- UVA 11297 Census(二维线段树)
Description This year, there have been many problems with population calculations, since in some cit ...
- HDU 4571 Travel in time(最短路径+DP)(2013 ACM-ICPC长沙赛区全国邀请赛)
Problem Description Bob gets tired of playing games, leaves Alice, and travels to Changsha alone. Yu ...
- 第十一次ScrumMeeting会议
第十一次ScrumMeeting 时间:2017/11/18 4:00-4:30 地点:主203 人员:全体人员 照片: 工作情况 名字 今日计划 明天的工作 遇到的困难 蔡帜 讨论策划详情\确定WB ...
- DPDK vhost库
原创翻译,转载请注明出处. vhost库实现了一个用户空间的virtio net server,允许用户直接处理virtio ring队列.换句话说,它让用户可以从VM virtio网络设备读取或写入 ...
- 【Linux】Linux修改openfile和max user processes?
#当时测试虚机为centos7.4版本: # 在/etc/security/limits.conf文件末尾添加如下命令: * soft nproc 1314 * hard ...
- windows apache启动报错
Windows启动Apache时报错 he requested operation has failed 有可能80端口被占或者项目路径不存在等 首先找到问题原因 cmd--命令端--切换到apach ...