作业一:nginx服务
1.二进制安装nginx

2.作为web服务修改配置文件

3.让配置生效,验证配置

 [root@localhost ~]# systemctl stop firewalld.service
[root@localhost ~]# setenforce 0 
[root@localhost ~]# sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/sysconfig/selinux 

[root@localhost ~]# yum install -y epel-release
[root@localhost ~]# yum install -y nginx 

作为web服务修改配置文件
在server中location中加(更改网站根目录)
        location / {
            root /var/www/html;
            index index.html;
        }
[root@localhost nginx]# mkdir /var/www/html -p
[root@localhost nginx]# echo web1 > /var/www/html/index.html 

[root@localhost nginx]# systemctl start nginx.service 
[root@localhost nginx]#  systemctl reload nginx.service 
[root@localhost nginx]# netstat -lntup |grep nginx 
[root@localhost nginx]#  systemctl enable nginx.service 

让配置生效,验证配置
浏览器访问 http://192.168.2.2

[root@localhost nginx]# curl http://127.0.0.1
web1
[root@localhost nginx]# curl http://192.168.2.2
web1

作业二:nfs服务
二进制安装nfs
作为共享存储挂载在三台web的网站根目录下
实现,在任意一台web上修改的结果,其余两台都可以看到

 nfs服务器: 192.168.2.2
yum -y install rpcbind nfs-utils
[root@bogon ~]#  systemctl enable rpcbind.service
[root@bogon ~]# systemctl start rpcbind.service
[root@bogon ~]# cat /etc/exports
/share 192.168.2.0/24(rw,sync)
[root@bogon ~]# chmod -R o+rwx /share
[root@bogon ~]# systemctl enable nfs-server.service
[root@bogon ~]# systemctl start nfs-server.service
[root@bogon ~]# showmount -e 127.0.0.1
Export list for 127.0.0.1:
/share 192.168.2.0/24
[root@bogon ~]# exportfs
/share         192.168.2.0/24

web1服务器:192.168.2.3
yum -y install rpcbind nfs-utils
[root@bogon ~]#  systemctl enable rpcbind.service
[root@bogon ~]# systemctl start rpcbind.service
[root@bogon ~]# showmount -e 192.168.2.2
Export list for 192.168.2.2:
/share 192.168.2.0/24
[root@bogon ~]# mkdir /var/www/html/share -p
[root@bogon ~]# mount -t nfs 192.168.2.2:/share  /var/www/html/share/
[root@bogon ~]# df -h 
文件系统                 容量  已用  可用 已用% 挂载点
/dev/mapper/centos-root   18G  4.8G   13G   28% /
devtmpfs                 222M     0  222M    0% /dev
tmpfs                    237M     0  237M    0% /dev/shm
tmpfs                    237M  5.0M  233M    3% /run
tmpfs                    237M     0  237M    0% /sys/fs/cgroup
/dev/sda1                497M  159M  339M   32% /boot
tmpfs                     48M     0   48M    0% /run/user/0
tmpfs                     48M     0   48M    0% /run/user/1000
192.168.2.2:/share        18G  4.8G   13G   28% /var/www/html/share

web2服务器:192.168.2.4
yum -y install rpcbind nfs-utils
[root@bogon ~]#  systemctl enable rpcbind.service
[root@bogon ~]# systemctl start rpcbind.service
[root@bogon ~]# showmount -e 192.168.2.2
Export list for 192.168.2.2:
/share 192.168.2.0/24
[root@bogon ~]# mkdir /var/www/html/share -p
[root@bogon ~]# mount -t nfs 192.168.2.2:/share  /var/www/html/share/
[root@bogon ~]# df -h 
文件系统                 容量  已用  可用 已用% 挂载点
/dev/mapper/centos-root   18G  4.8G   13G   28% /
devtmpfs                 222M     0  222M    0% /dev
tmpfs                    237M     0  237M    0% /dev/shm
tmpfs                    237M  5.0M  233M    3% /run
tmpfs                    237M     0  237M    0% /sys/fs/cgroup
/dev/sda1                497M  159M  339M   32% /boot
tmpfs                     48M     0   48M    0% /run/user/0
tmpfs                     48M     0   48M    0% /run/user/1000
192.168.2.2:/share        18G  4.8G   13G   28% /var/www/html/share

web3服务器:192.168.2.5
yum -y install rpcbind nfs-utils
[root@bogon ~]#  systemctl enable rpcbind.service
[root@bogon ~]# systemctl start rpcbind.service
[root@bogon ~]# showmount -e 192.168.2.2
Export list for 192.168.2.2:
/share 192.168.2.0/24
[root@bogon ~]# mkdir /var/www/html/share -p
[root@bogon ~]# mount -t nfs 192.168.2.2:/share  /var/www/html/share/
[root@bogon ~]# df -h 
文件系统                 容量  已用  可用 已用% 挂载点
/dev/mapper/centos-root   18G  4.8G   13G   28% /
devtmpfs                 222M     0  222M    0% /dev
tmpfs                    237M     0  237M    0% /dev/shm
tmpfs                    237M  5.0M  233M    3% /run
tmpfs                    237M     0  237M    0% /sys/fs/cgroup
/dev/sda1                497M  159M  339M   32% /boot
tmpfs                     48M     0   48M    0% /run/user/0
tmpfs                     48M     0   48M    0% /run/user/1000
192.168.2.2:/share        18G  4.8G   13G   28% /var/www/html/share

