在配置 Zookeeper 的時候,我重啟了 CentOS 7,發現使用 XShell 遠程連接系統(主機:192.168.186.128)超時,
對于作業系統和寫代碼時候出現的各種 BUG 和意外,我早已經習慣;因為我知道,在有限的時間內,都可以被解決,
然后,我直接進入系統頁面,打開命令列輸入 ifconfig:
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.186.130 netmask 255.255.255.0 broadcast 192.168.186.255
inet6 fe80::20c:29ff:fe1a:6c13 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:1a:6c:13 txqueuelen 1000 (Ethernet)
RX packets 636 bytes 48167 (47.0 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 237 bytes 26851 (26.2 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
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 0 (Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
根據之前的系統快照備份,可以得到之前的資訊為:
eno16777736: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.186.128 netmask 255.255.255.0 broadcast 192.168.186.255
inet6 fe80::20c:29ff:fed8:e9b9 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:d8:e9:b9 txqueuelen 1000 (Ethernet)
RX packets 1370575 bytes 1933632481 (1.8 GiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 360561 bytes 85054851 (81.1 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
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 0 (Local Loopback)
RX packets 19044 bytes 38146469 (36.3 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 19044 bytes 38146469 (36.3 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
由此可見,重啟之后主機地址由 192.168.186.128 變為了 192.168.186.130,原來的 eno16777736 也變成了 ens33,
然后,我嘗試執行重啟網路的命令 service network restart 或者 systemctl restart network,發現報錯:
Job for network.service failed because the control process exited with error code. See "systemctl status network.service" and "journalctl -xe" for details.
為了查看詳細錯誤資訊,執行命令 cat /var/log/messages | grep network,發現了錯誤所在:
...
Sep 25 10:55:30 localhost network: [FAILED]
Sep 25 10:55:30 localhost NetworkManager[16202]: <info> renaming /etc/sysconfig/network-scripts/ifcfg-eno16777736 -> /etc/sysconfig/network-scripts/ifcfg-ens33
Sep 25 10:55:30 localhost network: Bringing up interface ens33: Error: no device found for connection 'eno16777736'.
...
錯誤提示是加載網卡 eno16777736 失敗,
于是執行命令 cd /etc/sysconfig/network-scripts/,進入存放網路配置的檔案夾,
查看目錄下的檔案發現:只存在原來的網卡 eno16777736 對應的組態檔 ifcfg-eno16777736,但是沒有網卡 ens33 對應的組態檔,所以推斷出,重啟之后,系統把原來的網卡洗掉了,然后啟用了新的網卡有了新的 IP 地址,為此,解決方案是,更換網卡組態檔并重新配置 IP 地址為舊的 IP 地址,并重啟網路,
首先執行命令 cp ifcfg-eno16777736 ifcfg-ens33,復制檔案,
然后,執行命令編輯檔案 vim ifcfg-ens33;把其中的網卡名字由原來的 eno16777736 更換為 ens33,同時確保 IP 地址是原來的地址:
IPADDR=192.168.186.128
NAME=ens33
DEVICE=ens33
同時執行命令洗掉無效網卡的組態檔 rm ifcfg-eno16777736,
然后執行重啟網路的命令 systemctl restart network,接著執行 ifconfig 可以發現 IP 地址成功更換為原來的 IP 地址了:
[root@localhost network-scripts]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.186.128 netmask 255.255.255.0 broadcast 192.168.186.255
inet6 fe80::20c:29ff:fe1a:6c13 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:1a:6c:13 txqueuelen 1000 (Ethernet)
RX packets 777 bytes 57063 (55.7 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 280 bytes 31690 (30.9 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
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 0 (Local Loopback)
RX packets 4 bytes 352 (352.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 4 bytes 352 (352.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
如果重啟一次沒有報錯但是 IP 地址沒有改變,那就再執行一次重啟,以防止快取問題,
重新使用 XShell 連接系統,第一次重新嘗試連接超時的話,就關掉再來一次,同樣防止快取問題,
最后,重啟系統,發現 IP 地址和網卡都正常,沒有變更,可以正常地使用 XShell 遠程訪問 CentOS 7 系統,
想了解更多,歡迎關注我的微信公眾號:Renda_Zhang
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/136001.html
標籤:AI
上一篇:一個double fetch工具在初始化時出錯。。。
下一篇:Docker Compose
