1.使用Xshell连接虚拟机出现如下问题,连接不上

Host 'hadoop104' resolved to 192.168.10.104.
Connecting to 192.168.10.104:22...
Could not connect to 'hadoop104' (port 22): Connection failed.

Type `help' to learn how to use Xshell prompt.

2.进入虚拟机:ping www.baidu.com

3.连不上网,那必定是网没打开了

输入:systemctl status network.service

出现如下结果:

network.service - LSB: Bring up/down networking
   Loaded: loaded (/etc/rc.d/init.d/network; bad; vendor preset: disabled)
   Active: failed (Result: exit-code) since 三 2022-03-23 11:40:16 CST; 29s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 3342 ExecStart=/etc/rc.d/init.d/network start (code=exited, status=1/FAILURE)

3月 23 11:40:15 hadoop104 network[3342]: RTNETLINK answers: File exists
3月 23 11:40:15 hadoop104 network[3342]: RTNETLINK answers: File exists
3月 23 11:40:15 hadoop104 network[3342]: RTNETLINK answers: File exists
3月 23 11:40:15 hadoop104 network[3342]: RTNETLINK answers: File exists
3月 23 11:40:15 hadoop104 network[3342]: RTNETLINK answers: File exists
3月 23 11:40:15 hadoop104 network[3342]: RTNETLINK answers: File exists
3月 23 11:40:16 hadoop104 systemd[1]: network.service: control process exited, co...=1
3月 23 11:40:16 hadoop104 systemd[1]: Failed to start LSB: Bring up/down networking.
3月 23 11:40:16 hadoop104 systemd[1]: Unit network.service entered failed state.
3月 23 11:40:16 hadoop104 systemd[1]: network.service failed.
Hint: Some lines were ellipsized, use -l to show in full.

4.输入:systemctl status NetworkManager
● NetworkManager.service - Network Manager
   Loaded: loaded (/usr/lib/systemd/system/NetworkManager.service; enabled; vendor preset: enabled)
   Active: active (running) since 三 2022-03-23 11:24:35 CST; 14min ago
     Docs: man:NetworkManager(8)
 Main PID: 687 (NetworkManager)
    Tasks: 3
   CGroup: /system.slice/NetworkManager.service
           └─687 /usr/sbin/NetworkManager --no-daemon


5.将NetworkManager关闭:systemctl stop NetworkManager

5.1上面这种方式关闭NetworkManager的坏处是每次重新启动电脑,又连不上了。为了彻底解决这个问题,使用如下命令:systemctl disable NetworkManager 这样开启虚拟机就不会再自动启动了

6.service network start

Starting network (via systemctl):                          [  确定  ]

7.重新 ping www.baidu.com

64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=1 ttl=128 time=44.9 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=2 ttl=128 time=44.9 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=3 ttl=128 time=47.0 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=4 ttl=128 time=45.2 ms
^C
--- ps_other.a.shifen.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3008ms
rtt min/avg/max/mdev = 44.934/45.524/47.006/0.901 ms

8.在Xshell端连接centos虚拟机

Host 'hadoop104' resolved to 192.168.10.104.
Connecting to 192.168.10.104:22...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.

Last login: Wed Mar 23 11:30:42 2022
[fei@hadoop104 ~]$ 
9.能够连上了,问题总算解决!

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