Day7.nfs服务以及nginx服务
作业一:nginx服务
二进制安装nginx包
作为web服务修改配置文件
让配置生效,验证配置
环境和nginx软件安装完毕,可以查看nginx.conf,不做修改退出
查看虚拟机的ip地址并关闭防火墙
打开浏览器输入ip地址+文件所在路径并回车
作业二:nfs服务
二进制安装nfs
作为共享存储挂载在三台web的网站根目录下
实现,在任意一台web上修改的结果,其余两台都可以看到
s
作业三:nginx反向代理三台web
实现基于轮询的方式调度三台web,并验证结果
http{
upstream pw {
server 192.168.0.101:80;
server 192.168.0.102:80;
}
}
location / {
proxy_pass http://pw;
}
实现基于权重的方式调度三台web,并验证结果
upstream pw {
#ip_hash;
server 192.168.0.101:80 weight=3;
server 192.168.0.102:80;
}
实现基于hash的方式调用三台web,并验证结果
upstream pw {
ip_hash;
server 192.168.0.101:80;
server 192.168.0.102:80;
}
systemctl reload nginx
作业四:nginx反向代理+三台web+nfs共享存储实现集群配置
作业五:源码安装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
[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 "liuxiaoyang" >> /usr/local/nginx/html/index.html
[root@web01 ~]# /usr/local/nginx/sbin/nginx
[root@web01 ~]# curl 192.168.16.195
liuxiaoyang