keepalived+nginx反向代理实现高可用

部署

这里需要两台服务器

   
@1   192.168.11.11node11keepalived  master   nginx
@2   192.168.11.12node12keepalived  backup  nginx
@3  192.168.11.13node13httpd
@4  192.168.11.14node14httpd

初始环境

关防火墙;关闭selinux ;

getenforce;systemctl  stop  firewalld

  @1@2    keepalived环境配置

[root@node11 ~]# modprobe ip_vs
[root@node11 ~]# lsmod | grep ip_vs
ip_vs                 141092  0 
nf_conntrack          111302  1 ip_vs
libcrc32c              12644  2 xfs,ip_vs
[root@node11 ~]# 

#yum安装keepalived包

[root@node11 ~]# yum -y install  keepalived
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
正在解决依赖关系
--> 正在检查事务
---> 软件包 keepalived.x86_64.0.1.2.13-8.el7 将被 安装
--> 正在处理依赖关系 libnetsnmpmibs.so.31()(64bit),它被软件包 keepalived-1.2.13-8.el7.x86_64 需要
--> 正在处理依赖关系 libnetsnmpagent.so.31()(64bit),它被软件包 keepalived-1.2.13-8.el7.x86_64 需要
--> 正在处理依赖关系 libnetsnmp.so.31()(64bit),它被软件包 keepalived-1.2.13-8.el7.x86_64 需要
--> 正在检查事务
---> 软件包 net-snmp-agent-libs.x86_64.1.5.7.2-24.el7_2.1 将被 安装
---> 软件包 net-snmp-libs.x86_64.1.5.7.2-24.el7_2.1 将被 安装
--> 解决依赖关系完成

依赖关系解决

==================================================================
 Package              架构    版本                   源      大小
==================================================================
正在安装:
 keepalived           x86_64  1.2.13-8.el7           local  224 k
为依赖而安装:
 net-snmp-agent-libs  x86_64  1:5.7.2-24.el7_2.1     local  702 k
 net-snmp-libs        x86_64  1:5.7.2-24.el7_2.1     local  747 k

事务概要
==================================================================
安装  1 软件包 (+2 依赖软件包)

总下载量:1.6 M
安装大小:5.6 M
Downloading packages:
------------------------------------------------------------------
总计                                  13 MB/s | 1.6 MB  00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : 1:net-snmp-libs-5.7.2-24.el7_2.1.x86_64       1/3 
  正在安装    : 1:net-snmp-agent-libs-5.7.2-24.el7_2.1.x86_   2/3 
  正在安装    : keepalived-1.2.13-8.el7.x86_64                3/3 
  验证中      : 1:net-snmp-agent-libs-5.7.2-24.el7_2.1.x86_   1/3 
  验证中      : keepalived-1.2.13-8.el7.x86_64                2/3 
  验证中      : 1:net-snmp-libs-5.7.2-24.el7_2.1.x86_64       3/3 

已安装:
  keepalived.x86_64 0:1.2.13-8.el7                                

作为依赖被安装:
  net-snmp-agent-libs.x86_64 1:5.7.2-24.el7_2.1                   
  net-snmp-libs.x86_64 1:5.7.2-24.el7_2.1                         

完毕!

这里以编译安装keepalived       推荐用编译安装,以下是编译安装keepalivd步骤

安装依赖的包

yum install -y  gcc    gcc-c++    openssl-devel

这里用的是keep alived官网上https://keepalived.org下载的keepalived-2.2.2.查看校验码

[root@node12 ~]# ls
anaconda-ks.cfg  init.sh  keepalived-2.2.2.tar.gz
[root@node12 ~]# md5sum keepalived-2.2.2.tar.gz 
2e86bade4a7a48cfac7d35a6c9643d46  keepalived-2.2.2.tar.gz

 

编译安装显示内容..略

tar xf keepalived-2.2.2.tar.gz   -C  /usr/src/

cd    /usr/src/keepalived-2.2.2/

 ./configure --prefix=/usr/local/keepalived

echo  $?

make  &&  make install

echo  $?

编辑管理程序文件

vim /usr/local/keepalived/etc/sysconfig/keepalived  #编辑 keepalived 管理程序文
这里只修改KEEPALIVED_OPTIONS=" -f /usr/local/keepalived/etc/keepalived/keepalived.conf  -D"

 

