ienki 发表于 2018-12-29 14:10:08

LVS+keepalived测试过程中碰到的问题

  主网关配置:
  # cat /etc/keepalived/keepalived.conf
#指定keepalived在发生切换时需要发送email到的对象,一行一个
global_defs {
   notification_email {
   acassen@firewall.loc
   }
#指定发件人
notification_email_from Alexandre.Cassen@firewall.loc
#指定smtp服务器地址
smtp_server 127.0.0.1
#指定smtp连接超时时间
smtp_connect_timeout 30
   router_id LVS_DEVEL                                                #运行keepalived机器的一个标识
}
vrrp_sync_group VI_1 {                                    #监控多个网段的实例
      group {                                                         #实例名
      VI_1
      }
}
vrrp_instance VI_1 {
    state MASTER                              #状态
    interface eth1                      #监听网卡
    virtual_router_id 51 #VPID标记
    priority 50                                 #优先级,高优先级竞选为master
    advert_int 1                              #检查间隔,默认1秒
    authentication {            #设置认证
      auth_type PASS   #认证方式
      auth_pass 1111   #认证密码
    }
    virtual_ipaddress {
      192.168.100.73          #虚拟ip
    }
}
  
virtual_server 192.168.100.73 80 {
    lb_algo wrr
    lb_kind DR
    persistence_timeout 600
    net_mask 255.255.255.0
    protocol TCP
  real_server 192.168.100.74 80 {
      weight 1
      TCP_CHECK {
  connect_timeout 3
  nb_get_retry 3
  delay_before_retry 3
  connect_port 80
  }
  }
    real_server 192.168.100.75 80 {
      weight 1
      TCP_CHECK {
  connect_timeout 3
  nb_get_retry 3
  delay_before_retry 3
  connect_port 80
  }
  }
}
  备网关配置:
  # cat /etc/keepalived/keepalived.conf
#指定keepalived在发生切换时需要发送email到的对象,一行一个
global_defs {
   notification_email {
   acassen@firewall.loc
   }
#指定发件人
notification_email_from Alexandre.Cassen@firewall.loc
#指定smtp服务器地址
smtp_server 127.0.0.1
#指定smtp连接超时时间
smtp_connect_timeout 30
   router_id LVS_DEVEL                                                运行keepalived机器的一个标识
}
vrrp_sync_group VI_1 {                                    #监控多个网段的实例
      group {                                                            #实例名
      VI_1
      }
}
vrrp_instance VI_1 {
    state BACKUP                              #状态
    interface eth0                      #监听网卡
    virtual_router_id 51 #VPID标记
    priority 10                                 #优先级,高优先级竞选为master
    advert_int 1                              #检查间隔,默认1秒
    authentication {            #设置认证
      auth_type PASS   #认证方式
      auth_pass 1111   #认证密码
    }
    virtual_ipaddress {
      192.168.100.73          #虚拟ip
    }
}
  
virtual_server 192.168.100.73 80 {
    lb_algo wrr
    lb_kind DR
    persistence_timeout 600
    net_mask 255.255.255.0
    protocol TCP
  real_server 192.168.100.74 80 {
      weight 1
                TCP_CHECK {
  connect_timeout 3
  nb_get_retry 3
  delay_before_retry 3
  connect_port 80
  }
  }
    real_server 192.168.100.75 80 {
      weight 1
                TCP_CHECK {
  connect_timeout 3
  nb_get_retry 3
  delay_before_retry 3
  connect_port 80
  }
  }
}
  在测试过程中,当将2台设备的keepalived启动后,client去访问没有问题;过一段时间后client就无法访问应用;而且观察lvs负载情况时发现client访问正常是主备网关显示的负载条目一致,当client访问不正常是,主备网关显示的负载条目不一致,以附件中图片为例,访问正常时如果负载到75,那么在74和75上观察负载是一致的都显示负载到75;访问不正常时,74显示负载到75上,而在75上显示负载到74上。


附件:http://down.运维网.com/data/2364545

页: [1]
查看完整版本: LVS+keepalived测试过程中碰到的问题