今天打算用VirtualBox虚拟机搭个Greenplum的集群环境,主机同意安装CentOS 7。结果最小化按照CentOS 7后yum install 报错,提示没办法连接到镜像库的地址,也就是没办法上网了。然后curl www.baidu.com提示无法查找到目标。首先想到是网络问题,先ifconfig命令看下。结果提示未知命令,果然是最小化安装。首先先把虚拟机的网络设置改成桥接,保证cable connect是勾选的,然后去到/etc/sysconfig/network-scripts目录下检查eth0网口的设置,结果没发现ifcfg-eth0这个文件。
先ip addr 命令查下mac地址(就是link/ether 后面那串)
然后vi /etc/sysconfig/network-scripts/ifcfg-eth0 添加eth0网口配置
保存退出执行 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.
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.
设定开机启动一个名为NetworkManager-wait-online服务,命令为:
systemctl enable NetworkManager-wait-online.service
reboot重启主机
重新执行systemctl status network.service就正常了。这里注意新建eth0的HWADDR后面的mac地址必须要跟本机保持一致
再运行curl baidu.com就OK了
参考:
https://www.cnblogs.com/zhizhao/p/9442487.html
http://blog.itpub.net/26506993/viewspace-2132570/