Chinaunix首页 | 论坛 | 博客
  • 博客访问: 101454180
  • 博文数量: 19283
  • 博客积分: 9968
  • 博客等级: 上将
  • 技术积分: 196062
  • 用 户 组: 普通用户
  • 注册时间: 2007-02-07 14:28
文章分类

全部博文(19283)

文章存档

2011年(1)

2009年(125)

2008年(19094)

2007年(63)

分类: LINUX

2008-04-28 22:12:44

 
文章来源中国IT实验室收集整理

三、配置基于高可用Lvs+heartbeat

        确定LVS使用DR或/tun模式,请对照上面的配置,本例使用DR模式

        1.配置LVS directorserver 脚本

        #!/bin/sh

        VIP=192.168.8.11

        RIP1=192.168.8.6

        RIP2=192.168.8.5

        /etc/rc.d/init.d/functions

        case "$1" in

        start)

        echo "start LVS of DirectorServer"

        #Set the Virtual IP Address

        /sbin/ifconfig eth0:1 $VIP broadcast $VIP netmask 255.255.255.255 up

        /sbin/route add -host $VIP dev eth0:1

        #Clear IPVS Table

        /sbin/ipvsadm -C

        #Set Lvs

        /sbin/ipvsadm -A -t $VIP:80 -s rr

        /sbin/ipvsadm -a -t $VIP:80 -r $RIP1:80 -g

        /sbin/ipvsadm -a -t $VIP:80 -r $RIP2:80 -g

        #Run Lvs

        /sbin/ipvsadm

        ;;

        stop)

        echo "close LVS Directorserver"

        /sbin/ipvsadm -C

        ;;

        *)

        echo "Usage: $0 {start|stop}"

        exit 1

        esac

        2. realserver端同样使用上面的配置文件就可以。

        3.安装heartbeat

        3.1 安装

        tar -zxvf libnet.tar.gz

        cd libnet

        。/configure

        make

        make install

        groupadd -g 694 haclient

        useradd -u 694 -g haclient hacluster

        tar zxf heartbeat-1.99.4.tar.gz

        cd heartbeat-1.99.4

        。/ConfigureMe configure

        make

        make install

        cp doc/ha.cf doc/haresources doc/authkeys /etc/ha.d/

        cp ldirectord/ldirectord.cf /etc/ha.d/

        3.2配置主文件/etc/ha.d/ha.cf

        logfile /var/log/ha-log

        keepalive 2

        deadtime 60

        warntime 10

        initdead 120

        udpport 694

        bcast eth0 # Linux

        auto_failback on

        ping_group group1 192.168.8.2 192.168.8.3

        respawn root /usr/lib/heartbeat/ipfail

        apiauth ipfail gid=root uid=root

        hopfudge 1

        use_logd yes

        node test7

        node test8

        crm on

        3.3资源文件/etc/ha.d/ haresources

        test7 192.168.8.11 httpd

        设置test7为主节点,集群的ip地址为192.168.8.11 集群服务有httpd

阅读(367) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~