免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2692 | 回复: 1
打印 上一主题 下一主题

[Web] 急 麻烦 大家帮忙下 nginx + keepalived 双机热备 生产环境 ~~问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-05-26 13:11 |只看该作者 |倒序浏览
急  麻烦 大家帮忙下  nginx + keepalived 双机热备 生产环境 ~~问题

~

用keepalived 来做热备HA

同时做路由 使内网192.168.128.0 的 可以访问公网IP 200.100.100.100
能实现吗? 如果错误多多话  请大家 教教 ~~         


我的目的是:nginx + keepalived 双机热备       keepalived 虚拟出 VIP 200.100.100.100    一个是内网网关192.168.254    同时监控物理设备
nginx 负责 负载   
同时写一脚本使nginx+keepalived 能做热备




配置如下


-----------------------
MASTER配置

global_defs {
notification_email {
finalbsd@gmail.com
}
notification_email_from finalbsd@gmail.com
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id nginxserver1
}
vrrp_sync_group VG1 {
group {
VI_1
}
}
vrrp_instance VI_1 {
state BACKUP
smtp_alert
notify_fault "/root/script/notify_mail.sh fault"
notify_master "/root/script/notify_mail.sh master"
nopreempt
interface eth1
track_interface {
eth0
eth1
}
mcast_src_ip 192.168.128.222   #外网卡
virtual_router_id 51
priority 150
advert_int 1

authentication {                #验证
auth_type PASS
auth_pass vrrp1101
}
virtual_ipaddress {
#<IPADDR>/<MASK> brd <IPADDR> dev <STRING> scope <SCOPT> label <LABEL>
200.100.100.100/24 dev eth1       #VIP公网IP
192.168.128.254/24 dev eth0       #VIP做内部网关  
}
}

virtual_routes {
# src <IPADDR> [to] <IPADDR>/<MASK> via|gw <IPADDR> dev <STRING> scope <SCOPE>
# src 192.168.128.112 to 200.100.100.100/24 via 192.168.200.254 dev eth1
src 192.168.100.0/24 to 200.100.100.100/24 via 192.168.128.254          #做出口路由
src 200.100.100.100/24 to 192.168.128.0/24 via 192.168.128.254          #做进口路由
}
preemtp_delay 300
debug
}


----------------------------------------------
BACKIP配置

global_defs {
notification_email {
finalbsd@gmail.com
}
notification_email_from finalbsd@gmail.com
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id nginxserver1
}
vrrp_sync_group VG1 {
group {
VI_1
}
}
vrrp_instance VI_1 {
state BACKUP
smtp_alert
notify_fault "/root/script/notify_mail.sh fault"
notify_master "/root/script/notify_mail.sh master"
interface eth1
track_interface {
eth0
eth1
}
mcast_src_ip 192.168.128.223  #外网卡
virtual_router_id 51
priority 100
advert_int 1

authentication {              #验证
auth_type PASS
auth_pass vrrp1101
}
virtual_ipaddress {
#<IPADDR>/<MASK> brd <IPADDR> dev <STRING> scope <SCOPT> label <LABEL>
200.100.100.100/24 dev eth1       #VIP公网IP
192.168.128.254/24 dev eth0       #VIP做内部网关  
}
}

virtual_routes {
# src <IPADDR> [to] <IPADDR>/<MASK> via|gw <IPADDR> dev <STRING> scope <SCOPE>
src 192.168.100.0/24 to 200.100.100.100/24 via 192.168.128.254          #做出口路由
src 200.100.100.100/24 to 192.168.128.0/24 via 192.168.128.254          #做进口路由
}
preemtp_delay 300
debug
}






---------------------------------------如果谁有测试成功过nginx+keepalive 热备
麻烦 指点 下

很重要    ~、


希望大家帮忙 下 ~~~

论坛徽章:
0
2 [报告]
发表于 2009-05-30 11:56 |只看该作者
我是这样部属的

1、准备二台机器,二台机器上安装keepalived 和nginx  ,
2、准备一个VIP IP 210.22.7.145,不用配置在ifcfg-ethxx中
eth0 是公网IP,eth1是内网IP
3、二台机器通过内网和后端的WEB APP服务器通信;

主配置文件:

! Configuration File for keepalived

global_defs {
   notification_email {
     myfreeke@gmail.com
   }
   notification_email_from myfreeke@gmail.com
   smtp_server smtp.gmail.com
   smtp_connect_timeout 30
   router_id LVS_DEVEL
}

vrrp_instance VI_1 {
    state MASTER
    interface eth0
    track_interface {
        eth1
    }
    virtual_router_id 1
    mcast_src_ip 210.22.7.148
   
    priority 200
    advert_int 1
   
    authentication {
        auth_type PASS
        auth_pass freeke
    }
    virtual_ipaddress {
     210.22.7.145
    }


备配置:
! Configuration File for keepalived

global_defs {
   notification_email {
     myfreeke@gmail.com
   }
   notification_email_from myfreeke@gmail.com
   smtp_server smtp.gmail.com
   smtp_connect_timeout 30
   router_id LVS_DEVEL
}

vrrp_instance VI_1 {
    state BACKUP
    interface eth0
    track_interface {
        eth1
    }
    virtual_router_id 1
    mcast_src_ip 210.22.7.146

    priority 100
    advert_int 1

    authentication {
        auth_type PASS
        auth_pass freeke
    }
    virtual_ipaddress {
     210.22.7.145   
    }
}


目前运营系统上就是这样跑着的,主挂掉4S就可以接管!
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP