vmware复制centos镜像后network服务启动失败

复制一个vmware镜像文件夹后,通过vmware打开新的镜像,执行systemctl status network,发现状态为failed,如下:

 

[root@centos7 network-scripts]# systemctl status network

● 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 三 2019-02-20 12:29:09 CST; 9s ago

     Docs: man:systemd-sysv-generator(8)

  Process: 18459 ExecStart=/etc/rc.d/init.d/network start (code=exited, status=1/FAILURE)

 

2月 20 12:29:09 centos7 network[18459]: RTNETLINK answers: File exists

2月 20 12:29:09 centos7 network[18459]: RTNETLINK answers: File exists

2月 20 12:29:09 centos7 network[18459]: RTNETLINK answers: File exists

2月 20 12:29:09 centos7 network[18459]: RTNETLINK answers: File exists

2月 20 12:29:09 centos7 network[18459]: RTNETLINK answers: File exists

2月 20 12:29:09 centos7 network[18459]: RTNETLINK answers: File exists

2月 20 12:29:09 centos7 systemd[1]: network.service: control process exited, code=exit...s=1

2月 20 12:29:09 centos7 systemd[1]: Failed to start LSB: Bring up/down networking.

2月 20 12:29:09 centos7 systemd[1]: Unit network.service entered failed state.

2月 20 12:29:09 centos7 systemd[1]: network.service failed.

通过journalctl -xe查看服务日志如下:

[root@centos7 network-scripts]# journalctl -ex

2月 20 11:20:21 centos7 systemd[1]: Stopped Network Manager.

-- Subject: Unit NetworkManager.service has finished shutting down

-- Defined-By: systemd

-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel

-- 

-- Unit NetworkManager.service has finished shutting down.

2月 20 11:20:21 centos7 polkitd[5446]: Unregistered Authentication Agent for unix-process:611

2月 20 11:20:33 centos7 polkitd[5446]: Registered Authentication Agent for unix-process:6117:

2月 20 11:20:33 centos7 systemd[1]: Starting LSB: Bring up/down networking...

-- Subject: Unit network.service has begun start-up

-- Defined-By: systemd

-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel

-- 

-- Unit network.service has begun starting up.

2月 20 11:20:33 centos7 network[6123]: 正在打开环回接口: [  确定  ]

2月 20 11:20:34 centos7 network[6123]: 正在打开接口 eno16777737: ERROR     : [/etc/sysconfig

2月 20 11:20:34 centos7 /etc/sysconfig/network-scripts/ifup-eth[6250]: 设备 eno16777737 似乎

2月 20 11:20:34 centos7 network[6123]: [失败]

2月 20 11:20:34 centos7 network[6123]: RTNETLINK answers: File exists

2月 20 11:20:34 centos7 network[6123]: RTNETLINK answers: File exists

2月 20 11:20:34 centos7 network[6123]: RTNETLINK answers: File exists

2月 20 11:20:34 centos7 network[6123]: RTNETLINK answers: File exists

2月 20 11:20:34 centos7 network[6123]: RTNETLINK answers: File exists

2月 20 11:20:34 centos7 network[6123]: RTNETLINK answers: File exists

2月 20 11:20:34 centos7 network[6123]: RTNETLINK answers: File exists

2月 20 11:20:34 centos7 network[6123]: RTNETLINK answers: File exists

2月 20 11:20:34 centos7 network[6123]: RTNETLINK answers: File exists

2月 20 11:20:34 centos7 systemd[1]: network.service: control process exited, code=exited stat

2月 20 11:20:34 centos7 systemd[1]: Failed to start LSB: Bring up/down networking.

-- Subject: Unit network.service has failed

-- Defined-By: systemd

-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel

-- 

-- Unit network.service has failed.

-- 

-- The result is failed.

2月 20 11:20:34 centos7 systemd[1]: Unit network.service entered failed state.

2月 20 11:20:34 centos7 systemd[1]: network.service failed.

2月 20 11:20:34 centos7 polkitd[5446]: Unregistered Authentication Agent for unix-process:611

重点是“设备 eno16777737 似乎...”这一行

解决办法:

1、查看ip信息

$ ip addr

[root@centos7 network-scripts]# ip addr

1: lo: 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: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000

    link/ether 00:0c:29:c9:ad:8a brd ff:ff:ff:ff:ff:ff

    inet 192.168.13.117/24 brd 192.168.13.255 scope global noprefixroute dynamic ens33

       valid_lft 85926sec preferred_lft 85926sec

    inet6 fe80::20c:29ff:fec9:ad8a/64 scope link noprefixroute 

       valid_lft forever preferred_lft forever

发现网卡名称为ens33,进入/etc/sysconfig/network-scripts目录,发现没有“ifcfg-ens33”这个文件,而是ifcfg-eno16777737 这个文件,原因找到了,是因为复制的镜像是之前的网卡名称,与本机的不对应。

2、需要将ifcfg-eno16777737文件名修改成ifcfg-ens33,另外需要修改文件内容中的“eno16777737”,都修改成“ens33”。

3、重启服务或者重启电脑

如果执行systemctl restart network发现还失败,就reboot重启电脑就可以解决。

目前我采用桥接网络方式,并且采用dhcp动态获取ip地址 ,如果是nat连接或者指定了ip地址,则需要修改ifcfg-ens33文件内容,将里面的MAC地址这一行删除,然后重启服务也可以解决。

转载来源:http://www.16boke.com/article/detail/250

 Linux  CentOS 

你可能感兴趣的:(操作系统)