风哥教程

培训 . 交流 . 分享
Make progress together!

LVS +Keepalived+ Ldirector负载均衡

[复制链接]
内容发布:luashin| 发布时间:2017-6-8 20:18:20
LVS + Ldirector负载均衡

1、DR安装配置:
(1)安装IPVSADM
yum -y install ipvsadm

cat /etc/init.d/lvsDR
#dscription: Start LVS of Director server
VIP=192.168.1.50
RIP1=192.168.1.60
RIP2=192.168.1.61
. /etc/rc.d/init.d/functions
case "$1" in
    start)
        echo "Start LVS of Director Server"
        # set the Virtual  IP Address and sysctl parameter
        /sbin/ifconfig eth0:0 $VIP broadcast $VIP netmask 255.255.255.255 up
        echo "1" >/proc/sys/net/ipv4/ip_forward
        #Clear IPVS table
        /sbin/ipvsadm -C
        #set LVS
        /sbin/ipvsadm -A -t $VIP:3306 -s rr -p 600
        /sbin/ipvsadm -a -t $VIP:3306 -r $RIP1:3306 -g
        /sbin/ipvsadm -a -t $VIP:3306 -r $RIP2:3306 -g
        #Run LVS
        /sbin/ipvsadm
       ;;
    stop)
        echo "Close LVS Directorserver"
        echo "0" >/proc/sys/net/ipv4/ip_forward
        /sbin/ipvsadm -C
        /sbin/ifconfig eth0:0 down
        ;;
    *)
        echo "Usage: $0 {start|stop}"
        exit 1
esac

2、安装ldirectord
需要安装四个软件包:
heartbeat-1.2.4-1.i386.rpm             heartbeat-pils-1.2.4-1.i386.rpm
heartbeat-ldirectord-1.2.4-1.i386.rpm  heartbeat-stonith-1.2.4-1.i386.rpm
rpm -ivh *.rpm --nodeps --force

修改配置文件:
cat /etc/ha.d/ldirectord.cf
#Global Directives
checktimeout=20
checkinterval=10
fallback=127.0.0.1:3306
autoreload=yes
logfile="/var/log/ldirectord.log"
quiescent=no

# Sample for an mysql virtual service
virtual=192.168.1.50:3306
        real=192.168.1.60:3306 gate
        real=192.168.1.61:3306 gate
        fallback=127.0.0.1:3306 gate
        service=mysql
        checktype=negotiate
        login="root"
        passwd="mysql"
        request="show status"
        scheduler=rr

3、real server配置: 在三个节点均这样操作:
增加/etc/init.d/lvsrs 脚本:
cat /etc/init.d/lvsrs
#!/bin/bash
#description : Start Real Server
VIP=192.168.1.50
. /etc/rc.d/init.d/functions
case "$1" in
    start)
        echo "Start LVS of Real Server"
        /sbin/ifconfig lo:0 $VIP broadcast $VIP netmask 255.255.255.255 up
        echo "1" >/proc/sys/net/ipv4/conf/lo/arp_ignore
        echo "2" >/proc/sys/net/ipv4/conf/lo/arp_announce
        echo "1" >/proc/sys/net/ipv4/conf/all/arp_ignore
        echo "2" >/proc/sys/net/ipv4/conf/all/arp_announce
        ;;
    stop)
        /sbin/ifconfig lo:0 down
        echo "Close LVS Director server"
        echo "0" >/proc/sys/net/ipv4/conf/lo/arp_ignore
        echo "0" >/proc/sys/net/ipv4/conf/lo/arp_announce
        echo "0" >/proc/sys/net/ipv4/conf/all/arp_ignore
        echo "0" >/proc/sys/net/ipv4/conf/all/arp_announce
        ;;
    *)
        echo "Usage: $0 {start|stop}"
        exit 1
esac



上一篇:MariaDB Galera Cluster部署(如何快速部署MariaDB集群)
下一篇:MySQL视图的基本操作
回复

使用道具 举报

1框架
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

热门文章教程

  • PostgreSQL数据库中文培训手册
  • Oracle OCP认证考试IZ0-053题库共712题数据
  • Navicat for MySQL最新版下载地址及注册码
  • MySQL5权威指南(第3版)PDF电子版下载
  • Oracle Database 12c 数据库100个新特性与
  • oracle 12c RAC 日志频繁切换 checkpoint n
快速回复 返回顶部 返回列表