老爷子88 发表于 2018-12-31 09:09:51

Keepalived+LVS/DR实验笔记

http://blog.运维网.com/attachment/201312/112231812.jpg
操作系统:RHEL5.8



分别在DirectorMaster和DirectorBackup上部署浮动资源(VIP IPVS策略)
测试2个Director在DR模式下是否都正常工作。测试完后都撤掉浮动资源


在DirectorMaster上安装配置Keepalived
#tar -zvxf 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.el5-i686/
--> 如果没有/usr/src/kernels/2.6.18-3.8.el5-i686,则需要安装对应当前kernel版本的kernel-devel软件包
ex:
    #uname -r
    2.6.18-308.el5xen

    #yum install kernel-xen-devel


小贴士
--> 若出现以下错误信息
!!! OpenSSL is not properly installed on your system. !!!
!!! Can not include OpenSSL headers files.
--> 解决方案
#yum -y install openssl-devel


  Keepalived configuration
  ------------------------
  Keepalived version      : 1.2.1
  Compiler                  : gcc
  Compiler flags            : -g -O2 -DETHERTYPE_IPV6=0x86dd
  Extra Lib               : -lpopt -lssl -lcrypto
  Use IPVS Framework      : Yes
  IPVS sync daemon support: Yes
  Use VRRP Framework      : Yes
  Use Debug flags         : No
  

  #make && make install
  #cd /etc/keepalived/
  #vim keepalived.conf
  ! Configuration File for keepalived
  global_defs {
      notification_email {

        root@localhost
      }

      notification_email_from keepalived@localhost

      smtp_server 127.0.0.1

      smtp_connect_timeout 30

      router_id Director1

  }
  vrrp_instance VI_1 {
      state MASTER

      interface eth0

      virtual_route_id 51

      priority 150

      advert_int 1

      authentication {

        auth_type PASS

        auth_pass 1111

      }

      virtual_ipaddress {

        192.168.122.200/24 dev eth0

      }

  }
  virtual_server 192.168.122.200 80 {
      delay_loop 3

      lb_algo rr    -->LVS调度算法

      lb_kind DR    -->LVS集群模式

      nat_mask 255.255.255.0

      protocol TCP

      real_server 192.168.122.30 80 {

        weight 1

        TCP_CHECK {

              connect_timeout 3

        }

      }
      real_server 192.168.122.40 80 {

        weight 1

        TCP_CHECK {

              connect_timeout 3

        }

      }
  }
  

  #scp keepalived.conf 192.168.122.20:/etc/keepalived/
  --> 拷贝后,修改配置文件
      state BACKUP

      priority 100    -->master至少要高于backup50



在两台Director上启动服务
#/etc/init.d/keepalived start





页: [1]
查看完整版本: Keepalived+LVS/DR实验笔记