服务器端

#!/bin/bash

function nginx_install(){
if [[ -f /usr/sbin/nginx ]]; then
echo 'Nginx has been installed.'
exit
else
flag1=3
while [[ $flag1 -gt 0 ]]; do
yum install epel-release -y && yum install nginx -y
if [[ $? -ne 0 ]]; then
((flag1--))
else
echo 'Nginx has been installed.'
exit
fi
done
echo 'Nginx install failed.'
fi
systemctl 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.conf
sed -ri "/^ *location \/ \{$/a $msg2" /etc/nginx/nginx.conf
systemctl reload nginx
} function nfs_install(){
rpm -qa |grep rpcbind >> /dev/null
if [[ $? -eq 0 ]]; then
echo 'RPCbind has been installed'
else
flag2=3
while [[ $flag2 -gt 0 ]]; do
yum install rpcbind -y
if [[ $? -ne 0 ]]; then
((flag2--))
else
echo 'RPCbind has been installed.'
exit
fi
done
echo 'RPCbind install failed.'
fi
rpm -qa |grep nfs-utils >> /dev/null
if [[ $? -eq 0 ]]; then
echo 'nfs-utils has been installed'
else
flag3=3
while [[ $flag3 -gt 0 ]]; do
yum install nfs-utils -y
if [[ $? -ne 0 ]]; then
((flag3--))
else
echo 'nfs-utils has been installed.'
exit
fi
done
echo 'nfs-utils install failed.'
fi
} function nfs_server(){
mkdir /share
touch /share/index.html
echo '---NFS---Hello---' > /share/index.html
chmod -R o+w /share
echo '/share 192.168.60.0/24(rw,sync,fsid=0)' >> /etc/exports
systemctl start rpcbind.service && systemctl start nfs-server.service
if [[ $? -eq 0 ]]; then
echo 'NFS server running.'
fi
systemctl enable rpcbind.service && systemctl enable nfs-server.service
} nginx_install
nginx_balancer
nfs_install
nfs_server

  

客户端

#!/bin/bash

function nginx_install(){
if [[ -f /usr/sbin/nginx ]]; then
echo 'Nginx has been installed.'
exit
else
flag1=3
while [[ $flag1 -gt 0 ]]; do
yum install epel-release -y && yum install nginx -y
if [[ $? -ne 0 ]]; then
((flag1--))
else
echo 'Nginx has been installed.'
exit
fi
done
echo 'Nginx install failed.'
fi
systemctl start nginx
} function nfs_install(){
rpm -qa |grep rpcbind >> /dev/null
if [[ $? -eq 0 ]]; then
echo 'RPCbind has been installed'
else
flag2=3
while [[ $flag2 -gt 0 ]]; do
yum install rpcbind -y
if [[ $? -ne 0 ]]; then
((flag2--))
else
echo 'RPCbind has been installed.'
exit
fi
done
echo 'RPCbind install failed.'
fi
rpm -qa |grep nfs-utils >> /dev/null
if [[ $? -eq 0 ]]; then
echo 'nfs-utils has been installed'
else
flag3=3
while [[ $flag3 -gt 0 ]]; do
yum install nfs-utils -y
if [[ $? -ne 0 ]]; then
((flag3--))
else
echo 'nfs-utils has been installed.'
exit
fi
done
echo 'nfs-utils install failed.'
fi
} function nfs_client(){
systemctl start rpcbind.service && systemctl start nfs-server.service
systemctl enable rpcbind.service && systemctl enable nfs-server.service
mount -t nfs 192.168.60.128:/share /usr/share/nginx/html/
df |grep 192.168.60.128 >> /dev/null
if [[ $? -eq 0 ]]; then
echo 'NFS client running.'
fi
} nginx_install
nfs_install
nfs_client

  

