本帖最后由 郑全 于 2019-8-10 10:39 编辑
一天,发现网卡无法启动,使用 ip a,发现如下:
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000
link/ether 00:0c:29:cf:d4:74 brd ff:ff:ff:ff:ff:ff
[root@dbserver ~]# 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 50599 bytes 23044797 (21.9 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 50599 bytes 23044797 (21.9 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
说明网卡ens33没有用到
[root@dbserver ~]# nmcli con
NAME UUID TYPE DEVICE
ens33 c96bc909-188e-ec64-3a96-6a90982b08ad ethernet --
[root@dbserver ~]# nmcli dev
DEVICE TYPE STATE CONNECTION
ens33 ethernet unmanaged --
lo loopback unmanaged --
[root@dbserver ~]# nmcli con up ens33
Error: Connection activation failed: No suitable device found for this connection.
重启NetworkManager服务,依然没有用
针对这个问题,可以使用network服务处理
但network需要配置文件中,加上网卡得mac地址,否则也起不来。
[root@dbserver network-scripts]# cat ifcfg-ens33
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_PRIVACY=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME="ens33"
ONBOOT=yes
HWADDR=00:0C:29:CF:D4:74
IPADDR=192.168.133.120
NETMASK=255.255.255.0
GATEWAY=192.168.133.2
DNS1=192.168.133.2
之后,service network restart,后,网卡可以起来
ifconfig
[root@dbserver network-scripts]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.133.120 netmask 255.255.255.0 broadcast 192.168.133.255
inet6 fe80::a0dc:d6c7:92d:7e62 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:cf:d4:74 txqueuelen 1000 (Ethernet)
RX packets 494 bytes 51822 (50.6 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 301 bytes 52510 (51.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 1000 (Local Loopback)
RX packets 99613 bytes 46845295 (44.6 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 99613 bytes 46845295 (44.6 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
但nmcli con之类的无法使用。
后来我始终觉得有问题,当时出现这个问题之前,是我更新了内核版本,但当时出现了一些问题,可能与这个有关,
更新之前为:
3.10.0-957.21.3.el7
更新之后,为以下版本27.2
[root@dbserver network-scripts]# uname -r
3.10.0-957.27.2.el7.x86_64
我后来重新更新这个版本,网卡还是不出来,
后来我发现一个问题:
[root@dbserver ~]# systemctl status NetworkManager
● NetworkManager.service - Network Manager
Loaded: loaded (/usr/lib/systemd/system/NetworkManager.service; disabled; vendor preset: enabled)
Active: active (running) since Sat 2019-08-10 09:48:43 CST; 1s ago
Docs: man:NetworkManager(8)
Main PID: 4265 (NetworkManager)
CGroup: /system.slice/NetworkManager.service
└─4265 /usr/sbin/NetworkManager --no-daemon
Aug 10 09:48:43 dbserver NetworkManager[4265]: <info> [1565401723.4037] manager: Networking is disabled by state file
Aug 10 09:48:43 dbserver NetworkManager[4265]: <info> [1565401723.4038] dhcp-init: Using DHCP client 'dhclient'
Aug 10 09:48:43 dbserver NetworkManager[4265]: <info> [1565401723.4354] Loaded device plugin: NMWifiFactory (/usr/lib64/NetworkManager/1.12.0-10.el7_6/libnm-device-plugin-wifi.so)
Aug 10 09:48:43 dbserver NetworkManager[4265]: <info> [1565401723.4430] Loaded device plugin: NMAtmManager (/usr/lib64/NetworkManager/1.12.0-10.el7_6/libnm-device-plugin-adsl.so)
Aug 10 09:48:43 dbserver NetworkManager[4265]: <info> [1565401723.4588] Loaded device plugin: NMTeamFactory (/usr/lib64/NetworkManager/1.12.0-10.el7_6/libnm-device-plugin-team.so)
Aug 10 09:48:43 dbserver NetworkManager[4265]: <info> [1565401723.4594] device (lo): carrier: link connected
Aug 10 09:48:43 dbserver NetworkManager[4265]: <info> [1565401723.4603] manager: (lo): new Generic device (/org/freedesktop/NetworkManager/Devices/1)
Aug 10 09:48:43 dbserver NetworkManager[4265]: <info> [1565401723.4609] device (ens33): carrier: link connected
Aug 10 09:48:43 dbserver NetworkManager[4265]: <info> [1565401723.4612] manager: (ens33): new Ethernet device (/org/freedesktop/NetworkManager/Devices/2)
Aug 10 09:48:43 dbserver NetworkManager[4265]: <info> [1565401723.4900] manager: startup complete
发现红色部分,但下次再去执行status,就没有这一行了,我通过网上搜索,没有看到centos,rhel有类似的问题,倒是看到有一个ubuntu有这样的问题,具体连接如下:
http://www.ubuntugeek.com/how-to ... tu-10-04-lucid.html
原文内容如下:
If your network manager is not working, and says unmanaged, or Networking disabled in ubuntu 10.04 try this fix
Open the terminal from Applications menu -> Accessories -> Terminal run the following commands service network-manager stop rm /var/lib/NetworkManager/NetworkManager.state service network-manager start
Then reboot your system.
难道centos7.6也有这样的问题吗,
我在我机器上搜了一下,确实有这个文件。
[root@dbserver network-scripts]# find / -name NetworkManager.state
/var/lib/NetworkManager/NetworkManager.state
[root@dbserver network-scripts]# cat /var/lib/NetworkManager/NetworkManager.state
[main]
NetworkingEnabled=false
WirelessEnabled=true
WWANEnabled=true
发现这里 NetworkingEnabled=false ,我修改为true,重新启动NetworkManager,还是不行,
我把这个文件移走,重新再去重启NetworkManager,神奇发现了,网卡可以正常使用了,同时,又会自动产生这个文件,而且这个文件 NetworkingEnabled=true了。
[root@dbserver network-scripts]# nmcli con
NAME UUID TYPE DEVICE
ens33 c96bc909-188e-ec64-3a96-6a90982b08ad ethernet ens33
[root@dbserver network-scripts]# nmcli dev
DEVICE TYPE STATE CONNECTION
ens33 ethernet connected ens33
lo loopback unmanaged --
[root@dbserver network-scripts]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.133.120 netmask 255.255.255.0 broadcast 192.168.133.255
inet6 fe80::a0dc:d6c7:92d:7e62 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:cf:d4:74 txqueuelen 1000 (Ethernet)
RX packets 869 bytes 90795 (88.6 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 548 bytes 90046 (87.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 1000 (Local Loopback)
RX packets 124712 bytes 56428208 (53.8 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 124712 bytes 56428208 (53.8 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
再重启机器,都没有问题。
最后,我无法确定是否是升级kernel,后面有空的时候,再重现一下,只是这里要提一个醒,因为我发现很多人的系统是直接连接到外网的,如果遇到了这个问题,怎么处理。
附:
我的环境:
centos 7.6
[root@dbserver network-scripts]# yum list kernel
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirror.jdcloud.com
* extras: mirrors.163.com
* updates: mirror.jdcloud.com
Installed Packages
kernel.x86_64 3.10.0-957.el7 @anaconda
kernel.x86_64 3.10.0-957.21.3.el7 @updates
kernel.x86_64 3.10.0-957.27.2.el7 @updates
[root@dbserver network-scripts]#
|