概述
考虑到keepalived高可用,备节点的机器基本上属于空闲状态,很浪费硬件资源,所以我们可以让keepalived互为主备,跑多个实例
第一个节点配置
vim /etc/keepalived/keepalived.conf
global_defs {
router_id LVS_KEEP01
}
#第一个业务 为主
vrrp_instance VI_1 {
state MASTER
interface eth0
lvs_sync_daemon_inteface eth0
virtual_router_id 51
priority 150
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
10.125.192.100
10.125.192.101
}
}
virtual_server 10.125.192.100 80 {
delay_loop 6
lb_algo wrr
lb_kind DR
nat_mask 255.255.255.0
persistence_timeout 10
protocol TCP
real_server 10.125.192.2 80 {
weight 1
inhibit_on_failure
TCP_CHECK {
connect_timeout 8
nb_get_retry 3
delay_before_retry 3
connect_port 80
}
}
real_server 10.125.192.3 80 {
weight 1
inhibit_on_failure
TCP_CHECK {
connect_timeout 8
nb_get_retry 3
delay_before_retry 3
connect_port 80
}
}
}
#第二个业务为备
vrrp_instance VI_2 {
state BACKUP
interface eth0
lvs_sync_daemon_inteface eth0
virtual_router_id 52
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 2222
}
virtual_ipaddress {
10.125.192.102
10.125.192.103
}
}
virtual_server 10.125.192.102 80 {
delay_loop 6
lb_algo wrr
lb_kind DR
nat_mask 255.255.255.0
persistence_timeout 10
protocol TCP
real_server 10.125.192.5 80 {
weight 1
inhibit_on_failure
TCP_CHECK {
connect_timeout 8
nb_get_retry 3
delay_before_retry 3
connect_port 80
}
}
real_server 10.125.192.6 80 {
weight 1
inhibit_on_failure
TCP_CHECK {
connect_timeout 8
nb_get_retry 3
delay_before_retry 3
connect_port 80
}
}
}
第二个节点配置
vim /etc/keepalived/keepalived.conf
global_defs {
router_id LVS_KEEP01
}
#第一个业务 为备
vrrp_instance VI_1 {
state BACKUP
interface eth0
lvs_sync_daemon_inteface eth0
virtual_router_id 51
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
10.125.192.100
10.125.192.101
}
}
virtual_server 10.125.192.100 80 {
delay_loop 6
lb_algo wrr
lb_kind DR
nat_mask 255.255.255.0
persistence_timeout 10
protocol TCP
real_server 10.125.192.2 80 {
weight 1
inhibit_on_failure
TCP_CHECK {
connect_timeout 8
nb_get_retry 3
delay_before_retry 3
connect_port 80
}
}
real_server 10.125.192.3 80 {
weight 1
inhibit_on_failure
TCP_CHECK {
connect_timeout 8
nb_get_retry 3
delay_before_retry 3
connect_port 80
}
}
}
#第二个业务为主
vrrp_instance VI_2 {
state MASTER
interface eth0
lvs_sync_daemon_inteface eth0
virtual_router_id 52
priority 150
advert_int 1
authentication {
auth_type PASS
auth_pass 2222
}
virtual_ipaddress {
10.125.192.102
10.125.192.103
}
}
virtual_server 10.125.192.102 80 {
delay_loop 6
lb_algo wrr
lb_kind DR
nat_mask 255.255.255.0
persistence_timeout 10
protocol TCP
real_server 10.125.192.5 80 {
weight 1
inhibit_on_failure
TCP_CHECK {
connect_timeout 8
nb_get_retry 3
delay_before_retry 3
connect_port 80
}
}
real_server 10.125.192.6 80 {
weight 1
inhibit_on_failure
TCP_CHECK {
connect_timeout 8
nb_get_retry 3
delay_before_retry 3
connect_port 80
}
}
}
最后
以上就是痴情草丛为你收集整理的keepalived双主模式(互为主备)的全部内容,希望文章能够帮你解决keepalived双主模式(互为主备)所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复