keepalived做高可用集群
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了keepalived做高可用集群相关的知识,希望对你有一定的参考价值。
keepalived的作用:主要用作RealServer的健康状态检查以及
LoadBalance主机和BackUP主机之间failover的实现。
使用keepalived软件部署网站HA集群: 能够实现任意单故障节点的高可用集群
一、前期准备
1、在两台网站服务器上安装keepalived软件(4.51,4.52)
2、查看配置的路径: rpm -qc keepalived
/etc/keepalived/keepalived.conf
/etc/sysconfig/keepalived
二、修改服务的主配置文件: vim /etc/keepalived/keepalived.conf
1、下面的是更改的配置文件
15 vrrp_instance haweb {
16 state MASTER
17 interface eth0
18 virtual_router_id 51
19 priority 150
20 advert_int 1
21 authentication {
22 auth_type PASS
23 auth_pass 123456
24 }
25 virtual_ipaddress {
26 192.168.4.253
27 }
28 }
2、修改备服务器的主配置文件:vim /etc/keepalived/keepalived.conf
把优先级调低:priority 100
3、分别重启两台服务器的keepalived服务
4、查看是否获取到VIP地址:
ip addr show | grep 192.168.4.
5、测试:当4.51的网站服务停掉时,VIP不会释放,需监控网站服务.
使用keepalived+lvs做高可用HA集群
一、前期准备工作:
1、准备四台主机,两台做web,两台做LVS+keepalived
2、分别安装httpd软件和ipvsadm
二、网站服务器为4.51和4.52:
1、修改网络接口运行参数,
cd /proc/sys/net/ipv4/conf/
echo 1 > lo/arp_ignore //忽略广播包
echo 2 > lo/arp_announce //兄弟接口接收和发送arp包
echo 1 > all/arp_ignore
echo 2 > all/arp_announce
如需开机自动配置,需写在vim /etc/sysctl.conf
net.ipv4.conf.lo.arp_ignore = 1
net.ipv4.conf.lo.arp_announce = 2
net.ipv4.conf.all.arp_ignore = 1
net.ipv4.conf.all.arp_announce = 2
sysctl -p 读一下,使其生效
2、绑定VIP地址:4.253 vim /etc/rc.d/rc.local ifconfig lo:1 192.168.4.253/32
二、配置分发器:4.53和4.54
1、安装软件ipvsadm
2、在主机上都安装keepalived软件
3、修改4.53服务器的主配置文件: vim /etc/keepalived/keepalived.conf
vrrp_instance VI_3 {
state MASTER
interface eth0
virtual_router_id 53
priority 150
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.4.253
}
}
virtual_server 192.168.4.253 80 {
delay_loop 6
lb_algo rr
lb_kind DR
nat_mask 255.255.255.0
protocol TCP
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
real_server 192.168.4.51 80 {
weight 1
}
real_server 192.168.4.52 80 {
weight 1
}
}
4、修改4.54服务器的配置文件: vim /etc/keepalived/keepalived.conf
state BACKUP
priority 100
5、重启服务,验证.
以上是关于keepalived做高可用集群的主要内容,如果未能解决你的问题,请参考以下文章
集群介绍keepalived介绍用keepalived配置高可用集群