编写脚本自动部署反向代理、web、nfs的更多相关文章

  1. 脚本自动部署及监控 web

    1.编写脚本自动部署反向代理.web.nfs: I.部署nginx反向代理两个web服务,调度算法使用加权轮询 II.所有web服务使用共享存储nfs,保证所有web都对其有读写权限,保证数据一致性: ...

  2. shell脚本安装部署反向代理 监控进程 计划任务

    1.编写脚本自动部署反向代理.web.nfs: 要求: I.部署nginx反向代理三个web服务,调度算法使用加权轮询: 反向代理服务器脚本配置脚本 #!/bin/bash #安装eple和nginx ...

  3. Shell脚本-自动化部署反向代理、WEB、nfs

    部署nginx反向代理三个web服务,调度算法使用加权轮询(由于物理原因只开启两台服务器) AutoNginxNfsService.sh #/bin/bash systemctl status ngi ...

  4. linux基础 -nginx和nfs代理 开发脚本自动部署及监控

    开发脚本自动部署及监控 1.编写脚本自动部署反向代理.web.nfs: (1).部署nginx反向代理三个web服务,调度算法使用加权轮询:  (2).所有web服务使用共享存储nfs,保证所有web ...

  5. 010-- 开发脚本自动部署nginx_web和nfs及监控内存

    1.编写脚本自动部署反向代理.web.nfs: #!/bin/bash #检测安装nginx function detection_nginx(){ if [ -f /etc/nginx/nginx. ...

  6. linux开发脚本自动部署及监控

    linux开发脚本自动部署及监控 开发脚本自动部署及监控一.编写脚本自动部署反向代理.web.nfs:要求:1.部署nginx反向代理三个web服务,调度算法使用加权轮询: #!/bin/sh ngx ...

  7. Linux基础-----------nginx安装和nginx web、nginx反向代理、nfs 服务

    作业一:nginx服务1)二进制安装nginx包 yum install epel-release -y 先安装epel-release 再查看yum源中已经安装上了epel相关文件 中间省去了一些安 ...

  8. shell脚本自动部署及监控

    一.shell脚本部署nginx反向代理和三个web服务 1 对反向代理服务器进行配置 #!/bin/bash #修改用户交互页面 用户输入参数执行相应的参数 #安装epel扩展包和nginx fun ...

  9. 利用Nginx实现反向代理web服务器

    一.Nginx简介 Nginx是一个很强大的高性能Web服务器和反向代理服务器,它具有很多非常优越的特性: 可以高并发连接 内存消耗少 成本低廉 配置文件非常简单 支持Rewrite重写 内置的健康检 ...

随机推荐

  1. < meta http-equiv = "X-UA-Compatible" content = "IE=edge,chrome=1" />的意义

    X-UA-Compatible是神马? X-UA-Compatible是IE8的一个专有<meta>属性,它告诉IE8采用何种IE版本去渲染网页,在html的<head>标签中 ...

  2. Linux命令大全总结

    目录方面的命令:ls,dir,cd,clear,mkdir ls 显示指定目录的文件和目录 ls -a 列出目录下的所有文件,包括以 . 开头的隐藏文件 ls -l 显示指定目录的详细列表 ls -R ...

  3. Unity琐碎(1) 编辑器参数修改

    今天在写编辑器面板的时候,突然发现如果面板参数变化的时候,不能实时修改表现效果(参数没有生效). public int monsterCount ; void Awake() { monsterCou ...

  4. Mac下配置apache

    一.前言 今天遇到问题,怎么配置apache在Mac上,原来Mac自带apache,只需要自己开启配置一下就行了. 二.步骤: 1.修改apache的http_conf文件 打开finder前往/pr ...

  5. js实现Mac触摸板双指事件(上/下/左/右/放大/缩小)

    前言 这几天在修复一个web问题时,需要捕获Mac触摸板双指事件(上.下.左.右.放大.缩小),但发现并没有现成的轮子,还是要自己造. 例如:jquery.mousewheel.js(添加跨浏览器的鼠 ...

  6. Java设计模式之八 ----- 责任链模式和命令模式

    前言 在上一篇中我们学习了结构型模式的享元模式和代理模式.本篇则来学习下行为型模式的两个模式, 责任链模式(Chain of Responsibility Pattern)和命令模式(Command ...

  7. HTML元素 - input type=hidden

    定义 传输关于客户/服务器交互的状态信息. Transmits state information about client/server interaction. 注释 这种输入类型用户无法控制,但 ...

  8. 手把手教你解析Resources.arsc

    http://blog.csdn.net/beyond702/article/details/51744082 一.前言 对于APK里面的Resources.arsc文件大家应该都知道是干什么的(不知 ...

  9. 一次ASM磁盘空间假装耗尽 ORA-15041: DISKGROUP SPACE EXHAUSTED

    给ASM磁盘新增一块盘进去,ASM_DISK2剩余空间四百多G: SQL> select * from v$asm_diskgroup;   GROUP_NUMBER NAME         ...

  10. 基于canvas图像处理的图片 灰色图像

    图片展示网页往往色彩繁杂,当一个网页上有多张图片的时候用户的注意力就很不容易集中,而且会造成网站整个色调风格的不可把控. 能不能把所有的预览图变成灰度图片,等用户激活某张图片的时候再上色呢? 以前,唯 ...