1、实验原理:
在企业中,如果只有一台调度器,那么如果它出现问题,将造成不可估量的损失,所以企业会使用两台调度器,主调度器正常工作,如果出现问题那么辅调度器接替它继续工作,不会影响业务。
2、实验环境
主和备两台调度器要有所有主机的解析,包括自己
server1:主调度器 IP:172.25.1.101
server4:辅调度器 IP:172.25.1.103
server2:服务器 IP:172.25.1.102
server3:服务器 IP:172.25.1.103
测试机:172.25.1.1
3、配置
server1
keepalived-2.0.17.tar.gz 自己下载压缩包
tar -zxf keepalived-2.0.17.tar.gz
yum install gcc openssl-devel 安装源码编译所需要的环境
cd keepalived-2.0.17
./configure --prefix=/usr/local/keepalived --with-init=systemdls
make && make install
ln -s /usr/local/keepalived/etc/keepalived/ /etc/
/etc/init.d/ldirectord stop
chkconfig ldirectord off
cat /usr/lib/systemd/system/keeplived.service
vim /etc/keepalived/keepalived.conf
global_defs {
notification_email {
root@localhost
}
notification_email_from keepalived@localhost
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id LVS_DEVEL
vrrp_skip_check_adv_addr
#vrrp_strict
vrrp_garp_interval 0
vrrp_gna_interval 0
}
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 {
172.25.1.101
}
}
virtual_server 172.25.1.101 80 { #sserver1 ip地址
delay_loop 6
lb_algo rr
lb_kind DR
#persistence_timeout 50
protocol TCP
real_server 172.25.1.102 80 {
TCP_CHECK {
weight 1
connect_timeout 3
retry 3
delay_before_retry 3
}
}
real_server 172.25.1.103 80 {
TCP_CHECK {
weight 1
connect_timeout 3
retry 3
delay_before_retry 3
}
}
}
systemctl start keepalived.service
server4
tar -zxf keepalived-2.0.17.tar.gz
yum install gcc openssl-devel
cd keepalived-2.0.17
./configure --prefix=/usr/local/keepalived --with-init=systemdls
make && make install
ln -s /usr/local/keepalived/etc/keepalived/ /etc/
/etc/init.d/ldirectord stop
chkconfig ldirectord off
vim /etc/keepalived/keepalived.conf
vim /etc/keepalived/keepalived.conf
global_defs {
notification_email {
root@localhost
}
notification_email_from keepalived@localhost
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id LVS_DEVEL
vrrp_skip_check_adv_addr
#vrrp_strict
vrrp_garp_interval 0
vrrp_gna_interval 0
}
vrrp_instance VI_1 {
state BACKUP 备用调度器
interface eth0
virtual_router_id 51
priority 50
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
172.25.1.101
}
}
virtual_server 172.25.1.104 80 { #server4 IP地址
delay_loop 6
lb_algo rr
lb_kind DR
#persistence_timeout 50
protocol TCP
real_server 172.25.1.102 80 {
TCP_CHECK {
weight 1
connect_timeout 3
retry 3
delay_before_retry 3
}
}
real_server 172.25.1.103 80 {
TCP_CHECK {
weight 1
connect_timeout 3
retry 3
delay_before_retry 3
}
}
}
systemctl start keepalived.service
server2,server3
systemctl start httpd
4、测试:
关掉主调度器
curl 172.25.1.101
本文介绍如何通过Keepalived实现高可用集群的搭建过程,包括主备调度器的配置与测试步骤。主调度器正常运行,若出现故障则由备调度器接管,确保业务连续性。
694

被折叠的 条评论
为什么被折叠?



