构建具有负载均衡功能MySQL集群 PART 2

一、建立两台用作负载均衡的服务器(一主一辅):
      Load Balancer 1 (Primary): 192.168.0.13
      Load Balancer 2 (Backup): 192.168.0.14
      1、配置 IPVS
      Load Balancer  1/ Load Balancer 2:
      执行以下操作
      yum install ipvsadm
      ifconfig eth0:0 192.168.0.15 netmask 255.255.255.255 broadcast 192.168.0.15 up(或者
      直接在配置文件 ifcfg-eth0:0 中配置)
      route add -host 192.168.0.15 dev eth0:0
      ipvsadm -A -t 192.168.0.15:3306 -s wlc
      ipvsadm -a -t 192.168.0.15:3306 -r 192.168.0.10
      ipvsadm -a -t 192.168.0.15:3306 -r 192.168.0.11
      service ipvsadm save(将 IPVS 表保存到 /etc/sysconfig/ipvsadm)
      
      192.168.0.15 为整个 MySQL Cluster 的虚拟 IP,3306 为 MySQL 服务的默认
      端口

      2、配置 Real Server 端
      SQL Node 1 / SQL Node2:
      执行以下操作
      在 /etc/sysctl.conf 作如下配置
      net.ipv4.ip_forward = 1
      net.ipv4.conf.lo.arp_ignore = 1
      net.ipv4.conf.lo.arp_announce = 2      
      net.ipv4.conf.all.arp_ignore = 1
      net.ipv4.conf.all.arp_announce = 2      
      执行以下命令
      ifconfig lo:0 192.168.0.15 netmask 255.255.255.255 broadcast 192.168.0.15 up
      route add -host 192.168.0.15 dev lo:0 
   
      3、配置 ldirectord
      
      4、配置 heartbeat

      5、测试