keepalived 是 Router 的 VRRP 一樣 .......只管 IP 的 HA ....
不管幾台 Server 做 HA 都可 . 它的運作如同 VRRP 一樣 ........
二話不說 兩台都裝 keepalived
apt-get install keepalived
設定第一台(priority 100)
/etc/keepalived/keepalived.conf
-------------------------------------------
! Configuration File for keepalived
vrrp_instance VI_1 {
state MASTER
interface eth0
virtual_router_id 51
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1234567890
}
virtual_ipaddress {
192.168.0.220
}
}
-------------------------------------------
重啟服務 /etc/init.d/keepalived restart
檢查服務
root@linux-ad3:~# ip addr |grep 220
inet 192.168.0.220/32 scope global eth0
............
設定第二台 (priority 150)
/etc/keepalived/keepalived.conf
-------------------------------------------
! Configuration File for keepalived
vrrp_instance VI_1 {
state MASTER
interface eth0
virtual_router_id 51
priority 150
advert_int 1
authentication {
auth_type PASS
auth_pass 1234567890
}
virtual_ipaddress {
192.168.0.220
}
}
-------------------------------------------
重啟服務 /etc/init.d/keepalived restart
檢查服務
root@linux-ad4:~# ip addr |grep 220
inet 192.168.0.220/32 scope global eth0
............
重啟兩台 Server ....
檢查兩台的 Zentyal 服務 是否有用 VRRP 帶起 ...
netstat -nat |grep 220
tcp 0 0 192.168.0.220:3268 0.0.0.0:* LISTEN
tcp 0 0 192.168.0.220:3269 0.0.0.0:* LISTEN
tcp 0 0 192.168.0.220:389 0.0.0.0:* LISTEN
tcp 0 0 192.168.0.220:135 0.0.0.0:* LISTEN
tcp 0 0 192.168.0.220:139 0.0.0.0:* LISTEN
tcp 0 0 192.168.0.220:464 0.0.0.0:* LISTEN
tcp 0 0 192.168.0.220:53 0.0.0.0:* LISTEN
tcp 0 0 192.168.0.220:88 0.0.0.0:* LISTEN
tcp 0 0 192.168.0.220:636 0.0.0.0:* LISTEN
tcp 0 0 192.168.0.220:445 0.0.0.0:* LISTEN
tcp 0 0 192.168.0.220:1024 0.0.0.0:* LISTEN
發現只有 第一台的 DNS 會起不來
administrator@linux-ad4:~$ netstat -nat |grep 220
tcp 0 0 192.168.0.220:3268 0.0.0.0:* LISTEN
tcp 0 0 192.168.0.220:3269 0.0.0.0:* LISTEN
tcp 0 0 192.168.0.220:389 0.0.0.0:* LISTEN
tcp 0 0 192.168.0.220:135 0.0.0.0:* LISTEN
tcp 0 0 192.168.0.220:139 0.0.0.0:* LISTEN
tcp 0 0 192.168.0.220:464 0.0.0.0:* LISTEN
tcp 0 0 192.168.0.220:88 0.0.0.0:* LISTEN
tcp 0 0 192.168.0.220:636 0.0.0.0:* LISTEN
tcp 0 0 192.168.0.220:445 0.0.0.0:* LISTEN
tcp 0 0 192.168.0.220:1024 0.0.0.0:* LISTEN
.....
改 /usr/share/perl5/EBox/Samba/SetUidGidNumbers.pm
用 vi 找 Samba uid and gid number check daemon started
找到 ---> EBox::info("Samba uid and gid number check daemon started");
在這前加入兩行
EBox::info("DNS restart by chio");
EBox::Sudo::system("/etc/init.d/bind9 restart");
.....................
/var/log/zentyal/zentyal.log 會看到 ...
SetUidGidNumbers.pm:196 EBox::Samba::SetUidGidNumbers::run - DNS restart by chio
--------------------------------
這時 dns 會有所有資訊 ....
像這樣子 VIP 綁到所有機器上了
root@linux-ad3:~# nslookup
> linux-ad3
Server: 127.0.0.1
Address: 127.0.0.1#53
Name: linux-ad3.tw2.com
Address: 192.168.0.220
Name: linux-ad2.tw2.com
Address: 192.168.0.2
> linux-ad3
Server: 127.0.0.1
Address: 127.0.0.1#53
Name: linux-ad3.tw2.com
Address: 192.168.0.220
Name: linux-ad3.tw2.com
Address: 192.168.0.1
每台機器都要設 hosts 資訊 (包含 windows 也要設)
像這樣子 ....複寫就會成功 ......
192.168.0.1 linux-ad3.tw.nzgft linux-ad3
192.168.0.2 linux-ad2.tw.nzgft linux-ad2
其實不加也可 ...過一下子 DNS 的 VIP 會綁在運作的 機器上
另一台會消失 .....複寫就正常了 ...但 HA 切換又發生問題了 ...寫了沒壞處
留言列表