首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 开源软件 >

KeepAlived装配与配置

2014-01-03 
KeepAlived安装与配置#./configure --prefix/usr/local/keepalived-1.2.9# make# make install? ??? ? 安

KeepAlived安装与配置
# ./configure --prefix=/usr/local/keepalived-1.2.9# make# make install

? ??

? ? 安装keepalived的启动服务

cp /usr/local/keepalived-1.2.9/etc/rc.d/init.d/keepalived /etc/rc.d/init.d/cp /usr/local/keepalived-1.2.9/etc/sysconfig/keepalived /etc/sysconfig/mkdir /etc/keepalivedcp /usr/local/keepalived-1.2.9/etc/keepalived/keepalived.conf /etc/keepalived/ln -s /usr/local/keepalived-1.2.9/sbin/keepalived /usr/sbin/service keepalived start设置随机器启动:chkconfig keepalived on

?

三:配置keepalived(Master / Slave模式)

master配置

! Configuration File for keepalivedglobal_defs {   notification_email {     mircox@163.com   }   notification_email_from mircox@163.com   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 1    authentication {        auth_type PASS        auth_pass 1111    }    virtual_ipaddress {        192.168.1.41    }}#其实这里是个增强。vrrp_instance VI_2 {    state BACKUP    interface eth0    virtual_router_id 52    priority 90    advert_int 1    authentication {        auth_type PASS        auth_pass 1111    }    virtual_ipaddress {        192.168.1.51    }}

?

salve配置

! Configuration File for keepalivedglobal_defs {   notification_email {     mircox@163.com   }   notification_email_from mircox@163.com   smtp_server smtp.163.com   smtp_connect_timeout 30   router_id LVS_DEVEL}vrrp_instance VI_1 {    state BACKUP    interface eth0    virtual_router_id 51    priority 90    advert_int 1    authentication {        auth_type PASS        auth_pass 1111    }    virtual_ipaddress {        192.168.1.51    }}vrrp_instance VI_2 {    state MASTER    interface eth0    virtual_router_id 52    priority 100    advert_int 1    authentication {        auth_type PASS        auth_pass 1111    }    virtual_ipaddress {        192.168.1.51    }}

?

附属conf的备注:

global_defs?{

???notification_email {
?????xxxxxx@sina.com???#设置报警邮件地址,可以设置多个,每行一个。需要开启sendmail服务。
???}
???notification_email_from?keepalived@localhost??#设置邮件的发送地址
???smtp_server 127.0.0.1?????????????????????????#设置SMTP Server地址
???smtp_connect_timeout 30???????????????????????#设置SMTP Server的超时时间
???router_id LVS_DEVEL??????????#表示运行Keepalived服务器的一个标识。发邮件时显示大邮件主题中的信息
}
vrrp_instance VI_1 {????????????#vrrp 实例定义部分
????state MASTER????????????????#指定Keepalived的角色,MASTER表示些主机是主服务器。BACKUP表示此主机是备用服务器?
????interface eth1??????????????#指定HA监测网络的接口
????virtual_router_id 51????????#虚拟路由标识,这个标识是一个数字,同一个vrrp实例使用唯一的标识,即同一个vrrp_instance下MASTER与BACKUP必须是一致的
????priority 50?????????????????#定义优先级,数字越大,优先级越高
????authentication {
????????auth_type PASS??????????#设置验证类型和密码,MASTER和BACKUP必须使用相同的密码才能正常通信
????????auth_pass 1111
????}
????virtual_ipaddress {????????#设置虚拟IP地址,可以设置多个虚拟IP地址,每行一个
???????192.168.100.250
????}
}
virtual_server 192.168.100.250 80 {???#设置虚拟服务器,需要指定虚拟IP地址和服务端口,IP与端口之间用空格隔开
????delay_loop 6?????????????????#设置运行情况检查时间,单位为秒
????lb_algo rr????????????????#设置负载调度算法,这里设置rr,即轮询算法
????lib_kind DR???????????????#设置LVS实现负载均衡机制,有NAT、TUN、DR三个模式可选
????persistence_timeout 60????#会话保持单位时间,单位是秒
????protocol TCP??????????????#指定转发协议类型,有TCP和UDP两种
????real_server 192.168.100.60 80 {??#配置服务节点1,需要指定real server的真实IP地址和端口
????????weight 1?????????????????????#配置服务节点的权值,权值数字越大,权值越高
????????TCP_CHECK {??????????????????#relserve的状态检测设置部分,单位是秒
??????????????????connect_timeout 10 #表示10秒无响应超时
??????????????????nb_get_retry 3?????#表示重试次数
???????????dealy_before_retry 3??#表示重试间隔
?}
????}
????real_server 192.168.100.80 80 {
????????weight 1
????????TCP_CHECK {
?????????????????connect_timeout 10??#表示10秒无响应超时
?????????????????nb_get_retry 3?????#表示重试次数
??????????dealy_before_retry 3??#表示重试间隔
?}
????}
}

热点排行