作业一:
nginx反向代理三台web服务器,实现负载均衡
所有的web服务共享一台nfs的存储
2台服务器
nginx 【lb】 :101.200.206.6
nginx 【web】:101.200.169.119 准备环境:
分别在所有服务器执行
=======>part1:
iptables -F
#systemctl disable firewalld #开机默认关闭
#systemctl stop firewalld #立即关闭
#systemctl status firewalld setenforce 0
#/etc/sysconfig/selinux
#SELINUX=disabled
==========>part2:
安装程序
yum install rpcbind nfs-utils -y
yum install nginx -y
==========>part3: 【lb】
创建共享目录 mkdir /nfs
修改配置文件
[root@iZ25j36rr97Z nfs]# cat /etc/exports
/nfs *(rw,sync,fsid=0)
修改权限
chmod -R o+w /nfs
先为rpcbind和nfs做开机启动:
systemctl enable nfs-server.service
systemctl enable rpcbind.service
systemctl start rpcbind.service
systemctl start nfs-server.service
确认启动成功
[root@iZ25j36rr97Z nfs]# rpcinfo
program version netid address service owner
100000 4 tcp 0.0.0.0.0.111 portmapper superuser
100000 3 tcp 0.0.0.0.0.111 portmapper superuser
100000 2 tcp 0.0.0.0.0.111 portmapper superuser
100000 4 udp 0.0.0.0.0.111 portmapper superuser
100000 3 udp 0.0.0.0.0.111 portmapper superuser
100000 2 udp 0.0.0.0.0.111 portmapper superuser
100000 4 local /var/run/rpcbind.sock portmapper superuser
100000 3 local /var/run/rpcbind.sock portmapper superuser
100011 1 udp 0.0.0.0.3.107 rquotad superuser
100011 2 udp 0.0.0.0.3.107 rquotad superuser
100011 1 tcp 0.0.0.0.3.107 rquotad superuser
100011 2 tcp 0.0.0.0.3.107 rquotad superuser
100005 1 udp 0.0.0.0.169.8 mountd superuser
100005 1 tcp 0.0.0.0.202.245 mountd superuser
100005 2 udp 0.0.0.0.200.5 mountd superuser
100005 2 tcp 0.0.0.0.190.185 mountd superuser
100005 3 udp 0.0.0.0.236.40 mountd superuser
100005 3 tcp 0.0.0.0.152.224 mountd superuser
100003 2 tcp 0.0.0.0.8.1 nfs superuser
100003 3 tcp 0.0.0.0.8.1 nfs superuser
100003 4 tcp 0.0.0.0.8.1 nfs superuser
100227 2 tcp 0.0.0.0.8.1 nfs_acl superuser
100227 3 tcp 0.0.0.0.8.1 nfs_acl superuser
100003 2 udp 0.0.0.0.8.1 nfs superuser
100003 3 udp 0.0.0.0.8.1 nfs superuser
100003 4 udp 0.0.0.0.8.1 nfs superuser
100227 2 udp 0.0.0.0.8.1 nfs_acl superuser
100227 3 udp 0.0.0.0.8.1 nfs_acl superuser
100021 1 udp 0.0.0.0.134.187 nlockmgr superuser
100021 3 udp 0.0.0.0.134.187 nlockmgr superuser
100021 4 udp 0.0.0.0.134.187 nlockmgr superuser
100021 1 tcp 0.0.0.0.218.123 nlockmgr superuser
100021 3 tcp 0.0.0.0.218.123 nlockmgr superuser
100021 4 tcp 0.0.0.0.218.123 nlockmgr superuser
100024 1 udp 0.0.0.0.131.201 status 29
100024 1 tcp 0.0.0.0.206.148 status 29
[root@iZ25j36rr97Z nfs]# exportfs
/nfs <world>
默认查看自己共享的服务
[root@iZ25j36rr97Z nfs]# showmount -e
Export list for iZ25j36rr97Z:
/nfs *
[root@iZ25j36rr97Z nfs]#
修改【lb】 nginx配置
[root@iZ25j36rr97Z conf]# cat nginx.conf
worker_processes 1;
events {
worker_connections 1024;
}
http {
upstream nginxlb
{
server 101.200.206.67:8081;
server 101.200.169.119:8081;
server 101.200.169.119:8082;
}
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name 101.200.206.67;
location / {
proxy_pass http://nginxlb;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
server {
listen 8081;
server_name 101.200.206.67;
location / {
root html;
index nginx.txt index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
在根目录添加 nginx.txt
echo 'nginx' >nginx.txt
mount -t nfs 101.200.206.67:/nfs /home/service/nginx/html 客户端执行
yum install rpcbind nfs-utils -y
mount -t nfs 101.200.206.67:/nfs /home/service/nginx/html
修改nginx配置
[root@iZ2ze0sw83m5wno8bd2yudZ conf]# cat nginx.conf
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 8081;
server_name localhost;
location / {
root html;
index 8081.txt index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
[root@iZ2ze0sw83m5wno8bd2yudZ conf]# cat nginx1.conf
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 8082;
server_name localhost;
location / {
root html;
index 8082.txt index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
} echo '8081' >8081.txt
echo '8082' >8082.txt
启动服务端和客户端nginx
/home/service/nginx/sbin/nginx -c /home/service/nginx/conf/nginx.conf
/home/service/nginx/sbin/nginx -c /home/service/nginx/conf/nginx1.conf 在浏览器端查看轮询结果
3台web 依次被lb调度

  

nfs cron shell 作业的更多相关文章

  1. nfs cron shell 笔记

    1.nfs 2.crond 3.shell 1.准备环境: 防火墙 selinux 配置ip 2.安装软件 二进制 源码安装 3.改改配置文件 二进制:/etc/nginx/nginx.conf 源码 ...

  2. shell作业后台执行的方法

    来思考几种场景: 1.某个脚本需要执行时间比较长,无人值守,可能执行过程中因ssh会话超时而中断? 2.某次测试一段代码,需要临时放入后台运行? 3.放入后台运行的脚本,需要在一段时间后重新调到前台? ...

  3. shell作业01

    1.判断/etc/inittab文件是否大于100行,如果大于,则显示”/etc/inittab is a big file.”否者显示”/etc/inittab is a small file.” ...

  4. xv6的作业翻译——作业1 - shell和系统调用

    Xv6的lecture LEC 1 Operating systems   L1: O/S overview L1:O/S概述   * 6.828 goals 6.828的目标   Understan ...

  5. cron,linux定时脚本

    Linux的cron和crontab Cron定时执行工具详解 Linux下的crontab定时执行任务命令详解 Linux上启动Cron任务 [linux]解析crontab cron表达式详解 c ...

  6. Shell记录-Shell命令(定时任务)

    在Linux系统中, at 命令是针对仅运行一次的任务,循环运行的例行性计划任务,linux系统则是由 cron(crond) 这个系统服务来控制的.Linux 系统上面原本就有非常多的计划性工作,因 ...

  7. Ansible部署rsync、nfs及sersync

    rsync nfs sersync httpd环境: 角色 外网IP(NAT) 内网IP(LAN) 主机名 Rsync服务端 eth0:10.0.1.51 eth1:172.16.1.51 backu ...

  8. NFS网络文件共享服务

    NFS-网络文件系统,它的主要功能是通过网络让不同的主机系统之间可以彼此共享文件或目录. NFS在企业中得应用场景 在企业集群架构的工作场景中,NFS网络文件系统一般被用来存储共享视频.图片.附件等静 ...

  9. 【NFS】nfs安装调优

    nfs [root@flymaster ~]# rpm -qa nfs-utils rpcbindnfs-utils-1.2.3-75.el6.x86_64rpcbind-0.2.0-13.el6_9 ...

随机推荐

  1. Java基础(7)-集合类3

    list集合的特点 1)有序(存储和取出的元素一直) 2)可重复 List子类的特点 ArrayList 有序,可重复 底层数据结构是数组 查询快,增删慢 线程不安全,效率高 Vector 有序,可重 ...

  2. Codeforces Round #283 (Div. 2) E. Distributing Parts 贪心+set二分

    E. Distributing Parts time limit per test 2 seconds memory limit per test 256 megabytes input standa ...

  3. hdu 5876 Sparse Graph 无权图bfs求最短路

    Sparse Graph Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) P ...

  4. idel 中 生成 jar包 和项目中自己需要的包

    一.首先在自己的项目中创建一个类类中创建一个构造方法构造方法中传入一个字符串参数(这个字符串参数是为了传入路径) 在方法体内通过file类创建文件夹(换而言之就是项目中的包) 二 .就是对这个项目中的 ...

  5. Asp.net WebAPI 使用流下载文件注意事项

    public HttpResponseMessage Post(string version, string environment, string filetype) { var path = @& ...

  6. OpenStack日志搜集分析之ELK

    ELK 安装配置简单,用于管理 OpenStack 日志时需注意两点: Logstash 配置文件的编写 Elasticsearch 日志存储空间的容量规划 另外推荐 ELKstack 中文指南. E ...

  7. 魔术师发牌问题--java实现

    package com.wyl.linklist; /** **问题名称:魔术师发牌问题 *问题描述:魔术师手里一共有13张牌,全是黑桃,1~13. *********魔术师需要实现一个魔术:这是十三 ...

  8. DOM初体验(绑定事件,监听事件)

    JavaScript的组成: ECMAScript(js的基本语法).DOM(文档对象模型).BOM(浏览器对象模型) DOM的作用: 1. 找到页面上的元素 2. 增添.删除.修改页面上的元素 3. ...

  9. spring boot 基础篇 -- 集成接口测试Swagger

    一.在pom.xml加入Swagger jar包引入 <dependency> <groupId>io.springfox</groupId> <artifa ...

  10. MongoDB Wiredtiger存储引擎实现原理——Copy on write的方式管理修改操作,Btree cache

    转自:http://www.mongoing.com/archives/2540 传统数据库引擎的数据组织方式,一般存储引擎都是采用 btree 或者 lsm tree 来实现索引,但是索引的最小单位 ...