[root@node11 keepalived-2.2.2]# systemctl   daemon-reload
[root@node11 keepalived-2.2.2]# systemctl start keepalived
[root@node11 keepalived-2.2.2]# systemctl status keepalived● keepalived.service - LVS and VRRP High Availability Monitor
   Loaded: loaded (/usr/lib/systemd/system/keepalived.service; disabled; vendor preset: disabled)
   Active: active (running) since 六 2021-06-19 18:35:34 CST; 6s ago
  Process: 40439 ExecStart=/usr/local/keepalived/sbin/keepalived $KEEPALIVED_OPTIONS (code=exited, status=0/SUCCESS)
 Main PID: 40440 (keepalived)
   CGroup: /system.slice/keepalived.service
           ├─40440 /usr/local/keepalived/sbin/keepalived...
           ├─40441 /usr/local/keepalived/sbin/keepalived...
           └─40442 /usr/local/keepalived/sbin/keepalived...

6月 19 18:35:38 node11 Keepalived_vrrp[40442]: Sending ...
6月 19 18:35:38 node11 Keepalived_vrrp[40442]: Sending ...
6月 19 18:35:38 node11 Keepalived_vrrp[40442]: Sending ...
6月 19 18:35:39 node11 Keepalived_healthcheckers[40441]: ...
6月 19 18:35:39 node11 Keepalived_healthcheckers[40441]: ...
6月 19 18:35:39 node11 Keepalived_healthcheckers[40441]: ...
6月 19 18:35:40 node11 Keepalived_healthcheckers[40441]: ...
6月 19 18:35:40 node11 Keepalived_healthcheckers[40441]: ...
6月 19 18:35:40 node11 Keepalived_healthcheckers[40441]: ...
6月 19 18:35:40 node11 Keepalived_healthcheckers[40441]: ...
Hint: Some lines were ellipsized, use -l to show in full.

 

如果开启报错查看文件/usr/lib/systemd/system/keepalived.service

 

[Unit]
Description=LVS and VRRP High Availability Monitor
After=network-online.target syslog.target 
Wants=network-online.target 

[Service]
Type=forking
PIDFile=/run/keepalived.pid
KillMode=process
EnvironmentFile=-/usr/local/keepalived/etc/sysconfig/keepalived
ExecStart=/usr/local/keepalived/sbin/keepalived  $KEEPALIVED_OPTIONS
ExecReload=/bin/kill -HUP $MAINPID

[Install]
WantedBy=multi-user.target

编辑著配置文件

[root@node11 ~]# cat /usr/local/keepalived/etc/keepalived/keepalived.conf
! Configuration File for keepalived

