1、實驗規劃php
2、實現步驟:html
www1主機:mysql
一、安裝LAMP+NFS_DNS:web
# yum install bind httpd mysql-server php php-mysql nfs-utlis rpcbind
二、設置httpd:sql
三、設置nfs:後端
echo "/var/www/html10.1.24.19/16(rw)" >> /etc/exports service start rpcbind && service start nfs
三、設置mysql:centos
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)
四、配置DNSbash
添加域服務器
[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:ide
[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
一、搭建LAMP環境,修改httpd的根目錄爲/var/www/html,而且添加支持index.php
二、掛載NFS文件系統
[root@localhost html]# mount -t nfs 10.1.24.18:/var/www/html /var/www/html/ [root@localhost html]# ls index.php pma
客戶機測試:
一、修改DNS服務器爲10.1.24.18
[23:32 root@centos6.8~]# cat /etc/resolv.conf ; generated by /sbin/dhclient-script nameserver 10.1.24.18
二、訪問測試,已經能正常輪詢
[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
三、測試成功
[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單獨一臺機器。
OK,更多文章請關注個人博客。