1.前言
很多情况下,假如我们在一台虚拟机已搭建了静态IP上网,JDK和Maven等基础环境下,自己又不想重新搭建这些环境,我们就会想到到虚拟机克隆。
2.环境
列如在192.168.8.21,已搭建了静态IP上网;
CentOS 7.x NAT模式静态IP上网可以参考:
https://blog.csdn.net/no_ob/article/details/78656552
3.遇到问题
192.168.8.21虚拟机克隆后192.168.8.22,执行service network restart命令后出现下面的错误:
Restarting network (via systemctl): 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
● 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 五 2017-07-14 19:01:47 CST; 1min 16s ago
Docs: man:systemd-sysv-generator(8)
Process: 4681 ExecStart=/etc/rc.d/init.d/network start (code=exited, status=1/FAILURE)
CGroup: /system.slice/network.service
└─1192 /sbin/dhclient -H mini1 -1 -q -lf /var/lib/dhclient/dhclient--ens33.lease -pf /v...
7月 14 19:01:47 mini1 network[4681]: RTNETLINK answers: File exists
7月 14 19:01:47 mini1 network[4681]: RTNETLINK answers: File exists
7月 14 19:01:47 mini1 network[4681]: RTNETLINK answers: File exists
7月 14 19:01:47 mini1 network[4681]: RTNETLINK answers: File exists
7月 14 19:01:47 mini1 network[4681]: RTNETLINK answers: File exists
7月 14 19:01:47 mini1 network[4681]: RTNETLINK answers: File exists
7月 14 19:01:47 mini1 systemd[1]: network.service: control process exited, code=exited status=1
7月 14 19:01:47 mini1 systemd[1]: Failed to start LSB: Bring up/down networking.
7月 14 19:01:47 mini1 systemd[1]: Unit network.service entered failed state.
7月 14 19:01:47 mini1 systemd[1]: network.service failed.
3.问题解决
1./etc/sysconfig/network-scripts/将ifcfg-xxx文件中的IPADDR修改为192.168.8.22
2./etc/sysconfig/network-scripts/将ifcfg-xxx文件中的DEVICE一行注释掉。
修改之前192.168.8.21的ifcfg-xxx:
修改之后192.168.8.22的ifcfg-xxx:
4.测试结果
输入重启虚拟机命令:service network restart
检测网络命令:ping www.baidu.com
5.如果问题还没解决可以参考下:
https://blog.csdn.net/weiyongle1996/article/details/75128239