• linux下如何设置vip(虚拟ip)


    在做HA的时候需要为服务器设计虚拟IP,也就是一个主机对应多个IP地址?刚听起来好神奇,原来这样也是可能的
    看了下面的这个链接 自己配了一下
    http://hi.baidu.com/pbottle/item/7175d29702a0a0bd83d29533

    在eth0处引用别名,设置完子网掩码即可
    ifconfig eth0:0 166.111.69.100 netmask 255.255.255.0 up
    ifconfig查看此时的信息

    点击(此处)折叠或打开

    1. eth0 Link encap:Ethernet HWaddr 08:00:27:64:59:11 
    2.           inet addr:166.111.69.17 Bcast:166.111.69.255 Mask:255.255.255.0
    3.           inet6 addr: 2402:f000:1:4412:a00:27ff:fe64:5911/64 Scope:Global
    4.           inet6 addr: fe80::a00:27ff:fe64:5911/64 Scope:Link
    5.           UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
    6.           RX packets:597673 errors:0 dropped:0 overruns:0 frame:0
    7.           TX packets:215472 errors:0 dropped:0 overruns:0 carrier:0
    8.           collisions:0 txqueuelen:1000 
    9.           RX bytes:67285933 (67.2 MB) TX bytes:22782158 (22.7 MB)
    10. eth0:0 Link encap:Ethernet HWaddr 08:00:27:64:59:11 
    11.           inet addr:166.111.69.100 Bcast:166.111.69.255 Mask:255.255.255.0
    12.           UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
    13. lo Link encap:Local Loopback 
    14.           inet addr:127.0.0.1 Mask:255.0.0.0
    15.           inet6 addr: ::1/128 Scope:Host
    16.           UP LOOPBACK RUNNING MTU:16436 Metric:1
    17.           RX packets:843 errors:0 dropped:0 overruns:0 frame:0
    18.           TX packets:843 errors:0 dropped:0 overruns:0 carrier:0
    19.           collisions:0 txqueuelen:0 
    20.           RX bytes:67174 (67.1 KB) TX bytes:67174 (67.1 KB)

    然后找另一台机器ping这个vip(eth0:0)就可以看到显示结果了。
    写在/etc/rc.local里也可以,写在这里就不怕断电后机器无法正常使用了。

  • 相关阅读:
    centos下修改hosts文件以及生效命令
    CentOS 7 上安装(LAMP)服务 Linux,Apache,MySQL,PHP
    sqlserver下载地址及密匙
    npm/gulp/nodejs
    sp_addlinkedserver 跨服务器连接数据库查询
    sql使用临时表循环
    nodejs和npm
    扫描输入后自动定位到下一个输入框
    Unable to load the specified metadata resource
    mysql保存乱码(C#)
  • 原文地址:https://www.cnblogs.com/duanxz/p/5011570.html
Copyright © 2020-2023  润新知