色婆ijqwj 发表于 2018-12-31 06:56:09

lvs主备NAT模式上课用例(keepalived)

  主节点配置
  ! Configuration File for keepalived
  global_defs {
   notification_email {
admin@163.com
   }
   notification_email_from sender@163.com
   smtp_server smtp.163.com
   smtp_connect_timeout 30
   router_id LVS_master
}
  vrrp_instance VIlvs {
    state MASTER
    interface eth2
    virtual_router_id 51
    priority 100
    advert_int 1
    authentication {
      auth_type PASS
      auth_pass 1122
    }
    virtual_ipaddress {
      172.16.11.200
      192.168.7.1 dev eth1
    }
}
  virtual_server 172.16.11.200 80 {
    delay_loop 6
    lb_algo rr
    lb_kind NAT
    nat_mask 255.255.255.0
    #persistence_timeout 50
    protocol TCP
  real_server 192.168.7.156 80 {
      weight 100
      TCP_CHECK {
      connect_timeout 10
      nb_get_retry 3
      delay_before_retry 3
                }
  }
  real_server 192.168.7.158 80 {
      weight 100
      TCP_CHECK {
      connect_timeout 10
      nb_get_retry 3
      delay_before_retry 3
                }
  }
  备节点配置
  ! Configuration File for keepalived
  global_defs {
   notification_email {
admin@163.com
   }
   notification_email_from sender@163.com
   smtp_server smtp.163.com
   smtp_connect_timeout 30
   router_id LVS_slave
}
  vrrp_instance VIlvs {
    state SLAVE
    interface eth5
    virtual_router_id 51
    priority 90
    advert_int 1
    authentication {
      auth_type PASS
      auth_pass 1122
    }
    virtual_ipaddress {
      172.16.11.200
      192.168.7.1 dev eth4
    }
}
  virtual_server 172.16.11.200 80 {
    delay_loop 6
    lb_algo rr
    lb_kind NAT
    nat_mask 255.255.255.0
    #persistence_timeout 50
    protocol TCP
  real_server 192.168.7.156 80 {
      weight 100
      TCP_CHECK {
      connect_timeout 10
      nb_get_retry 3
      delay_before_retry 3
                }
  }
  real_server 192.168.7.158 80 {
      weight 100
      TCP_CHECK {
      connect_timeout 10
      nb_get_retry 3
      delay_before_retry 3
                }
  }

  内核参数设置
  echo 1 > /proc/sys/net/ipv4/ip_forward
  -A POSTROUTING -s 192.168.7.0/24 -o eth2 -j SNAT --to-source 172.16.11.162

  WEB服务器节点
  只需开启WEB服务,默认网关指向LVS服务器即可



页: [1]
查看完整版本: lvs主备NAT模式上课用例(keepalived)