1.nginx web 安装 配置 

#systemctl stop firewalld
#systemctl disabled firewalld
#wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
#yum install nginx -y
#echo "welcome to china" >/usr/share/nginx/html/index.html
#systemctl start nginx.service
#curl 192.168.16.95
welcome to china

2.nginx proxy

proxy              192.168.16.95
web01 192.168.16.186
web02 192.168.16.187 #web01操作
[root@web01 ~]# yum install nginx -y
[root@web01 ~]# echo "welcome to web01" >/usr/share/nginx/html/index.html
[root@web01 ~]# systemctl start nginx.service
[root@web01 ~]# curl 192.168.16.186
welcome to web01 #web02操作
[root@web02 ~]# systemctl stop firewalld
[root@web02 ~]# echo "welcome to web02" >/usr/share/nginx/html/index.html
[root@web02 ~]# systemctl start nginx.service
[root@web02 ~]# curl 192.168.16.187
welcome to web02 #proxy 操作
[root@proxy ~]# vim /etc/nginx/nginx.conf
http {
upstream web {
server 192.168.16.186;
server 192.168.16.187;
} server {
listen 80; location / {
proxy_pass http://web;
}
}
}
[root@proxy ~]# systemctl reload nginx.service #其它服务器curl
bogon:~ centos$ curl 192.168.16.95
welcome to web01
bogon:~ centos$ curl 192.168.16.95
welcome to web02

2.nginx 调度  轮询  权重  hash

#轮询
http {
upstream myapp1 {
server srv1.example.com;
server srv2.example.com;
server srv3.example.com;
} server {
listen 80; location / {
proxy_pass http://myapp1;
}
}
} #权重
http {
upstream myapp1 {
server srv1.example.com weight=3;
server srv2.example.com;
server srv3.example.com;
}
server {
listen 80; location / {
proxy_pass http://myapp1;
}
}
} #hash http {
upstream myapp1 {
ip_hash;
server srv1.example.com;
server srv2.example.com;
server srv3.example.com;
}
server {
listen 80; location / {
proxy_pass http://myapp1;
}
}
}

4.nfs服务

#环境准备
nfs服务端 192.168.16.95
web01 192.168.16.186
web02 192.168.16.187 #nfs服务端
[root@proxy ~]# cat /etc/exports
/share 192.168.16.0/24(rw,sync,fsid=0)
[root@proxy ~]# mkdir /share
[root@proxy ~]# chmod o+w /share
[root@proxy ~]# cat /etc/exports
/share 192.168.16.0/24(rw,sync,fsid=0)
[root@proxy ~]# mkdir /share
[root@proxy ~]# chmod o+w /share
[root@proxy ~]# systemctl start rpcbind.service
[root@proxy ~]# systemctl start nfs-server.service
[root@proxy ~]# echo "192.168.16.95 proxy" >>/etc/hosts
[root@proxy ~]# exportfs
/share 192.168.16.0/24
[root@proxy ~]# showmount -e
Export list for proxy:
/share 192.168.16.187/24,192.168.16.186/24 #web01 操作
[root@bogon ~]# yum install rpcbind nfs-utils -y
[root@web01 ~]# systemctl start rpcbind.service
[root@web01 ~]# systemctl start nfs-server.service
[root@web01 ~]# showmount -e 192.168.16.95
Export list for 192.168.16.95:
/share 192.168.16.187/24,192.168.16.186/24
[root@web01 ~]# mount -t nfs 192.168.16.95:/share /usr/share/nginx/html/
[root@web01 ~]# df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/mapper/cl-root 18G 4.6G 13G 26% /
devtmpfs 473M 0 473M 0% /dev
tmpfs 489M 0 489M 0% /dev/shm
tmpfs 489M 7.1M 482M 2% /run
tmpfs 489M 0 489M 0% /sys/fs/cgroup
/dev/sda1 509M 169M 341M 34% /boot
tmpfs 98M 0 98M 0% /run/user/0
192.168.16.95:/share 18G 5.0G 13G 29% /usr/share/nginx/html #web02 操作
[root@bogon ~]# yum install rpcbind nfs-utils -y
[root@web02 ~]# systemctl start rpcbind.service
[root@web02 ~]# systemctl start nfs-server.service
[root@web02 ~]# showmount -e 192.168.16.95
Export list for 192.168.16.95:
/share 192.168.16.187/24,192.168.16.186/24
[root@web01 ~]# mount -t nfs 192.168.16.95:/share /usr/share/nginx/html/
[root@web02 ~]# mount -t nfs 192.168.16.95:/share /usr/share/nginx/html/
[root@web02 ~]# df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/mapper/cl-root 18G 4.6G 13G 26% /
devtmpfs 473M 0 473M 0% /dev
tmpfs 489M 0 489M 0% /dev/shm
tmpfs 489M 7.1M 482M 2% /run
tmpfs 489M 0 489M 0% /sys/fs/cgroup
/dev/sda1 509M 169M 341M 34% /boot
tmpfs 98M 0 98M 0% /run/user/0
192.168.16.95:/share 18G 5.0G 13G 29% /usr/share/nginx/html #proxy创建文件 web01 web02 查看
[root@proxy share]# echo "Nginx" >/share/index.html [root@web01 html]# cat /usr/share/nginx/html/index.html
Nginx [root@web02 ~]# cat /usr/share/nginx/html/index.html
Nginx

