• nfs cron shell 作业


    作业一:
    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调度
    

      

  • 相关阅读:
    springboot + self4j 学习笔记
    git 创建本地分支,并且推送到远程分支
    windows 下生成 ssh key
    Topshelf
    ADSL拨号连接
    EF中使用Contains方法
    elasticsearch中的概念简述
    CriticalFinalizerObject的作用
    sqlserver中的统计语法
    Windbg简单介绍
  • 原文地址:https://www.cnblogs.com/morgana/p/6930447.html
Copyright © 2020-2023  润新知