本篇内容主要讲解“centos7上keepalived的安装和配置方法”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“centos7上keepalived的安装和配置方法”吧!
创新互联从2013年创立,是专业互联网技术服务公司,拥有项目成都网站建设、网站建设网站策划,项目实施与项目整合能力。我们以让每一个梦想脱颖而出为使命,1280元卢氏做网站,已为上家服务,为卢氏各地企业和个人服务,联系电话:18982081108
1、环境规划
1)master:node1,centos7.5,eth0:192.168.1.11,eht1:10.10.1.11,keepalive
2)backup:node1,centos7.5,eth0:192.168.1.12,eth2:10.10.1.12,keepalive
2、搭建步骤
1)node1,node2上都以mini方式安装CentOS 7.5 64-bit,并按照规划配置IP地址;
2)node1,node2的/etc/hosts中添加如下内容。
192.168.1.11 node1.xx.xxx.com node1
10.10.1.11 node1.xx.xxx.com node1
192.168.1.12 node2.xx.xxx.com node2
10.10.1.12 node2.xx.xxx.com node2
3)node1,node2安装keepalive1.3.5
#yum install keeplived
4)配置node1上的keepalive
vi /etc/keepalived/keepalived.conf #进行如下修改
vrrp_instance VI_1 {
state MASTER #设置节点node1为MASTER角色
interface enp11s0f0 #配置eth0网卡enp11s0f0为节点node1的系统IP
virtual_router_id 51 #master和backup一致
priority 100 #数字越大,等级越高,保证master比任何backup高
advert_int 1
authentication {
auth_type PASS #vrrp协议,保证master及其他backup一致
auth_pass 1111 #保证master及其他backup一致
}
virtual_ipaddress {
192.168.1.210/24 #VIP
}
5)配置节点node2上的keeplive
vi /etc/keepalived/keepalived.conf #进行如下修改
vrrp_instance VI_1 {
state BACKUP #设置节点node2为BACKUP角色
interface enp11s0f0 #配置eth0网卡enp11s0f0为节点node2的系统IP
virtual_router_id 51 #master和backup一致
priority 99 #数字越大,等级越高,保证比master低
advert_int 1
authentication {
auth_type PASS #vrrp协议,保证master及其他backup一致
auth_pass 1111 #保证master及其他backup一致
}
virtual_ipaddress {
192.168.1.210/24 #VIP
}
6)启动和配置keepalive
systemctl start keepalived.service
systemct enable keepalived.service
3、验证
1)查看master上keepalive及ip
ps -ef|grep keepalive
ip addr
2)keepalived高可用测试
#关闭node1上的keepalived
systemctl stop keepalived.service
#查看node1上的keepalived和ip
ps -ef|grep keepalived
ip addr
#查看node2上的keepalived和ip
ps -ef|grep keepalived
ip addr
到此,相信大家对“centos7上keepalived的安装和配置方法”有了更深的了解,不妨来实际操作一番吧!这里是创新互联网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!