一、實驗環境準備
三臺CentOS6.5 64位虛擬機命名爲Director,RS1,RS2.具體配置如下。
1、網絡配置
(1)director。兩塊虛擬網卡。一塊eth1網絡配置模式爲橋接模式,一塊eth2僅主機模式。
eth1:
eth2:
(2) Real Server
RS1:配置爲橋接模式,網關地址設爲director的eth2。安裝httpd服務。
RS2:與RS1配置相同,地址爲192.168.64.103。安裝httpd服務。
2、軟件配置
(1)director.
安裝ipvsadm。
添加集羣:
ipvsadm -A -t 192.168.1.231:80 -s rr。
添加RS:
ipvsadm -a -t 192.1681.231:80 -r 192.168.64.102 -m
ipvsadm -a -t 192.1681.231:80 -r 192.168.64.103 -m
查看:
ipvsadm -L
(2)Real Server配置。
在RS1下的http服務路徑/var/www/html下建立文件index.html內容爲"This is RS1 server",並啓動http服務。
RS2同樣的操作,index.html內容爲“this is RS2 server”。
三、測試
在192.168.1.0,這個網絡訪問http://192.168.1.231。可以看到現實內容的隨着每次刷新在變化,說明已經成功。