yum安装出现错误如下:
我在虚拟机中安装Docker的过程中,使用yum命令后出现如下错误代码:
“Could not resolve host: mirrorlist.centos.org; Name or service not known”
但是ping www.baidu.com是成功的,这说明DNS没问题,确认是yum源访问
的问题,原因在于无法链接到国外的源仓库,有时候连上也很慢,所以报错。
现在就需要更换国内的yum源。
更换yum源:
我更换为阿里的,还有华为云,清华大学等源可以使用。
1、从阿里云下载新的配置文件,两个命令可用,如果虚拟机还没安装wget工具,就使用curl
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
2、清理缓存
yum clean all
3、重新生成缓存
yum makecache
4、更新yum源包
yum -y update