KeepAlive高可用雙主lvs-dr模型集群

1.環境:

RS1 ?: ?192.168.0.117

RS2 :192.168.0.118

VS1 :192.168.0.106

VS2 : ?192.168.0.114

VIP1:192.168.0.90 ? ? VIP2:192.168.0.99

2.在RS上安裝httpd服務:yum install httpd

編輯網頁:

vi /var/www/html/index.html

192.168.0.117

vi /var/www/html/index.html

192.168.0.118

3.在RS上配置VIP,兩臺RS上都要配置

echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore
echo 1 > /proc/sys/net/ipv4/conf/lo/arp_ignore
echo 2 >/proc/sys/net/ipv4/conf/all/arp_announce
echo 2 >/proc/sys/net/ipv4/conf/lo/arp_announce
ifconfig ?lo:0 ?192.168.0.90 netmask ?255.255.255.255 ?broadcast ?192.168.0.90 ?up
ifconfig ?lo:1 ?192.168.0.99 netmask ?255.255.255.255 ?broadcast ?192.168.0.99 ?up
route add ?-host ?192.168.0.90 ?dev ?ens33
route add ?-host ?192.168.0.99 ?dev ?ens33
4.啟動httpd服務
systemctl start httpd
5.在VS中配置vs的高可用以及VS集群服務
VS1:

global_defs {

notification_email {
root@localhost
}
notification_email_from keepalived@localhost
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id centos7-1
vrrp_mcast_group4 224.0.101.23
}

vrrp_instance myr1 {
state BACKUP
interface ens33
virtual_router_id 51
priority 90
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.0.90/24 dev ens33
}

}

vrrp_instance myr2 {
state MASTER
interface ens33
virtual_router_id 52
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.0.99/24 dev ens33
}
}

virtual_server 192.168.0.90 80{
delay_loop 6
lb_algo wrr
lb_kind DR
protocol TCP
sorry_server 127.0.0.1 80
real_server 192.168.0.117 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.0.118 80{
weight 1
HTTP_GET{
url{
path /
status_code 200
}
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
}

virtual_server 192.168.0.99 80{
delay_loop 6
lb_algo wrr
lb_kind DR
protocol TCP
sorry_server 127.0.0.1 80
real_server 192.168.0.117 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.0.118 80{
weight 1
HTTP_GET{
url{
path /
status_code 200
}
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
}

VS2:

global_defs {

notification_email {
root@localhost
}
notification_email_from keepalived@localhost
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id centos7-2
vrrp_mcast_group4 224.0.101.23
}

vrrp_instance myr1 {
state MASTER
interface ens33
virtual_router_id 51
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.0.90/24 dev ens33
}
}

vrrp_instance myr2 {
state BACKUP
interface ens33
virtual_router_id 52
priority 90
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.0.99/24 dev ens33
}
}

virtual_server 192.168.0.90 80{
delay_loop 6
lb_algo wrr
lb_kind DR
protocol TCP
sorry_server 127.0.0.1 80
real_server 192.168.0.117 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.0.118 80{
weight 1
HTTP_GET{
url{
path /
status_code 200
}
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
}

virtual_server 192.168.0.99 80{
delay_loop 6
lb_algo wrr
lb_kind DR
protocol TCP
sorry_server 127.0.0.1 80
real_server 192.168.0.117 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.0.118 80{
weight 1
HTTP_GET{
url{
path /
status_code 200
}
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
}

6.在vs上配置sorry_server
yum install httpd
vs2上
vi /var/www/html/index.html
Driector2:sorry_server
vs1上
vi /var/www/html/index.html
Driector1:sorry_server

7.啟動keepalived

systemctl ?start keepalived

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

(0)
DPingDPing
上一篇 2018-07-23 15:37
下一篇 2018-07-23 19:22

相關推薦

  • 學習筆記(1)

    學習筆記

    Linux筆記 2018-04-01
  • ansible_playbook

    —– hosts: allremote_user: root vars:ports:-81-82-83 vars:ports:– listen_port: 81– listen_port: 82– listen_port: 83 vars:ports:– web1:port: 81#na…

    Linux筆記 2018-07-30
  • Linux文本處理工具

    抽取文本的工具: 文件查看命令: 分頁查看文件內容: 顯示文本前或后行的內容: 抽取文本cut和合并文件paste cut和paste: 分析文本的工具: 文件排序sort:  

    Linux筆記 2018-04-08
  • 計算機的組成及其功能

    計算機(computer)俗稱電腦,常用于進行數值計算、邏輯計算,除此之外還帶有存儲記憶功能。 計算機主要由五個部分組成。 (1)運算器 運算器(ALU,Arithmetic Logic Unit),基本功能是完成對各種數據的加工處理,主要負責完成計算機中的算術運算(即加、減、乘、除以及相應的復合運算)和邏輯運算(與、或、非等邏輯運算以及數據的比較和移位等操…

    Linux筆記 2018-05-13
  • shell腳本基礎及編程練習

    shell基礎語法

    Linux筆記 2018-04-15
  • 實驗:正向主DNS實現 實驗:反向解析DNS 實驗:從DNS服務器實現

    實驗:正向主DNS實現實驗:反向解析DNS 實驗:從DNS服務器實現 在主服務器vim /etc/named.confallow-transfer { slaveip;}; 加此行從服務器vim /etc/named.confallow-transfer { none;}; 加此行 vim /etc/named.rfc1912.zoneszone &#822…

    2018-06-01
欧美性久久久久