5.nginx反向代理+两台web+nfs共享存储实现集群配置

#在实验2和3的基础上

#在浏览器上访问proxy 192.168.16.95

#在web01上查看
[root@web01 html]# tail -f /var/log/nginx/access.log
192.168.16.95 - - [20/Mar/2017:17:10:21 +0800] "GET / HTTP/1.0" 304 0 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36" "-" #在web02上查看
[root@web02 html]# tail -f /var/log/nginx/access.log
192.168.16.95 - - [20/Mar/2017:17:10:17 +0800] "GET / HTTP/1.0" 200 6 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36" "-" #浏览器访问proxy,后端的两台nginx会轮询得到nfs服务器的文件

  

6. 源码安装nginx

[root@web01 html]#yum remove nginx
[root@web01 html]#useradd -s /sbin/nologin -M www
[root@web01 html]#yum -y install pcre pcre-devel openssl openssl-devel
[root@web01 html]#wget http://nginx.org/download/nginx-1.10.3.tar.gz
[root@web01 ~]# tar xf nginx-1.10.3.tar.gz
[root@web01 nginx-1.10.3]# cd nginx-1.10.3/
[root@web01 nginx-1.10.3]#./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_ssl_module --with-http_stub_status_module --with-file-aio --with-stream
[root@web01]#make && make install
[root@web01~]#/usr/local/nginx/sbin/nginx -t
[root@web01~]#nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
[root@web01~]#nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@web01 ~]# echo "Hello Word" > /usr/local/nginx/html/index.html
[root@web01 ~]# /usr/local/nginx/sbin/nginx
[root@web01 ~]# curl 192.168.16.186
Hello Word

  

