报错信息:ERROR---Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64

在CentOS7中运行yum安装命令时出现以下错误:
报错信息:ERROR---Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64
报错问题:安装时网卡没有打开,导致了无法连接网络。重新配置即可。

解决步骤:

  1. 查看自己本机的网卡,在终端中执行命令:nmcli d
    报错信息:ERROR---Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64

  2. cd到 /etc/sysconfig/network-scripts/目录下,查看目录下的文件
    报错信息:ERROR---Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64

  3. 打开ifcfg-ens32文件修改配置,命令行:vi ifcfg-ens32 ,修改配置内容,如下图
    报错信息:ERROR---Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64

  4. 重启网络服务,命令行:systemctl restart network;看是否可以ping通百度
    报错信息:ERROR---Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64

  5. 可以yum安装
    报错信息:ERROR---Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64