keepalived配置

两台主机
实机ip
web1:10.0.17.205
wen2:10.0.17.206

VIP
10.0.17.250

web1

yum install httpd -y
yum install keepalived
nmcli connection add con-name ens33 ifname ens33 type ethernet
nmcli connection modify ens33 ipv4.method manual ipv4.addresses 10.0.17.205/24 connection.autoconnect yes
nmcli connection up ens33
echo "10.0.17.205" >/var/www/html/index.html
systemctl restart httpd
iptables -F
firewall-cmd --set-default-zone=trusted

配置keepalived

vi /etc/keepalived/keepalived.conf
global_defs {
   router_id web1
   vrrp_iptables
}
vrrp_instance VI_1 {
    state MASTER
    interface ens33
    virtual_router_id 51
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        10.0.17.250:80
    }
}

systemctl enable keepalived.service
systemctl start keepalived.service

web2

yum install httpd -y
yum install keepalived
nmcli connection add con-name ens33 ifname ens33 type ethernet
nmcli connection modify ens33 ipv4.method manual ipv4.addresses 10.0.17.206/24 connection.autoconnect yes
nmcli connection up ens33
echo "10.0.17.206" >/var/www/html/index.html
systemctl restart httpd
iptables -F
firewall-cmd --set-default-zone=trusted

配置keepalived

vi /etc/keepalived/keepalived.conf

global_defs {
   router_id web1
   vrrp_iptables
}
vrrp_instance VI_1 {
    state BACKUP
    interface ens33
    virtual_router_id 51
    priority 50
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        10.0.17.250:80
    }
}


systemctl enable keepalived.service
systemctl start keepalived.service
  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值