keepalived(主主) 結合lvs(dr工作 模式) 實現高可用性。

keepalived(主主) 結合lvs(dr工作 模式) 實現高可用性。

client: 192.168.100.6
————————————————-

#for i in {1..10};do sleep 0.5;curl 192.168.100.200;done

proxy1: 192.168.100.7
————————————————–
vim /etc/keepalived/keepalived.conf –配置文件
vrrp_instance VI_1 { –主
state MASTER
interface eth1
virtual_router_id 66
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 123456
}
virtual_ipaddress {
192.168.100.100/24
}
notify_master “/etc/keepalived/notify.sh master”
notify_backup “/etc/keepalived/notify.sh backup”
notify_fault “/etc/keepalived/notify.sh fault”
}
#lvs-dr
virtual_server 192.168.100.100 80 {
delay_loop 6
lb_algo rr
lb_kind DR
# persistence_timeout 50
protocol TCP
sorry_server 127.0.0.1 80

real_server 192.168.100.27 80 {
weight 1
HTTP_GET {
url {
path /
status_code 200
}
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
real_server 192.168.100.37 80 {
weight 1
HTTP_GET {
url {
path /
status_code 200
}
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
}
# ——lingwai de yige cong—————————–
vrrp_instance VI_2 { –從
state BACKUP
interface eth1
virtual_router_id 88
priority 80
advert_int 1
authentication {
auth_type PASS
auth_pass 54321
}
virtual_ipaddress {
192.168.100.200/24
}
notify_master “/etc/keepalived/notify.sh master”
notify_backup “/etc/keepalived/notify.sh backup”
notify_fault “/etc/keepalived/notify.sh fault”
}
#lvs-dr
virtual_server 192.168.100.200 80 {
delay_loop 6
lb_algo rr
lb_kind DR
# persistence_timeout 50
protocol TCP
sorry_server 127.0.0.1 80

real_server 192.168.100.28 80 {
weight 1
HTTP_GET {
url {
path /
}
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
real_server 192.168.100.38 80 {
weight 1
HTTP_GET {
url {
path /
status_code 200
}
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
}

proxy2: 192.168.100.17
————————————————–
vim /etc/keepalived/keepalived.conf
vrrp_instance VI_1 {
state BACKUP
interface eth1
virtual_router_id 66
priority 80
advert_int 1
authentication {
auth_type PASS
auth_pass 123456
}
virtual_ipaddress {
192.168.100.100/24
}
notify_master “/etc/keepalived/notify.sh master”
notify_backup “/etc/keepalived/notify.sh backup”
notify_fault “/etc/keepalived/notify.sh fault”
}

virtual_server 192.168.100.100 80 {
delay_loop 6
lb_algo rr
lb_kind DR
# persistence_timeout 50
protocol TCP
sorry_server 127.0.0.1 80

real_server 192.168.100.27 80 {
weight 1
HTTP_GET {
url {
path /
status_code 200
}
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
real_server 192.168.100.37 80 {
weight 1
HTTP_GET {
url {
path /
status_code 200
}
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
}
# ——lingwai de yige zu—————————–
vrrp_instance VI_2 {
state MASTER
interface eth1
virtual_router_id 88
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 54321
}
virtual_ipaddress {
192.168.100.200/24
}
notify_master “/etc/keepalived/notify.sh master”
notify_backup “/etc/keepalived/notify.sh backup”
notify_fault “/etc/keepalived/notify.sh fault”
}
virtual_server 192.168.100.200 80 {
delay_loop 6
lb_algo rr
lb_kind DR
# persistence_timeout 50
protocol TCP
sorry_server 127.0.0.1 80

real_server 192.168.100.28 80 {
weight 1
HTTP_GET {
url {
path /
status_code 200
}
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
real_server 192.168.100.38 80 {
weight 1
HTTP_GET {
url {
path /
status_code 200
}
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
}

自測試:
#curl 192.168.100.37
192.168.100.100 RS2
#curl 192.168.100.38
192.168.100.200 RS2

自測試:
curl 192.168.100.27
192.168.100.100 RS1 –網站內容
curl 192.168.100.28
192.168.100.200 RS1

 

測試用戶:
for i in {1..1000};do sleep 0.5;curl 192.168.100.200;curl 192.168.100;100;done
宕機 proxy1
killall -9 keepalived

訪問不受影響 .

小結2 : 宕機 RS1
for i in {1..1000};do sleep 0.5;curl 192.168.100.200;curl 192.168.100;100;done
影響2 3 秒 。

本文來自投稿,不代表Linux運維部落立場,如若轉載,請注明出處:http://www.www58058.com/92090

(1)
百澗溪百澗溪
上一篇 2018-03-11
下一篇 2018-03-11

相關推薦

  • 文件管理基礎知識及命令詳解

    文件系統     文件和目錄被組織成一個單根倒置樹結構     文件系統從根目錄下開始,用“ /”表示     根文件系統(rootfs): root filesystem    …

    Linux干貨 2016-08-05
  • N25_第一周博客作業

    一、計算機組成及其功能      1、CPU:          運算器:計算功能,對數據進行加工處理的部件。          控制器:負責從存儲器讀取指令,控制計算器之間的運行狀態和結果;     &nbs…

    Linux干貨 2016-12-04
  • DNS and Bind

    DNS and Bind      DNS服務器所提供的服務是完成將主機名和轉換為IP地址的工作。為什么需要將主機名轉換為IP地址的工作呢?這是因為,當網絡上的一臺客戶機訪問某一服務器上的資源時,用戶在瀏覽器地址欄中輸入的是人類便于識記的主機名和域名。而網絡上的計算機之間實現連接卻是通過每臺計算機在網絡中擁有的惟一的IP地址來完…

    Linux干貨 2017-06-01
  • OPENSSL&DNS

      1、詳細描述一次加密通訊的過程,結合圖示最佳。 Client 從互聯網下載CA的公鑰,用于驗證Server身份 Server 通過加密算法生成一對密鑰,將公鑰發給CA認證機構,做數字證書 CA 通過自己的私鑰加密 Server 公鑰并加上自己的數字簽名后,將生成的數字證書發給Server Client 與 Server 通TCP的三次握手建立連…

    Linux干貨 2016-12-05
  • 變量、腳本、條件測試

    一、編程基礎   程序:指令+數據  計算機:運行二進制指令 程序編程風格:  過程式:以指令為中心,數據服務于指令  對象式:以數據為中心,指令服務于數據shell程序:提供了編程能力,解釋執行編程語言:  編譯:高級語言–>編譯器–>目標代碼  解釋:高級語言…

    Linux干貨 2016-08-15
欧美性久久久久