登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

herb

喜欢写博,喜欢安静,喜欢挑战!

 
 
 

日志

 
 

LVS(NAT)+keepalived部署文档(三)  

2011-04-14 16:27:52|  分类: Linux Cluster |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

u       拓扑描述

根据实际网络情况可在

 

后端web服务器1192.168.15.233

后端web服务器2192.168.15.234

负载服务器masterwlan-192.168.15.253

                  Lan-10.0.0.1

负载服务器backup192.168.15.236

 

u       Real机配置

需根据具体网络环境设置(a或b

a. 设置网关

/etc/sysconfig/network-scripts/ifcfg-eth0 添加

GATEWAY=10.0.0.1

b.添加默认网关

route add default gw 10.0.0.1 (提示:删除则用delete

 

u       调度器ipvsadm设置

#echo 1 > /proc/sys/net/ipv4/ip_forward (开启路由机制)

[root@localhost ~]# cat /root/ipvsadm.sh

#!/bin/sh

VIP=192.168.15.253

VIP_LAN=10.0.0.1

RIP1=10.0.0.233

RIP2=10.0.0.234

case "$1" in

    start)

        echo " start LVS "

#       set the Virtual  IP Address

#       /sbin/modprobe ipip

#       /sbin/ifconfig eth0:0 $VIP broadcast $VIP netmask 255.255.255.255 up

#       /sbin/route add -host $VIP dev eth0:0

       /sbin/ifconfig eth0:2 $VIP_LAN netmask 255.255.255.0 broadcast 10.0.0.255 up

       /sbin/ipvsadm -C

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

       /sbin/ipvsadm -a -t $VIP:80 -r $RIP1:80 -m -w 1

       /sbin/ipvsadm -a -t $VIP:80 -r $RIP2:80 -m -w 1

        ;;

    stop)

        echo "close LVS Director"

        /sbin/ipvsadm -C

        /sbin/ifconfig eth0:2 down

#       /sbin/modprobe -r ipip

        ;;

    *)

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

        exit 1

esac

 

测试验证正常

 

u       Master Keepalived配置

 [root@localhost ~]# vi /etc/keepalived/keepalived.conf

 

! Configuration File for keepalived

 

global_defs {

   notification_email {

     88fly@163.com

     chenhaibo@myhexin.com

     sysadmin@firewall.loc

   }

   notification_email_from Alexandre.Cassen@firewall.loc

   smtp_server smtp.163.com

   smtp_connect_timeout 30

   router_id LVS_DEVEL

}

 

vrrp_instance VI_1 {

    state MASTER

    interface eth0

    virtual_router_id 51

    priority 100

    advert_int 5

    authentication {

        auth_type PASS

        auth_pass 1111

    }

    virtual_ipaddress {

        192.168.15.253

    }

}

 

virtual_server 192.168.15.253 80 {

    #delay_loop 10

    lb_algo wlc

    lb_kind NAT

#   persistence_timeout 1

    protocol TCP

#   sorry_server 127.0.0.1 80

 

    real_server 10.0.0.233 80 {

        weight 1

        TCP_CHECK {

        connect_timeout 1

        nb_get_retry 3

        delay_before_retry 3

        connect_port 80

        }

    }

    real_server 10.0.0.234 80 {

        weight 1

        TCP_CHECK {

        connect_timeout 1

        nb_get_retry 3

        delay_before_retry 3

        connect_port 80

        }

    }

}

backup机对应修改即可

u       验证配置

关闭ipvsadm—> /root/ipvsadm.sh stop 

添加IP /sbin/ifconfig eth0:2 10.0.0.1 netmask 255.255.255.0 broadcast 10.0.0.255 up

启动keepalived验证  service keepalived start

  评论这张
 
阅读(2116)| 评论(2)

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2018