在做HA的时候需要为服务器设计虚拟IP,也就是一个主机对应多个IP地址?刚听起来好神奇,原来这样也是可能的
看了下面的这个链接 自己配了一下http://hi.baidu.com/pbottle/item/7175d29702a0a0bd83d29533在eth0处引用别名,设置完子网掩码即可ifconfig eth0:0 166.111.69.100 netmask 255.255.255.0 upifconfig查看此时的信息点击(此处)折叠或打开
- eth0 Link encap:Ethernet HWaddr 08:00:27:64:59:11
- inet addr:166.111.69.17 Bcast:166.111.69.255 Mask:255.255.255.0
- inet6 addr: 2402:f000:1:4412:a00:27ff:fe64:5911/64 Scope:Global
- inet6 addr: fe80::a00:27ff:fe64:5911/64 Scope:Link
- UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
- RX packets:597673 errors:0 dropped:0 overruns:0 frame:0
- TX packets:215472 errors:0 dropped:0 overruns:0 carrier:0
- collisions:0 txqueuelen:1000
- RX bytes:67285933 (67.2 MB) TX bytes:22782158 (22.7 MB)
- eth0:0 Link encap:Ethernet HWaddr 08:00:27:64:59:11
- inet addr:166.111.69.100 Bcast:166.111.69.255 Mask:255.255.255.0
- UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
- lo Link encap:Local Loopback
- inet addr:127.0.0.1 Mask:255.0.0.0
- inet6 addr: ::1/128 Scope:Host
- UP LOOPBACK RUNNING MTU:16436 Metric:1
- RX packets:843 errors:0 dropped:0 overruns:0 frame:0
- TX packets:843 errors:0 dropped:0 overruns:0 carrier:0
- collisions:0 txqueuelen:0
- RX bytes:67174 (67.1 KB) TX bytes:67174 (67.1 KB)
然后找另一台机器ping这个vip(eth0:0)就可以看到显示结果了。
写在/etc/rc.local里也可以,写在这里就不怕断电后机器无法正常使用了。