global_defs {
   notification_email {
     acassen@firewall.loc
     failover@firewall.loc
     sysadmin@firewall.loc
   }
   notification_email_from Alexandre.Cassen@firewall.loc
   smtp_server 192.168.200.1
   smtp_connect_timeout 30
   router_id node11
   vrrp_skip_check_adv_addr
   vrrp_strict
   vrrp_garp_interval 0
   vrrp_gna_interval 0
}
include /etc/keepalived/conf.d/*.conf

 

编辑子配置文件

[root@node11 ~]# mkdir /etc/keepalived/conf.d/*.conf  
[root@node11 ~]# vim /etc/keepalived/conf.d/cluster1.conf 

  1 
  2 vrrp_instance VI_1 {
  3         state MASTER
  4         interface eth0
  5         virtual_router_id 80
  6         priority 100
  7         advert_int 1
  8         authentication {
  9         auth_type PASS
 10         auth_pass 1234567
 11         }
 12 virtual_ipaddress {
 13         192.168.11.111
 14 
 15         }

@1@2  配置相同

 [root@node11 ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo   http://mirrors.aliyun.com/repo/Centos-7.repo
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  2523  100  2523    0     0  24042      0 --:--:-- --:--:-- --:--:-- 24259
[root@node11 ~]# echo $?
0
[root@node11 ~]# yum install -y epel-release
已加载插件:fastestmirror, langpacks
base                                                                                   | 3.6 kB  00:00:00     
extras                                                                                 | 2.9 kB  00:00:00     
updates                                                                                | 2.9 kB  00:00:00     
(1/4): base/7/x86_64/group_gz                                                          | 153 kB  00:00:00     
(2/4): extras/7/x86_64/primary_db                                                      | 242 kB  00:00:00     
(3/4): updates/7/x86_64/primary_db                                                     | 8.8 MB  00:00:09     
base/7/x86_64/primary_db       FAILED                                          
http://mirrors.aliyuncs.com/centos/7/os/x86_64/repodata/6d0c3a488c282fe537794b5946b01e28c7f44db79097bb06826e1c0c88bad5ef-primary.sqlite.bz2: [Errno 14] curl#7 - "Failed connect to mirrors.aliyuncs.com:80; Connection refused"
正在尝试其它镜像。
(4/4): base/7/x86_64/primary_db                                                        | 6.1 MB  00:00:05     
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 epel-release.noarch.0.7-11 将被 安装
--> 解决依赖关系完成

依赖关系解决

==============================================================================================================
 Package                       架构                    版本                     源                       大小
==============================================================================================================
正在安装:
 epel-release                  noarch                  7-11                     extras                   15 k

事务概要
==============================================================================================================
安装  1 软件包

总下载量:15 k
安装大小:24 k
Downloading packages:
警告:/var/cache/yum/x86_64/7/extras/packages/epel-release-7-11.noarch.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
epel-release-7-11.noarch.rpm 的公钥尚未安装
epel-release-7-11.noarch.rpm                                                           |  15 kB  00:00:00     
从 http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 检索密钥
导入 GPG key 0xF4A80EB5:
 用户ID     : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
 指纹       : 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
 来自       : http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : epel-release-7-11.noarch                                                                  1/1 
  验证中      : epel-release-7-11.noarch                                                                  1/1 

已安装:
  epel-release.noarch 0:7-11                                                                                  

完毕![root@node11 ~]# yum -y install  *.rpm
已加载插件:fastestmirror, langpacks
正在检查 nginx-1.16.1-1.el7.ngx.x86_64.rpm: 1:nginx-1.16.1-1.el7.ngx.x86_64
nginx-1.16.1-1.el7.ngx.x86_64.rpm 将被安装
正在检查 openssl-1.0.2k-16.el7_6.1.x86_64.rpm: 1:openssl-1.0.2k-16.el7_6.1.x86_64
openssl-1.0.2k-16.el7_6.1.x86_64.rpm 将作为 1:openssl-1.0.1e-60.el7.x86_64 的更新
正在检查 openssl-libs-1.0.2k-16.el7_6.1.x86_64.rpm: 1:openssl-libs-1.0.2k-16.el7_6.1.x86_64
openssl-libs-1.0.2k-16.el7_6.1.x86_64.rpm 将作为 1:openssl-libs-1.0.1e-60.el7.x86_64 的更新
正在解决依赖关系
--> 正在检查事务
---> 软件包 nginx.x86_64.1.1.16.1-1.el7.ngx 将被 安装
---> 软件包 openssl.x86_64.1.1.0.1e-60.el7 将被 升级
---> 软件包 openssl.x86_64.1.1.0.2k-16.el7_6.1 将被 更新
---> 软件包 openssl-libs.x86_64.1.1.0.1e-60.el7 将被 升级
--> 正在处理依赖关系 openssl-libs(x86-64) = 1:1.0.1e-60.el7,它被软件包 1:openssl-devel-1.0.1e-60.el7.x86_64 需要
epel/x86_64/metalink                                                                   | 4.6 kB  00:00:00     
epel                                                                                   | 4.7 kB  00:00:00     
(1/3): epel/x86_64/group_gz                                                            |  96 kB  00:00:00     
(2/3): epel/x86_64/primary_db                                                          | 6.9 MB  00:00:01     
epel/x86_64/updateinfo         FAILED                                          
http://mirrors.bfsu.edu.cn/epel/7/x86_64/repodata/2f6aaa026d823cf27f25d27c50cb007a33a6b2c0df8117fac6b81b6085334169-updateinfo.xml.bz2: [Errno 14] HTTP Error 404 - Not Found
正在尝试其它镜像。
To address this issue please refer to the below knowledge base article 

https://access.redhat.com/articles/1320623

If above article doesn't help to resolve this issue please create a bug on https://bugs.centos.org/

(3/3): epel/x86_64/updateinfo                                                          | 1.0 MB  00:00:00     
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * epel: mirrors.bfsu.edu.cn
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
---> 软件包 openssl-libs.x86_64.1.1.0.2k-16.el7_6.1 将被 更新
--> 正在检查事务
---> 软件包 openssl-devel.x86_64.1.1.0.1e-60.el7 将被 升级
---> 软件包 openssl-devel.x86_64.1.1.0.2k-21.el7_9 将被 更新
--> 正在处理依赖关系 openssl-libs(x86-64) = 1:1.0.2k-21.el7_9,它被软件包 1:openssl-devel-1.0.2k-21.el7_9.x86_64 需要
--> 正在检查事务
---> 软件包 openssl.x86_64.1.1.0.1e-60.el7 将被 升级
---> 软件包 openssl.x86_64.1.1.0.1e-60.el7 将被 升级
---> 软件包 openssl.x86_64.1.1.0.2k-16.el7_6.1 将被 更新
---> 软件包 openssl.x86_64.1.1.0.2k-21.el7_9 将被 更新
---> 软件包 openssl-libs.x86_64.1.1.0.1e-60.el7 将被 升级
---> 软件包 openssl-libs.x86_64.1.1.0.1e-60.el7 将被 升级
---> 软件包 openssl-libs.x86_64.1.1.0.2k-16.el7_6.1 将被 更新
---> 软件包 openssl-libs.x86_64.1.1.0.2k-21.el7_9 将被 更新
--> 解决依赖关系完成

依赖关系解决

==============================================================================================================
 Package               架构           版本                       源                                      大小
==============================================================================================================
正在安装:
 nginx                 x86_64         1:1.16.1-1.el7.ngx         /nginx-1.16.1-1.el7.ngx.x86_64         2.7 M
正在更新:
 openssl               x86_64         1:1.0.2k-21.el7_9          updates                                493 k
为依赖而更新:
 openssl-devel         x86_64         1:1.0.2k-21.el7_9          updates                                1.5 M
 openssl-libs          x86_64         1:1.0.2k-21.el7_9          updates                                1.2 M

事务概要
==============================================================================================================
安装  1 软件包
升级  1 软件包 (+2 依赖软件包)

总计:5.9 M
总下载量:3.2 M
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
openssl-devel-1.0.2k-21.el7_9. FAILED                                          0.0 B/s | 295 kB  --:--:-- ETA 
http://mirrors.cloud.aliyuncs.com/centos/7/updates/x86_64/Packages/openssl-devel-1.0.2k-21.el7_9.x86_64.rpm: [Errno 14] curl#6 - "Could not resolve host: mirrors.cloud.aliyuncs.com; Name or service not known"
正在尝试其它镜像。
(1/3): openssl-1.0.2k-21.el7_9.x86_64.rpm                                              | 493 kB  00:00:00     
(2/3): openssl-libs-1.0.2k-21.el7_9.x86_64.rpm                                         | 1.2 MB  00:00:02     
(3/3): openssl-devel-1.0.2k-21.el7_9.x86_64.rpm                                        | 1.5 MB  00:00:01     
--------------------------------------------------------------------------------------------------------------
总计                                                                          1.2 MB/s | 3.2 MB  00:00:02     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在更新    : 1:openssl-libs-1.0.2k-21.el7_9.x86_64                                                     1/7 
  正在更新    : 1:openssl-1.0.2k-21.el7_9.x86_64                                                          2/7 
  正在安装    : 1:nginx-1.16.1-1.el7.ngx.x86_64                                                           3/7 
----------------------------------------------------------------------

Thanks for using nginx!

Please find the official documentation for nginx here:
* http://nginx.org/en/docs/

Please subscribe to nginx-announce mailing list to get
the most important news about nginx:
* http://nginx.org/en/support.html

Commercial subscriptions for nginx are available on:
* http://nginx.com/products/

----------------------------------------------------------------------
  正在更新    : 1:openssl-devel-1.0.2k-21.el7_9.x86_64                                                    4/7 
  清理        : 1:openssl-devel-1.0.1e-60.el7.x86_64                                                      5/7 
  清理        : 1:openssl-1.0.1e-60.el7.x86_64                                                            6/7 
  清理        : 1:openssl-libs-1.0.1e-60.el7.x86_64                                                       7/7 
  验证中      : 1:openssl-devel-1.0.2k-21.el7_9.x86_64                                                    1/7 
  验证中      : 1:openssl-1.0.2k-21.el7_9.x86_64                                                          2/7 
  验证中      : 1:openssl-libs-1.0.2k-21.el7_9.x86_64                                                     3/7 
  验证中      : 1:nginx-1.16.1-1.el7.ngx.x86_64                                                           4/7 
  验证中      : 1:openssl-libs-1.0.1e-60.el7.x86_64                                                       5/7 
  验证中      : 1:openssl-devel-1.0.1e-60.el7.x86_64                                                      6/7 
  验证中      : 1:openssl-1.0.1e-60.el7.x86_64                                                            7/7 

已安装:
  nginx.x86_64 1:1.16.1-1.el7.ngx                                                                             

更新完毕:
  openssl.x86_64 1:1.0.2k-21.el7_9                                                                            

作为依赖被升级:
  openssl-devel.x86_64 1:1.0.2k-21.el7_9                 openssl-libs.x86_64 1:1.0.2k-21.el7_9                

完毕!
[root@node11 ~]# vim /etc/nginx/nginx.conf 

user  nginx;
worker_processes  1;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    #gzip  on;

    include /etc/nginx/conf.d/*.conf;

upstream webser {             #主要添加这九行

        server 192.168.11.13:80 weight=1;  

        server 192.168.11.14:80 weight=1;

    }



server {

        location / {

            proxy_pass http://webser/;

        }

    }

}
[root@node11 ~]vim /usr/local/keepalived/etc/keepalived/keepalived.conf
! Configuration File for keepalived

global_defs {
   notification_email {
     acassen@firewall.loc
     failover@firewall.loc
     sysadmin@firewall.loc
   }
   notification_email_from Alexandre.Cassen@firewall.loc
   smtp_server 192.168.200.1
   smtp_connect_timeout 30
   router_id node11                 #另一台改为主机名,可以一样,可以不一样,基本没有影响
   vrrp_skip_check_adv_addr
   vrrp_strict
   vrrp_garp_interval 0
   vrrp_gna_interval 0
}
include /etc/keepalived/conf.d/*.conf
[root@node11 ~]# cat /etc/keepalived/conf.d/cluster1.conf 
vrrp_script ch_nginx {

    script "/usr/bin/killall -0 nginx"

    interval 2

    weight -30

    fall 3

    rise 5

    timeout 2

}

vrrp_instance VI_1 {
        state MASTER        #另一台改为BACKUP
        interface eth0
        virtual_router_id 80  
        priority 100            #另一台优先权改为80,比100小     
        advert_int 1
        authentication {
        auth_type PASS
        auth_pass 1234567
        }
virtual_ipaddress {  
        192.168.11.111

        }      
 track_script {

        ch_nginx

        }
}

rtual_server 192.168.11.111 80 {
        delay_loop 3
        lb_algo rr
        lb_kind NAT
        protocol TCP


real_server 192.168.11.13 80 {
        weight 1
        HTTP_GET {
        url {
        path /
        status_code 200
        }   
        connect_timeout 1
        nb_get_retry 3
        delay_before_retry 1
        }
}

real_server 192.168.11.14 80 {
        weight 1
        HTTP_GET {
        url {
        path /
        status_code 200
        }       
        connect_timeout 1
        nb_get_retry 3
        delay_before_retry 1
        }
    }   

}
[root@node11 ~]# nginx
[root@node11 ~]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[root@node11 ~]# systemctl  restart  keepalived
[root@node11 ~]# yum install psmisc -y
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * epel: mirrors.bfsu.edu.cn
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 psmisc.x86_64.0.22.20-17.el7 将被 安装
--> 解决依赖关系完成

依赖关系解决

==============================================================================================================
 Package                 架构                    版本                             源                     大小
==============================================================================================================
正在安装:
 psmisc                  x86_64                  22.20-17.el7                     base                  141 k

事务概要
==============================================================================================================
安装  1 软件包

总下载量:141 k
安装大小:475 k
Downloading packages:
psmisc-22.20-17.el7.x86_64.rpm                                                         | 141 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : psmisc-22.20-17.el7.x86_64                                                                1/1 
  验证中      : psmisc-22.20-17.el7.x86_64                                                                1/1 

已安装:
  psmisc.x86_64 0:22.20-17.el7                                                                                

完毕!

[root@node11 ~]# ip a
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: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:bc:cb:e3 brd ff:ff:ff:ff:ff:ff
    inet 192.168.11.11/24 brd 192.168.11.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet 192.168.11.111/32 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:febc:cbe3/64 scope link 
       valid_lft forever preferred_lft forever

[root@node11 ~]# nginx -s stop
[root@node11 ~]# ip a                    #此时VIP飘逸到@2号机
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: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:bc:cb:e3 brd ff:ff:ff:ff:ff:ff
    inet 192.168.11.11/24 brd 192.168.11.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:febc:cbe3/64 scope link 
       valid_lft forever preferred_lft forever

@2主机上ip a 发现VIP飘逸过来了

[root@node12 ~]# ip a
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: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:49:c0:69 brd ff:ff:ff:ff:ff:ff
    inet 192.168.11.12/24 brd 192.168.11.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet 192.168.11.111/32 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:fe49:c069/64 scope link 
       valid_lft forever preferred_lft forever

 

 

 

 

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值