码迷,mamicode.com
首页 > 其他好文 > 详细

Keepalived 双实例双主模式配置

时间:2017-06-04 12:51:09      阅读:253      评论:0      收藏:0      [点我收藏+]

标签:pass   abc   说明   ipaddress   priority   auth   配置   stop   rom   

一、环境

A 业务在 lb01 上是主模式,在 lb02 上是备模式
B 业务在 lb01 上是备模式,在 lb02 上是主模式

Hostname IP 说明
lb01 192.168.123.101 VIP :192.168.123.100 ( 用于绑定 A 服务 www.abc.com 域名 )
lb02 192.168.123.102 VIP :192.168.123.200 ( 用于绑定 B 服务 bbs.abc.com 域名)

 

 

 

 

二、配置

[root@lb01 ~]# cat /etc/keepalived/keepalived.conf   
! Configuration File for keepalived    
                                       
global_defs {                          
   notification_email {                
     1054890557@qq.com
   }
   notification_email_from Alexandre.Cassen@firewall.loc   
   smtp_server 127.0.0.1           
   smtp_connect_timeout 30             
   router_id lb01         
}

vrrp_instance VI_1 {          
    state MASTER              
    interface eth0           
    virtual_router_id 55    
    priority 150              
    advert_int 1               
    authentication {         
        auth_type PASS        
        auth_pass 1111       
    }
    virtual_ipaddress {      
        192.168.123.100/24 dev eth0 label eth0:1 
    }
}

vrrp_instance VI_2 {         
    state BACKUP             
    interface eth0           
    virtual_router_id 56    
    priority 100           
    advert_int 1               
    authentication {         
        auth_type PASS       
        auth_pass 1111       
    }
    virtual_ipaddress {      
        192.168.123.200/24 dev eth0 label eth0:2   
    }
}
[root@lb02 ~]# cat /etc/keepalived/keepalived.conf
! Configuration File for keepalived    
                                       
global_defs {                          
   notification_email {                
     1054890557@qq.com
   }
   notification_email_from Alexandre.Cassen@firewall.loc   
   smtp_server 127.0.0.1           
   smtp_connect_timeout 30             
   router_id lb02                   
}

vrrp_instance VI_1 {              
    state BACKUP                     
    interface eth0           
    virtual_router_id 55       
    priority 100              
    advert_int 1               
    authentication {         
        auth_type PASS        
        auth_pass 1111        
    }
    virtual_ipaddress {      
        192.168.123.100/24 dev eth0 label eth0:1  
    }
}

vrrp_instance VI_2 {              
    state MASTER                     
    interface eth0           
    virtual_router_id 56       
    priority 150              
    advert_int 1               
    authentication {         
        auth_type PASS        
        auth_pass 1111        
    }
    virtual_ipaddress {      
        192.168.123.200/24 dev eth0 label eth0:2 
    }
}
[root@lb01 ~]# /etc/init.d/keepalived restart    # 查看 lb01 上的主服务器
[root@lb01 ~]# ip addr | egrep "192.168.123.100|192.168.123.200"
inet 192.168.123.100/24 scope global secondary eth0:1
[root@lb02 ~]# /etc/init.d/keepalived restart    # 查看 lb02 上的主服务器
[root@lb02 ~]# ip addr | egrep "192.168.123.100|192.168.123.200"
    inet 192.168.123.200/24 scope global secondary eth0:2
[root@lb01 ~]# /etc/init.d/keepalived stop       # 停掉 lb01 看会不会切换到 lb02
[root@lb02 ~]# ip addr | egrep "192.168.123.100|192.168.123.200"
inet 192.168.123.200/24 scope global secondary eth0:2
inet 192.168.123.100/24 scope global secondary eth0:1
[root@lb01 ~]# /etc/init.d/keepalived start      # 再次启动看会不会切换回来
[root@lb01 ~]# ip addr | egrep "192.168.123.100|192.168.123.200"
    inet 192.168.123.100/24 scope global secondary eth0:1

 

 

 

 

     

 

    

Keepalived 双实例双主模式配置

标签:pass   abc   说明   ipaddress   priority   auth   配置   stop   rom   

原文地址:http://www.cnblogs.com/pzk7788/p/6940000.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!