centos7配置虚拟ip_centos临时设置ip

centos7配置虚拟ip_centos临时设置ip环境概览master:192.168.46.26slave1:192.168.46.27测试机:192.168.46.22(用于ping机器)安装keepalivedyuminstall-ykeepalived修改masterkeepalived.conf配置文件vim/etc/keepalived/keepalived.confinterface修改为自己的网卡(使用ipaddr查看)priority修改其参数为188设置为主节点virtual_ipadd

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全系列IDE稳定放心使用

环境概览

master:192.168.46.26
slave1:192.168.46.27
测试机:192.168.46.22(用于ping机器)

安装keepalived

 yum install -y keepalived

修改master keepalived.conf 配置文件

vim /etc/keepalived/keepalived.conf

interface 修改为自己的网卡(使用 ip addr 查看)
priority 修改其参数为188 设置为主节点
virtual_ipaddress 配置虚拟ip
在这里插入图片描述

重启 keepalive 服务

 systemctl restart keepalived.service

查看 虚ip是否启动成功

ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:f5:3d:f3 brd ff:ff:ff:ff:ff:ff
    inet 192.168.46.26/18 brd 192.168.63.255 scope global ens33
       valid_lft forever preferred_lft forever
    `inet 192.168.46.88/32 scope global ens33`
       valid_lft forever preferred_lft forever
    inet6 fe80::345:1d44:e755:79c2/64 scope link
       valid_lft forever preferred_lft forever
3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN qlen 1000
    link/ether 52:54:00:63:02:0a brd ff:ff:ff:ff:ff:ff
    inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
       valid_lft forever preferred_lft forever
4: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN qlen 1000
    link/ether 52:54:00:63:02:0a brd ff:ff:ff:ff:ff:ff

inet 192.168.46.88/32 scope global ens33 表示成功启动虚拟ip

修改slave1 keepalived.conf 配置文件

vim /etc/keepalived/keepalived.conf

interface 修改为自己的网卡(使用 ip addr 查看)
priority 默认即可
virtual_ipaddress 配置虚拟ip
在这里插入图片描述

重启 keepalive 服务

 systemctl restart keepalived.service

查看 虚ip是否启动成功

ip addr
# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:63:37:39 brd ff:ff:ff:ff:ff:ff
    inet 192.168.46.27/18 brd 192.168.63.255 scope global ens33
       valid_lft forever preferred_lft forever
    inet6 fe80::34aa:c1e2:dc99:6721/64 scope link
       valid_lft forever preferred_lft forever
3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN qlen 1000
    link/ether 52:54:00:63:02:0a brd ff:ff:ff:ff:ff:ff
    inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
       valid_lft forever preferred_lft forever
4: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN qlen 1000
    link/ether 52:54:00:63:02:0a brd ff:ff:ff:ff:ff:ff

此节点作为从节点使用当主节点挂掉后,会使用此节点

使用测试机器ping 虚拟ip 看是否可以ping通

# ping 192.168.46.88
PING 192.168.46.88 (192.168.46.88) 56(84) bytes of data.
64 bytes from 192.168.46.88: icmp_seq=1 ttl=64 time=0.149 ms
64 bytes from 192.168.46.88: icmp_seq=2 ttl=64 time=0.303 ms
64 bytes from 192.168.46.88: icmp_seq=3 ttl=64 time=0.380 ms
64 bytes from 192.168.46.88: icmp_seq=4 ttl=64 time=0.239 ms
64 bytes from 192.168.46.88: icmp_seq=5 ttl=64 time=0.324 ms

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/182991.html原文链接:https://javaforall.cn

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)


相关推荐

发表回复

您的电子邮箱地址不会被公开。

关注全栈程序员社区公众号