免费注册 查看新帖 |

Chinaunix

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

keepalived for redhat linux 5配置 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-06-30 22:52 |只看该作者 |倒序浏览
有个项目可能用到,因此研究了一下。
Keepalived是Linux下面实现VRRP 备份路由的高可靠性运行件。基于Keepalived设计的服务模式能够真正做到主服务器和备份服务器故障时IP瞬间无缝交接。
网络环境:
三台服务器:
VIP:192.168.1.30
realserver1:192.168.1.22
realserver2:192.168.1.23
安装步骤:
前提条件需要有安装如下组件:
openssl-devel-0.9.8a-18.26.i586.rpm
popt-devel-1.7-271.27.i586.rpm
keepalived的安装比较简单(下载地址:
http://www.keepalived.org
):
在realserver1上操作:
在keepalived的解压目录执行如下命令:
#./configure --prefix=/usr/local/keepalived
#make
#make install
主要是修改配置文件(/usr/local/keepalived/etc/keepalived/keepalived.conf):
! Configuration File for keepalived
global_defs {
   notification_email {
   

39116712@qq.com
   }
   notification_email_from
admin@qq.com
   smtp_server 127.0.0.1
   smtp_connect_timeout 30
   router_id HA_1
}
}
vrrp_instance VI_1 {
    state MASTER

    interface eth0
    virtual_router_id 51
    mcast_src_ip 192.168.1.22
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass freeke
    }
    virtual_ipaddress {
    192.168.1.30
    }
}
在realserver2上执行与realserver1的相同操作,配置文件有点区别,主要体现在state和priority参数上如下:
! Configuration File for keepalived
global_defs {
   notification_email {
   

39116712@qq.com
   }
   notification_email_from
admin@qq.com
   smtp_server 127.0.0.1
   smtp_connect_timeout 30
   router_id HA_1
}
}
vrrp_instance VI_1 {
    state BACKUP

    interface eth0
    virtual_router_id 51
    mcast_src_ip 192.168.1.22
    priority 99
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass freeke
    }
    virtual_ipaddress {
    192.168.1.30
    }
}
经过以上的操作只需要执行如下命令即可启动:
#/usr/local/keepalived/sbin/keepalived -f /usr/local/keepalived/etc/keepalived/keepalived.conf -D
查看是否启动成功可按照如下方法操作:
A.  # tail -f /var/log/messages
若有如下内容输出则启动成功:

Jul  1 06:19:29 db Keepalived: Starting Keepalived v1.1.17 (06/28,2009)
Jul  1 06:19:29 db Keepalived: Starting Healthcheck child process, pid=1527
Jul  1 06:19:29 db Keepalived: Starting VRRP child process, pid=1528
Jul  1 06:19:29 db Keepalived_healthcheckers: Using MII-BMSR NIC polling thread...
Jul  1 06:19:29 db Keepalived_vrrp: Using MII-BMSR NIC polling thread...
Jul  1 06:19:29 db Keepalived_healthcheckers: Netlink reflector reports IP 192.168.1.22 added
Jul  1 06:19:29 db Keepalived_healthcheckers: Registering Kernel netlink reflector
Jul  1 06:19:29 db Keepalived_healthcheckers: Registering Kernel netlink command channel
Jul  1 06:19:29 db Keepalived_healthcheckers: Opening file 'etc/keepalived/keepalived.conf'.
Jul  1 06:19:29 db Keepalived_healthcheckers: Configuration is using : 5901 Bytes
Jul  1 06:19:29 db Keepalived_vrrp: Netlink reflector reports IP 192.168.1.22 added
Jul  1 06:19:29 db Keepalived_vrrp: Registering Kernel netlink reflector
Jul  1 06:19:29 db Keepalived_vrrp: Registering Kernel netlink command channel
Jul  1 06:19:29 db Keepalived_vrrp: Registering gratutious ARP shared channel
Jul  1 06:19:29 db Keepalived_vrrp: Opening file 'etc/keepalived/keepalived.conf'.
Jul  1 06:19:29 db Keepalived_vrrp: Configuration is using : 35764 Bytes
Jul  1 06:19:29 db Keepalived_vrrp: VRRP sockpool: [ifindex(2), proto(112), fd(10,11)]
Jul  1 06:19:30 db Keepalived_vrrp: VRRP_Instance(VI_1) Transition to MASTER STATE
Jul  1 06:19:31 db Keepalived_vrrp: VRRP_Instance(VI_1) Entering MASTER STATE
Jul  1 06:19:31 db Keepalived_vrrp: VRRP_Instance(VI_1) setting protocol VIPs.
Jul  1 06:19:31 db Keepalived_vrrp: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth0 for 192.168.1.30
Jul  1 06:19:31 db avahi-daemon[2425]: Registering new address record for 192.168.1.30 on eth0.
Jul  1 06:19:31 db Keepalived_healthcheckers: Netlink reflector reports IP 192.168.1.30 added
Jul  1 06:19:31 db Keepalived_vrrp: Netlink reflector reports IP 192.168.1.30 added

Jul  1 06:19:36 db Keepalived_vrrp: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth0 for 192.168.1.30
B. ping 192.168.1.30有返回值则OK。
可以在服务器master服务器上执行:ip add show eth0
看看是否有192.168.1.30的虚拟IP存在,存在则正常。


到此完成了keepalived的配置。只要在真实机器上启动相应的服务看看是否正常,有问题记得日志。到此完成了keepalived的双机配置。






本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/23251/showart_1982307.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP