ddddddf 发表于 2019-1-1 07:31:41

keepalived+LVS+apache双机搭建高可用负载均衡web服务

  编辑/etc/keepalived/keepalived.conf
  # vi /etc/keepalived/keepalived.conf ,添加如下内容
  ! Configuration File for keepalived
  global_defs {
  notification_email {
  admin@example.com
  }
  notification_email_from admin@example.com
  smtp_server 127.0.0.1
  smtp_connect_timeout 30
  router_id linux01
  }
  vrrp_instance VI_1 {                               #定义一个实例
  state BACKUP                                    #设置为backup,然后通过priority控制哪台提升为主
  interface eth0
  virtual_router_id 51
  priority 100
  nopreempt                                          #在priority高的这台设置这个参数,方便当主恢复后
  advert_int 1                                       #可以自动接管
  authentication {
  auth_type PASS
  auth_pass 1111
  }
  virtual_ipaddress {
  192.168.211.110 dev eth0 label eth0:0                #这里使用label标签启用eth0:0
  }
  }
  virtual_server 192.168.211.110 80 {                        #这里往下是定义LVS
  delay_loop 6
  lb_algo rr
  lb_kind DR
  nat_mask 255.255.255.0
  protocol TCP
  real_server 127.0.0.1 80 {                            #其中一台是本地web服务
  weight 1
  TCP_CHECK {
  connect_timeout 3
  }
  }
  real_server 192.168.211.129 80 {             #另一台的web服务
  weight 1
  TCP_CHECK {
  connect_timeout 3
  }
  }
  }

页: [1]
查看完整版本: keepalived+LVS+apache双机搭建高可用负载均衡web服务