場景:
在Book上裝VM可以練習分佈式架構搭建或者Hadoop集羣等大型系統的演練.
環境:
系統:Deepin
虛擬機軟件:Virtualbox
前提:
我們已經通過網橋聯通了集羣的每一臺機器.
問題:
切換網絡環境時,集羣不能互聯了.比如我在公司的網段192.168...,路上了網段變10.25..段了,或者回家網段變成其他的了.
這個問題一直困擾我好久,不知道該問誰呢,因爲我問一下人,他們都不知道.感覺好孤獨呢.但是我不想死心,今天終於扎到了.關鍵的一句話,如下圖:
虛擬主機網絡參數 : 手動配置成橋接的宿主機網卡的同一網段,或通過宿主機網絡中的 DHCP Ser 獲取。
看到這句話,我就抱着試試虛擬網卡是不是可以解決.果然不讓我失望.
這是配置結果
(base) walker@Yanjun-PC:~$ ifconfig
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 22815 bytes 3346731 (3.1 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 22815 bytes 3346731 (3.1 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlp2s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.25.133.69 netmask 255.255.255.0 broadcast 10.25.133.255
inet6 fe80::d466:ac8:522e:19b6 prefixlen 64 scopeid 0x20<link>
ether d4:6d:6d:1c:8f:90 txqueuelen 1000 (Ethernet)
RX packets 463274 bytes 458273026 (437.0 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 317896 bytes 50839603 (48.4 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlp2s0:1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.168.0.1 netmask 255.255.0.0 broadcast 172.168.255.255
ether d4:6d:6d:1c:8f:90 txqueuelen 1000 (Ethernet)
(base) walker@Yanjun-PC:~$ ping 172.168.0.130
PING 172.168.0.130 (172.168.0.130) 56(84) bytes of data.
64 bytes from 172.168.0.130: icmp_seq=1 ttl=64 time=0.129 ms
64 bytes from 172.168.0.130: icmp_seq=2 ttl=64 time=0.601 ms
^C
--- 172.168.0.130 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1031ms
rtt min/avg/max/mdev = 0.129/0.365/0.601/0.236 ms
(base) walker@Yanjun-PC:~$
關鍵的執行命令:sudo ifconfig wlp2s0:1 172.168.0.10 up
祝大家好運!