ITPUX技术网

交流 . 资讯 . 分享
Make progress together!
Linux操作系统下Oracle11g R2 RAC 安装配置教程
Oracle数据库培训-备份恢复-性能优化-集群容灾
Oracle数据库DBA高级工程师培训视频

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框架
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表