首页 > 代码库 > NFS共享web资源,DNS轮询实现Web负载均衡的小实验
NFS共享web资源,DNS轮询实现Web负载均衡的小实验
一、实验规划
二、实现步骤:
www1主机:
1、安装LAMP+NFS_DNS:
# yum install bind httpd mysql-server php php-mysql nfs-utlis rpcbind
2、设置httpd:
3、设置nfs:
echo "/var/www/html10.1.24.19/16(rw)" >> /etc/exports service start rpcbind && service start nfs
3、设置mysql:
mysql> GRANT ALL ON *.* TO ‘hill‘@‘%‘ IDENTIFIED BY ‘123456‘; Query OK, 0 rows affected (0.00 sec) mysql> GRANT ALL ON *.* TO ‘hill‘@‘localhost‘ IDENTIFIED BY ‘123456‘; Query OK, 0 rows affected (0.00 sec) mysql> GRANT ALL ON *.* TO ‘hill‘@‘127.0.0.1‘ IDENTIFIED BY ‘123456‘; Query OK, 0 rows affected (0.00 sec) mysql> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.00 sec)
4、配置DNS
添加域
[root@localhost named]# tail -14 /etc/named.conf zone "hillboy.com" IN { type master; file "hillboy.zone"; }; include "/etc/named.rfc1912.zones"; include "/etc/named.root.key";
添加RR:
[root@localhost named]# cat /var/named/hillboy.zone $TTL 86400 @INSOAns.hillboy.com.admin.hillboy.com. ( 1015 1H 30M 1W 1D ) @INNSns.hillboy.com. nsINA10.1.24.18 wwwINA10.1.24.18 wwwINA10.1.24.19
WWW1已经配置完成,下面配置WWW2
1、搭建LAMP环境,修改httpd的根目录为/var/www/html,并且添加支持index.php
2、挂载NFS文件系统
[root@localhost html]# mount -t nfs 10.1.24.18:/var/www/html /var/www/html/ [root@localhost html]# ls index.php pma
客户机测试:
1、修改DNS服务器为10.1.24.18
[23:32 root@centos6.8~]# cat /etc/resolv.conf ; generated by /sbin/dhclient-script nameserver 10.1.24.18
2、访问测试,已经能正常轮询
[23:32 root@centos6.8~]# ping www.hillboy.com PING www.hillboy.com (10.1.24.19) 56(84) bytes of data. 64 bytes from 10.1.24.19: icmp_seq=1 ttl=64 time=2.90 ms 64 bytes from 10.1.24.19: icmp_seq=2 ttl=64 time=0.869 ms 64 bytes from 10.1.24.19: icmp_seq=3 ttl=64 time=0.945 ms 64 bytes from 10.1.24.19: icmp_seq=4 ttl=64 time=0.953 ms ^C --- www.hillboy.com ping statistics --- 4 packets transmitted, 4 received, 0% packet loss, time 12032ms rtt min/avg/max/mdev = 0.869/1.416/2.900/0.858 ms [23:32 root@centos6.8~]# ping www.hillboy.com PING www.hillboy.com (10.1.24.18) 56(84) bytes of data. 64 bytes from 10.1.24.18: icmp_seq=1 ttl=64 time=1.27 ms 64 bytes from 10.1.24.18: icmp_seq=2 ttl=64 time=0.492 ms ^C --- www.hillboy.com ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 6064ms rtt min/avg/max/mdev = 0.492/0.883/1.275/0.392 ms
3、测试成功
[23:41 root@centos6.8~]# mtr www.hillboy.com -r HOST: centos6.8 Loss% Snt Last Avg Best Wrst StDev 1. 10.1.24.18 0.0% 10 0.6 0.5 0.5 0.6 0.0 [23:44 root@centos6.8~]# mtr www.hillboy.com -r HOST: centos6.8 Loss% Snt Last Avg Best Wrst StDev 1. 10.1.24.19 0.0% 10 1.0 1.0 0.9 1.0 0.0
这里只用了两台机器实验,还可以规划mysql为一台机器实现共享,web后端资源实现共享,DNS单独一台机器。
本文出自 “6638225” 博客,转载请与作者联系!
NFS共享web资源,DNS轮询实现Web负载均衡的小实验
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。