测试:
web1:
[root@bogon share]# echo "123" > /var/www/html/share/1.txt
web2:
[root@bogon ~]# cat /var/www//html/share/1.txt 
123
web3:
[root@bogon ~]# cat /var/www//html/share/1.txt 
123

作业三:nginx反向代理三台web
实现基于轮询的方式调度三台web,并验证结果
实现基于权重的方式调度三台web,并验证结果
实现基于hash的方式调用三台web,并验证结果

 (1)
Nginx反向代理:实现基于轮询的方式
http {
    upstream  pythonweb{
       server 192.168.2.3:80;
       server 192.168.2.4:80;
       server 192.168.2.5:80;
    }
  server{
   location / {
     proxy_pass http://pythonweb;
   }
  }
[root@bogon ~]# systemctl reload nginx.service 
[root@bogon ~]# systemctl restart nginx.service 
(2)
Nginx反向代理:实现基于权重的方式
http {
    upstream  pythonweb{
       server 192.168.2.3:80  weight=3;
       server 192.168.2.4:80;
       server 192.168.2.5:80;
    }
  server{
   location / {
     proxy_pass http://pythonweb;
   }
  }
[root@bogon ~]# systemctl reload nginx.service 
[root@bogon ~]# systemctl restart nginx.service 

(2)
Nginx反向代理:实现基于权重的方式
http {
    upstream  pythonweb{
       ip_hash;
       server 192.168.2.3:80;
       server 192.168.2.4:80;
       server 192.168.2.5:80;
    }
  server{
   location / {
     proxy_pass http://pythonweb;
   }
  }
[root@bogon ~]# systemctl reload nginx.service 
[root@bogon ~]# systemctl restart nginx.service 

作业四:nginx反向代理+三台web+nfs共享存储实现集群配置

 作业2中nfs共享的目录是/var/www/html/share

作业3中nginx反向代理+3台web发布的目录是/var/www/html
将3台web的发布目录修改即可:
作为web服务修改配置文件
在server中location中加(更改网站根目录)
        location / {
            root /var/www/html/share;
            index index.html;
        }
[root@bogon share]# cat /var/www/html/share/index.html 
web123
[root@bogon html]# systemctl restart nginx.service 
浏览器测试

作业五:源码安装nginx,并按照作业一描述的那样去测试使用

 [root@bogon ~]# mkdir /application
[root@bogon ~]# yum erase nginx  -y
[root@bogon ~]# yum install gcc-* glibc-* openssl openssl-devel pcre pcre-devel zlib zlib-devel -y
[root@bogon ~]# wget http://nginx.org/download/nginx-1.11.10.tar.gz
[root@bogon ~]# tar xf nginx-1.11.10.tar.gz 
[root@bogon ~]#cd nginx-1.11.10/
[root@bogon nginx-1.11.10]# ls -l 
总用量 704
drwxr-xr-x. 6 1001 1001   4096 3月  20 19:34 auto
-rw-r--r--. 1 1001 1001 274992 2月  14 23:36 CHANGES
-rw-r--r--. 1 1001 1001 419007 2月  14 23:36 CHANGES.ru
drwxr-xr-x. 2 1001 1001   4096 3月  20 19:34 conf
-rwxr-xr-x. 1 1001 1001   2481 2月  14 23:36 configure
drwxr-xr-x. 4 1001 1001     68 3月  20 19:34 contrib
drwxr-xr-x. 2 1001 1001     38 3月  20 19:34 html
-rw-r--r--. 1 1001 1001   1397 2月  14 23:36 LICENSE
drwxr-xr-x. 2 1001 1001     20 3月  20 19:34 man
-rw-r--r--. 1 1001 1001     49 2月  14 23:36 README
drwxr-xr-x. 9 1001 1001     84 3月  20 19:34 src
./configure --sbin-path=/application/nginx/nginx --conf-path=/application/nginx/nginx.conf --pid-path=/application/nginx/nginx.pid --with-http_ssl_module
make
make install
启动:/application/nginx/nginx
检测:/application/nginx/nginx -t
停止:/application/nginx/nginx -s stop
重载:/application/nginx/nginx -s reload 
配置文件:/application/nginx/nginx.conf 
vim /application/nginx/nginx.conf 
   location / {
            root   /var/www/html/share;
            index  index.html index.htm;
        }
重载:/application/nginx/nginx -s reload 
 

NFS, web,负载均衡,Nginx yum 源码安装的更多相关文章

  1. Nginx unit 源码安装初体验

    Nginx unit 源码安装初体验 上次介绍了从yum的安装方法(https://www.cnblogs.com/wang-li/p/9684040.html),这次将介绍源码安装,目前最新版为1. ...

  2. linux应用之nginx的源码安装及配置(centos)

    1.准备工作选首先安装这几个软件:GCC,PCRE(Perl Compatible Regular Expression),zlib,OpenSSL.Nginx是C写的,需要用GCC编译:Nginx的 ...

  3. 关于nginx的源码安装方式

    Nginx(engine x)是一款是由俄罗斯的程序设计师Igor Sysoev所开发高性能的 Web和 反向代理 服务器, 也是一个 IMAP/POP3/SMTP 代理服务器.在高连接并发的情况下, ...

  4. 编译nginx的源码安装subs_filter模块

    使用nginx的反向代理功能搭建nuget镜像服务器时,需要针对官方nuget服务器的响应内容进行字符串替换,比如将www.nuget.org替换为镜像服务器的主机名,将https://替换为http ...

  5. nginx 的源码安装

    安装nginx之前要做的准备工作有:安装如下库 (1)gzip模块需要 zlib 库 (2)rewrite模块需要 pcre 库 (3)ssl 功能需要openssl库 还有一种简单的方法就是 yum ...

  6. 客户端负载均衡Ribbon之源码解析

    什么是负载均衡器? 假设有一个分布式系统,该系统由在不同计算机上运行的许多服务组成.但是,当用户数量很大时,通常会为服务创建多个副本.每个副本都在另一台计算机上运行.此时,出现 "Load ...

  7. ribbon负载均衡循环策略源码

    (原) 在用ribbon负载均衡取eureka注册中心中的地址时,默认采用循环策略,例如商品服务有3个,分别为URL1,URL2,URL3,那么在客户端第一次取时,会取到URL1,第二次取时取到URL ...

  8. Hbase负载均衡流程以及源码

    hmater负责把region均匀到各个region server .hmaster中有一个线程任务是专门处理负责均衡的,默认每隔5分钟执行一次. 每次负载均衡操作可以分为两步: 生成负载均衡计划表 ...

  9. zabbix,php,nginx,mysql源码安装 神仙操作

    →软件包 mkdir /soft/ cd /soft ♦下载以下软件包 nginx-1.14.2.tar.gz wget http://nginx.org/download/nginx-1.14.2. ...

随机推荐

  1. httplib和urllib2常用方法

    都是几年前用过的,现在翻出来记录一下. import httplib import urllib2 import socket ##---------------------------------- ...

  2. 软件测试4gkd

    一.性能测试有几种类型,它们之间什么关系? (1)性能测试包括:负载测试.压力测试.配置测试.并发测试.容量测试.可靠性测试.失败测试. 负载测试:通过逐渐增加系统的负载,测试系统性能的变化,并最终确 ...

  3. 快速签发 Let's Encrypt 证书指南

    本文仅记录给自己的网站添加"小绿锁"的动手操作过程,不涉及 HTTPS 工作原理等内容的讲解,感兴趣的同学可以参考篇尾的文章自行了解. 简单了解下我的实验环境: 云服务器:Cent ...

  4. 使用教育邮箱激活JetBrains全家桶

    如果你还有在校时的邮箱,比如your_name@xxx.edu或者your_name@xxx.edu.cn的邮箱,那么你可以免费激活JetBrains全家桶. JetBrains Toolbox 专业 ...

  5. Lintcode85-Insert Node in a Binary Search Tree-Easy

    85. Insert Node in a Binary Search Tree Given a binary search tree and a new tree node, insert the n ...

  6. matlab 入门

    ---恢复内容开始--- 1.cast表示将元素转化成对应的ASCII值 如cast('hellothere','uint8')输出结果为104 101 108 108 111 116 104 101 ...

  7. vue安装过后遇到的坑

    vue在所有配置文件安装过之后: 运行 npm run dev 不能自动打开浏览器,但是命令行中已经提示我们运行成功了 等很久也没有自动打开浏览器,必须要自己手动的输入地址. 那么我们如何在npm r ...

  8. C、C++中的static和extern关键字

    1.首先,关于声明和定义的区别 这种写法(函数原型后加;号表示结束的写法)只能叫函数声明而不能叫函数定义,只有带函数体的声明才叫定义,比如下面 只有分配存储空间的变量声明才叫变量定义,其实函数也是一样 ...

  9. swift 有道 翻译文档(1 定义变量常量,数组字典)

    使用let来创建常量,使用var来创建变量.一个常量的值在编译时不需要知道,但是您必须为它指定一个值一次.这意味着您可以使用常量来命名一个您确定一次的值,但是在许多地方使用它.var myVariab ...

  10. error CS1002: ; expected 错误解决

    一般出现这种错误,大概原因是因为前端页面里的C#代码少个分号,或少个括号 导致编译器出错:仔细检查页面中的C#代码是否写的正确. 我之所以出现这个错误是因为前台页面中:@{  } 这里的代码少一个括号 ...