centos7系统keepalvie高可用(抢占式)

2021/4/9 7:30:14

本文主要是介绍centos7系统keepalvie高可用(抢占式),对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

一、基础环境

master: 192.168.203.128
slave: 192.168.203.129
VIP 192.168.203.130

二、安装keepalive

1、 创建依赖环境

yum -y install openssl-devel gcc gcc-c++
mkdir /etc/keepalived
wget https://www.keepalived.org/software/keepalived-2.0.18.tar.gz

2、安装keepalived

tar -zxvf keepalived-2.0.18.tar.gz
mv keepalived-2.0.18 /usr/local/keepalived
cd /usr/local/keepalived
./configure && make && make install

3、创建启动文件

cp  -a /usr/local/etc/keepalived   /etc/init.d/
cp  -a /usr/local/etc/sysconfig/keepalived    /etc/sysconfig/
cp  -a /usr/local/sbin/keepalived    /usr/sbin/

4、创建配置文件

1 master
vim /etc/keepalived/keepalived.conf

global_defs {
       router_id internal_control
}
vrrp_instance VI_1 {
       state MASTER
       interface ens33
       virtual_router_id 3
       priority 200
       advert_int 1 
       authentication {
               auth_type PASS
               auth_pass 123456
       }
       virtual_ipaddress {
               192.168.203.130/24

       }
}

2 slave
vim /etc/keepalived/keepalived.conf

global_defs {
       router_id internal_control
}
vrrp_instance VI_1 {
       state BACKUP
       interface ens33
       virtual_router_id 3
       priority 90
       advert_int 1 
       authentication {
               auth_type PASS
               auth_pass 123456
       }
       virtual_ipaddress {
               192.168.203.130/24

       }
}

5、启动keepalived(2台机器)

systemctl start keepalived
systemctl enable keepalived

查看maser上已经有vip地址了
centos7系统keepalvie高可用(抢占式)

三、测试

1 master关闭keepalived

systemctl stop keepalived 

2 salve查看vip地址
centos7系统keepalvie高可用(抢占式)



这篇关于centos7系统keepalvie高可用(抢占式)的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程