Python之路-Linux命令基础(5)
作业一:nginx服务 二进制安装nginx包
1.使用网络yum源
2.使用yum安装epel-release扩展源
[root@localhost html]# yum install epel-release -y
3.使用yum安装nginx服务。
[root@localhost html]# yum install nginx -y
4.作为web服务修改配置文件
[root@localhost html]# vim /etc/nginx/nginx.conf
5.进入网络根目录下,创建文件index.html,作为我们要访问的内容
[root@localhost html]# vim /usr/share/nginx/html/index.html
6.关闭防火墙
[root@localhost html]# systemctl stop firewalld
7.让配置生效,
[root@localhost html]# systemctl restart nginx
[root@localhost html]# systemctl status nginx
8.验证配置
作业二:nfs服务
1.二进制安装nfs
nfs是网络文件系统的缩写
[root@localhost nginx]# yum install rpcbind nfs-utils -y
2.修改配置文件
[root@localhost nginx]# vim /etc/exports
3.服务端配置
[root@localhost /]# mkdir /share
[root@localhost /]# cd /share
[root@localhost share]# touch share.txt
[root@localhost share]# echo welcome to beijing > share.txt
[root@localhost share]# cat share.txt
welcome to beijing
4.启动服务,验证共享文件( 必须先启动rpcbind服务)
[root@localhost share]# systemctl enable nfs-server.service
Created symlink from /etc/systemd/system/multi-user.target.wants/nfs-server.service to /usr/lib/systemd/system/nfs-server.service.
[root@localhost share]# systemctl enable rpcbind.service
[root@localhost share]# systemctl start rpcbind.service
[root@localhost share]# systemctl start nfs-server.service
[root@localhost share]# exportfs
/share 192.168.0.0/24
[root@localhost share]# showmount -e
Export list for localhost:
/share 192.168.0.0/24
5.作为共享存储挂载在三台web的网站根目录下
[root@localhost html]# showmount -e 192.168.0.107
Export list for 192.168.0.107:
/share 192.168.0.0/24
[root@localhost html]# mkdir -p /var/www/html
[root@localhost html]# mount -t nfs 192.168.0.107:/share /var/www/html
[root@localhost html]# ls /var/www/html/
share.txt
6.在服务端修改读写权限
[root@localhost ~]# chmod -R o+w /share
7.实现,在任意一台web上修改的结果,其余两台都可以看到
例如:web2上新建aaa.txt 在web3上立刻可以查看
作业三:nginx反向代理三台web
1.官方文档网址 http://nginx.org/en/docs/http/load_balancing.html
2.克隆出来三台web,在不同的服务器上创建的index.html内容不一样,依然创建在网站的根目录,因为我们未修改location中的root,所以采用全局的网站根目录
vim /usr/share/nginx/html/index.html
3.在代理的服务端的配置文件中,参照官网文档进行修改。
4.重新加载配置文件
systemctl reload nginx
5.实现基于轮询的方式调度三台web,并验证结果
默认是轮询方式
6.实现基于权重的方式调度三台web,并验证结果
7.实现基于hash的方式调用三台web,并验证结果
作业四:nginx反向代理+三台web+nfs共享存储实现集群配置
实现方式:我们同时拥有一台nginx反向代理服务器和三台web服务器,以及一台存储服务器。客户端发来的请求由反向代理服务端分给三台web服务器去处理数据,而作为客户端的用户,我们只是将请求递交给了反向代理服务器,并感受不到这种处理。而三台服务器上所使用的数据又是通过NFS共享存储技术共享在了一台存储的服务器上,导致不同的web服务器获取到的数据都是实时更新的,保证数据的有效可靠。等到处理完成,由nginx反向代理服务器把处理得到的数据传递回用户。
作业五:源码安装nginx
1.安装nginx所需要的包
[root@ym /]# yum install gcc-* glibc-* openssl openssl-devel pcre pcre-devel zlib zlib-devel -y
2.拖入文件后,解压缩

3.执行配置的可执行文件

4.配置相关参数
[root@ym nginx-1.10.3]# ./configure --sbin-path=/usr/local/nginx/nginx --conf-path=/usr/local/nginx/nginx.conf --pid-path=/usr/local/nginx/nginx.pid --with-http_ssl_module
5.编译和编译安装
[root@ym nginx-1.10.3]# make && make install
![Image[1] Image[1]](http://images2015.cnblogs.com/blog/1122619/201703/1122619-20170322011832377-689687878.png)
![Image(1)[1] Image(1)[1]](http://images2015.cnblogs.com/blog/1122619/201703/1122619-20170322011833643-370435354.png)
![Image(2)[1] Image(2)[1]](http://images2015.cnblogs.com/blog/1122619/201703/1122619-20170322011834549-1550907987.png)
![Image(3)[1] Image(3)[1]](http://images2015.cnblogs.com/blog/1122619/201703/1122619-20170322011836690-214235759.png)
![Image(4)[1] Image(4)[1]](http://images2015.cnblogs.com/blog/1122619/201703/1122619-20170322011839018-1824071920.png)
![Image(5)[1] Image(5)[1]](http://images2015.cnblogs.com/blog/1122619/201703/1122619-20170322011845440-1176225128.png)
![Image(6)[1] Image(6)[1]](http://images2015.cnblogs.com/blog/1122619/201703/1122619-20170322011849799-95213504.png)
![Image(7)[1] Image(7)[1]](http://images2015.cnblogs.com/blog/1122619/201703/1122619-20170322011852096-1957410375.png)
![Image(8)[1] Image(8)[1]](http://images2015.cnblogs.com/blog/1122619/201703/1122619-20170322011852986-462874078.png)
![Image(9)[1] Image(9)[1]](http://images2015.cnblogs.com/blog/1122619/201703/1122619-20170322011856143-2068543311.png)
![Image(10)[1] Image(10)[1]](http://images2015.cnblogs.com/blog/1122619/201703/1122619-20170322011900096-58883361.png)
![Image(11)[1] Image(11)[1]](http://images2015.cnblogs.com/blog/1122619/201703/1122619-20170322011903611-699170093.png)
![Image(12)[1] Image(12)[1]](http://images2015.cnblogs.com/blog/1122619/201703/1122619-20170322011905424-166567223.png)
![Image(13)[1] Image(13)[1]](http://images2015.cnblogs.com/blog/1122619/201703/1122619-20170322011906158-1677362423.png)
![Image(14)[1] Image(14)[1]](http://images2015.cnblogs.com/blog/1122619/201703/1122619-20170322011907518-2025677250.png)
浙公网安备 33010602011771号