Nginx web proxy NFS服务的更多相关文章

  1. Windows下Nginx+Web.py+FastCGI服务搭建

    在搭建之前,有必要了解下什么是fastcgi,但鉴于我自己也不大了解,这里就不搬门弄斧了,请参考各种百科和官网资料. 1.资源下载 python下载地址:戳这里webpy下载地址:戳这里flup下载地 ...

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

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

  3. linux---nginx服务nfs服务nginx反向代理三台web

    一:nginx服务 1.二进制安装nginx包 [root@bogon ~]# systemctl disable firewalld #关闭Firewalls自启动 Removed symlink ...

  4. 07 nginx反向代理和nfs服务

    作业一:nginx服务二进制安装nginx包 作为web服务修改配置文件 让配置生效,验证配置 作业二:nfs服务二进制安装nfs作为共享存储挂载在三台web的网站根目录下实现,在任意一台web上修改 ...

  5. day10 nfs服务,nginx负载均衡,定时任务

    ==================nginx 负载均衡==================== 实现nginx负载均衡的效果,并运用nfs服务共享目录,使所有nginx服务拥有共同的http目录 n ...

  6. nginx nfs服务

    一.nginx服务 1.二进制安装nginx包 [root@bogon ~]# ls /etc/yum.repos.d/ [root@bogon ~]# cd /etc/yum.repos.d/ [r ...

  7. 2-4、nginx特性及基础概念-nginx web服务配置详解

    Nginx Nginx:engine X 调用了libevent:高性能的网络库 epoll():基于事件驱动event的网络库文件 Nginx的特性: 模块化设计.较好扩展性(不支持模块动态装卸载, ...

  8. Linux实战教学笔记37:企业级Nginx Web服务优化实战(上)

    一,Nginx基本安全优化 1.1 调整参数隐藏Nginx软件版本号信息 一般来说,软件的漏洞都和版本有关,这个很像汽车的缺陷,同一批次的要有问题就都有问题,别的批次可能就都是好的.因此,我们应尽量隐 ...

  9. linux基础之nginx和nfs服务

      第一部分: 一.nginx服务安装nginx包(源码安装)1.先cd /etc/yum.repos.d目录下2.yum install epel-release -y(安装扩展包)3.yum in ...

随机推荐

  1. BZOJ2565:最长双回文串——题解

    http://www.lydsy.com/JudgeOnline/problem.php?id=2565 题目大意: 顺序和逆序读起来完全一样的串叫做回文串.比如acbca是回文串,而abc不是(ab ...

  2. [BZOJ1131/POI2008]Sta树的深度

    Description 给出一个N个点的树,找出一个点来,以这个点为根的树时,所有点的深度之和最大 Input 给出一个数字N,代表有N个点.N<=1000000 下面N-1条边. Output ...

  3. bzoj3232

    Description DZY家的后院有一块地,由N行M列的方格组成,格子内种的菜有一定的价值,并且每一条单位长度的格线有一定的费用. DZY喜欢在地里散步.他总是从任意一个格点出发,沿着格线行走直到 ...

  4. YBT 5.2 树形动态规划

    题解在代码中 二叉苹果树[loj 10153] /* 若要留q条边便是要留q+1个点 所以记忆化搜索 dp[pos][ans]=max(dp[pos][ans],dp[l[pos]][k]+dp[r[ ...

  5. 禁用 nouveau 驱动

    安装Nvidia显卡的官方驱动和系统自带的nouveau驱动冲突. 安装网上方法尝试了modprob.d/blacklist.conf里的各种修改,重启以后还是没有成功警用nouveau驱动 最后看见 ...

  6. Activity及Intent

    1.Activity 在一个Android应用程序中,Activity是为用户操作而展示的可视化界面.比如你要打电话,这个时候的拨号界面就是一个Activity,你要发短信给你的女朋友,这个短信窗口就 ...

  7. SpringMVC 用注解Annotation驱动的IoC功能@Autowired @Component

    转载自:http://blog.csdn.net/lufeng20/article/details/7598564 本文分为三个部分:概述.使用注解进行属性注入.使用注解进行Bean的自动定义. 一, ...

  8. 如何在阿里云服务器部署Django

    这段时间一直在搞我的网站——大学易,一个大学生评课网站,主要是提供课程的详尽信息(比如老师会不会经常点名,有没有期中考试),课程资料的下载等等. 这篇文章主要是分享给那些菜鸟,就是像我一样完全没有搞过 ...

  9. 51nod 1284 2 3 5 7的倍数 | 容斥原理

    用容斥原理求出不满足条件的个数cnt,然后用n-cnt就得到答案了. 这里不满条件的数就是能整除2,3,5,7这些数的集合并集.要计算几个集合并集的大小,我们要先将所有单个集合的大小计算出来,然后减去 ...

  10. 【设计模式】 模式PK:代理模式VS装饰模式

    1.概述 对于两个模式,首先要说的是,装饰模式就是代理模式的一个特殊应用,两者的共同点是都具有相同的接口,不同点则是代理模式着重对代理过程的控制,而装饰模式则是对类的功能进行加强或减弱,它着重类的功能 ...