码迷,mamicode.com
首页 > 其他好文 > 详细

keepalived源码安装及主备配置

时间:2015-11-23 15:01:24      阅读:170      评论:0      收藏:0      [点我收藏+]

标签:linux   keepalived   

keepavlied起初专门为LVS设计的,专门用来监控LVS集群系统中各个服务节点的状态,后来加入VRRP功能,因此除了配合LVS服务外,也可以作为其他服务(nginx,haproxy)的高可用软件。


keepalived服务两大用途:healthcheck 健康检查(针对RS) 、failover 高可用故障转移(主备)


keepalived的安装,主和备都需要安装

和LVS安装一样,最好也先给内核路径做一个软连接到/usr/src/linux

[root@localhost ~]# ln -s /usr/src/kernels/2.6.32-573.8.1.el6.i686/ /usr/src/linux
[root@localhost ~]# cd /usr/local/src/
[root@localhost src]# wget [root@localhost src]# tar xf keepalived-1.1.19.tar.gz
[root@localhost src]# cd keepalived-1.1.19
[root@localhost keepalived-1.1.19]# ./configure

configure执行成功的结果:有3个Yes;支持IPVS框架,IPVS的同步支持,VRRP的框架支持;
Keepalived configuration
------------------------
Keepalived version : 1.1.19
Compiler : gcc
Compiler flags : -g -O2
Extra Lib : -lpopt -lssl -lcrypto
Use IPVS Framework : Yes
IPVS sync daemon support : Yes
Use VRRP Framework : Yes
Use Debug flags : No

[root@localhost keepalived-1.1.19]# make
[root@localhost keepalived-1.1.19]# make install

配置keepalived

[root@localhost keepalived-1.1.19]# cp /usr/local/etc/rc.d/init.d/keepalived /etc/init.d/
[root@localhost keepalived-1.1.19]# cp /usr/local/etc/sysconfig/keepalived /etc/sysconfig/
[root@localhost keepalived-1.1.19]# mkdir /etc/keepalived -p
[root@localhost keepalived-1.1.19]# cp /usr/local/etc/keepalived/keepalived.conf /etc/keepalived/
[root@localhost keepalived-1.1.19]# cp /usr/local/sbin/keepalived /usr/sbin/
[root@localhost keepalived-1.1.19]# /etc/init.d/keepalived start


主MASTER、备backup上配置文件:/etc/keepalived/keepalived.conf

主master配置:

vrrp_instance VI_1 {
 state MASTER
 interface eth0
 virtual_router_id 51
 priority 150
 advert_int 1
 authentication {
 auth_type PASS
 auth_pass 1111
 }
virtual_ipaddress {
 192.168.20.100/24
 }
}

备 backup 的配置:

vrrp_instance VI_1 {
 state BACKUP
 interface eth0
 virtual_router_id 51
 priority 100
 advert_int 1
 authentication {
 auth_type PASS
 auth_pass 1111
 }
virtual_ipaddress {
 192.168.20.100/24
 }
}

主、备启动keepalived,主绑定VIP地址,主停止keepalived服务,备机马上接管VIP;



本文出自 “模范生的学习博客” 博客,请务必保留此出处http://mofansheng.blog.51cto.com/8792265/1715866

keepalived源码安装及主备配置

标签:linux   keepalived   

原文地址:http://mofansheng.blog.51cto.com/8792265/1715866

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!