試用keepalived來做雙機熱備,伺服器資訊如下:
伺服器1:centos / 192.168.18.20 [ip] / 192.168.18.22 [虛擬ip]
伺服器2:centos / 192.168.18.21 [ip] / 192.168.18.22 [虛擬ip]
1. 安裝keepalived
2臺server都使用下面的命令安裝keepalived:
yum install keepalived -y
2. server1 keepalived 配置$ vi /etc/keepalived/keepalived.conf
vrrp_instance vi_1
virtual_ipaddress
}
3. server2 keepalived 配置$ vi /etc/keepalived/keepalived.conf
vrrp_instance vi_1
virtual_ipaddress
}
4. 啟動keepalived$ service keepalived start
啟動keepalived後,可看到2臺server都繫結了虛擬ip:
$ ip a
# server 1:
2: eth0:
mtu 1500 qdisc pfifo_fast state up qlen 1000
link/ether 00:24:8c:8c:67:43 brd ff:ff:ff:ff:ff:ff
inet 192.168.18.20/24 brd 192.168.18.255 scope global eth0
inet 192.168.18.22/32 scope global eth0
inet6 fe80::224:8cff:fe8c:6743/64 scope link
valid_lft forever preferred_lft forever
# server 2:
2: eth0:
mtu 1500 qdisc pfifo_fast state up qlen 1000
link/ether 00:23:54:bf:ab:17 brd ff:ff:ff:ff:ff:ff
inet 192.168.18.21/24 brd 192.168.18.255 scope global eth0
inet 192.168.18.22/32 scope global eth0
inet6 fe80::223:54ff:febf:ab17/64 scope link
valid_lft forever preferred_lft forever
5. 測試
瀏覽器訪問出現 this is server 1.
將192.168.18.20關閉,再訪問出現this is server 2.
Nginx keepalived實現雙機熱備部署
一 安裝必要的軟體包,以保證nginx和keepalived能安裝 yum y install gcc gcc c make yum y install pcre devel 安裝nginx的依賴軟體包 yum y install openssl devel 安裝keepalived依賴軟體包 yu...
Keepalived實現雙機熱備
一 主機從機都安裝keepalived 1.安裝 yum install y keepalived 2.備份 cd etc keepalived cp keepalived.conf keepalived.conf.back 二 主機配置並啟動 1.建立配置檔案 echo configuration...
mySQL雙機冗餘 MySQL雙機熱備實現原理
雙機熱備是應用於伺服器的一種解決方案,其構造思想是主機和從機通過tcp ip網路連線,正常情況下主機處於工作狀態,從機處於監視狀態,一旦從機發現主機異常,從機將會在很短的時間之內代替主機,完全實現主機的功能。mysql資料庫提供了一種主從備份的機制,其實就是把主資料庫的所有的資料同時寫到備份的資料庫...