1. kvm是否啓動鏡像
1) 現象:kvm啓動qcow2 ubuntu虛擬機過程中,提示
- error were found when checking the disk drive for boot
2) 解決方案
- 鏡像硬盤引導壞了,建議更換qcow2鏡像。
- 更換完了鏡像:啓動後:
如圖所示:有三個網卡driver,說明鏡像啓動過程中正確配置網卡。
- Dhclient eth0可以看到網卡可以正確分配IP地址。
- 如若不能正確分配Ip,說明dhcp服務dnsmasq沒有啓動。
- 重啓dhcp服務器
- 手動配置Ip。見鏈接:
http://blog.csdn.net/qiqishuang/article/details/51541049
2. 檢查網絡鏈接
1) 檢查DNS狀態
- 現象:手動配置Ip地址後發現,可以ping通網關120.0.0.1.但是不能ping通www.baidu.com。說明Dns服務器可能有問題。vi /etc/resolve.conf修改nameserver 192.168.1.4 或者8.8.8.8、8.8.4.4
2) 檢查網絡拓撲鏈接
現象:DNS正確配置後,去宿主機看發現:ping DNS服務器發現同樣ping不通
解決方案:經檢查網絡拓撲鏈接ovs-vsctl show沒有問題。
舉例說明:運行BA run.sh腳本突然Node2節點斷了。
1 從其他服務節點ssh上去。查看路由表發現網關均從br0出去…
2 本機流量全部從br0走,接下來查看br0的連接情況
root@node2:~# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.19.254 0.0.0.0 UG 0 0 0 br0
3 發現br並沒有連接網卡eth0,所以掛上br0即可
Bridge "br0"
Port "br0"
Interface "br0"
type: internal
修改如下:
Bridge "br0"
Port "br0"
Interface "br0"
type: internal
Port "eth0"
Interface "eth0"
3) 檢查NAT鏈接狀態
* NAT檢查如下。
1. 查看NAT是否開啓:有無ba-router
- 檢查NAT各個網口配置狀態
root@node2:/opt/zq# ip netns
ba-router
by-router
by-dhcp
root@node2:/opt/zq# ip netns exec ba-router ifconfig
ein-if Link encap:Ethernet HWaddr b2:fd:be:2f:ea:56
inet addr:192.168.19.224 Bcast:192.168.19.255 Mask:255.255.255.0
inet6 addr: fe80::b0fd:beff:fe2f:ea56/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:29989 errors:0 dropped:431 overruns:0 frame:0
TX packets:11001 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:32724214 (32.7 MB) TX bytes:798147 (798.1 KB)
rout-if Link encap:Ethernet HWaddr b6:17:e8:4b:14:f6
inet addr:120.0.0.1 Bcast:120.0.255.255 Mask:255.255.0.0
inet6 addr: fe80::b417:e8ff:fe4b:14f6/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:11082 errors:0 dropped:0 overruns:0 frame:0
TX packets:16879 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:802068 (802.0 KB) TX bytes:31648717 (31.6 MB)
4) 檢查NAT路由表狀態
由上可知:NAT鏈接沒有問題,所以在查看下NAT路由表:ip netns exec ba-router route -n
現象:查看下路由表route -n,發現沒有路由192.168.1.0/24網段無法出去,默認丟棄或者 默認網關192.168.19.254
root@node2:/tmp/zq# ip netns exec ba-router route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
120.0.0.0 0.0.0.0 255.255.0.0 U 0 0 0 rout-if
192.168.19.0 0.0.0.0 255.255.255.0 U 0 0 0 ein-if
- 解決方案:添加NAT網關: ip netns exec ba-router route add default gw 192.168.19.254
ip netns exec ba-router route add default gw 192.168.19.254
5) 查看NAT路由表
root@node2:/tmp/zq# ip netns exec ba-router route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.19.254 0.0.0.0 UG 0 0 0 ein-if
120.0.0.0 0.0.0.0 255.255.0.0 U 0 0 0 rout-if
192.168.19.0 0.0.0.0 255.255.255.0 U 0 0 0 ein-if
6)添加完路由表後,可以ping通google DNS服務器了。
root@node2:/tmp/zq# ip netns exec ba-router ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=43 time=59.5 ms
64 bytes from 8.8.8.8: icmp_seq=1 ttl=43 time=59.5 ms
64 bytes from 8.8.8.8: icmp_seq=1 ttl=43 time=59.5 ms
^C
— 8.8.8.8 ping statistics —
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 59.574/59.574/59.574/0.000 ms
7)本機路由表:route -n
root@node2:/tmp/zq# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.19.254 0.0.0.0 UG 0 0 0 br0
20.0.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
120.0.0.0 0.0.0.0 255.255.0.0 U 0 0 0 ba-dhcp-if
172.17.0.0 0.0.0.0 255.255.0.0 U 0 0 0 docker0
192.168.19.0 0.0.0.0 255.255.255.0 U 0 0 0 br0
192.168.122.0 0.0.0.0 255.255.255.0 U 0 0 0 virbr0