LVS DR+Keepalived

LVS DR+keepalived:只有vip地址为浮动资源
LVS DR通过keepalived实现高可用

安装内核对应的开发包

yum install kernel-xen-devel 安装跟当前内核相对应的开发包

安装Keepalived

解压tar xvzf keepalived-1.2.1.tar.gz
进入解压目录:cd keepalived-1.2.1
编译安装: ./configure --prefix=/ --mandir=/usr/local/share/man/ --with-kernel-dir=/usr/src/kernels/2.6.18-308.el5xen-i686/
make && make install
uname -r要和--with-kernel-dir后面路径中的内核目录一致

配置文件

进入:/etc/keepalived
编辑:vim keepalived.conf
! Configuration File for keepalived
global_defs {
  router_id LVS_DEVEL
  }
vrrp_instance VI_1 {
  state MASTER
  interface eth0 //dip网卡
  virtual_router_id 51
  priority 100

  advert_int 1
  unicast_src_ip 192.168.20.131
  unicast_peer {
  192.168.20.132
  }
  authentication {
    auth_type PASS
    auth_pass 1111
  }
  virtual_ipaddress { //设置vip地址
    192.168.122.10/24 dev eth1
    }
  }
  virtual_server 192.168.122.10 80 {
    delay_loop 6
    lb_algo rr
    lb_kind DR
    nat_mask 255.255.255.0
    protocol TCP

  real_server 192.168.122.100 80 {
  weight 1
  TCP_CHECK { //健康检查
  connect_timeout 3
    }
  }
  real_server 192.168.122.200 80 {
  weight 1
  TCP_CHECK {
  connect_timeout 3
    }
  }
}

猜你喜欢

转载自www.cnblogs.com/super-sos/p/8909695.html