一、问题描述
在对CentOS虚拟机进行时钟同步的时候,遇到了如下问题:
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was
14: curl#6 - “Could not resolve host: mirrorlist.centos.org; Unknown error”
二、最终问题解决方案
YUM源更换到阿里云软件仓库
转自:CentOS YUM源更换到阿里云软件仓库
方法如下:
首先登录系统后,你得变成root,或者有sudo提权的权限,才能进行这些操作。
第一步,将原来的目录改个名,晾到一边
mv /etc/yum.repos.d /etc/yum.repos.d-bak
第二步:原来的目录还得再恢复
mkdir /etc/yum.repos.d
第三步:下载阿里云的yum源配置
cd /etc/yum.repos.d
wget http://mirrors.aliyun.com/repo/Centos-7.repo
第四步:清除yum原来的缓存
yum clean all
//注意clean与all之间还有一个空格
第五步:查看这个软件源中有多少软件包
[root@node2 yum.repos.d]# yum repolist
Loaded plugins: fastestmirror, langpacks
Determining fastest mirrors
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
base | 3.6 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/4): base/7/x86_64/group_gz | 153 kB 00:00:00
(2/4): extras/7/x86_64/primary_db | 253 kB 00:00:01
base/7/x86_64/primary_db FAILED 197 kB/s | 4.4 MB 00:02:33 ETA
http://mirrors.aliyuncs.com/centos/7/os/x86_64/repodata/6d0c3a488c282fe537794b5946b01e28c7f44db79097bb06826e1c0c88bad5ef-primary.sqlite.bz2: [Errno 14] curl#7 - "Failed connect to mirrors.aliyuncs.com:80; Connection refused"
Trying other mirror.
(3/4): base/7/x86_64/primary_db | 6.1 MB 00:00:34
(4/4): updates/7/x86_64/primary_db | 27 MB 00:02:24
repo id repo name status
base/7/x86_64 CentOS-7 - Base - mirrors.aliyun.com 10,072
extras/7/x86_64 CentOS-7 - Extras - mirrors.aliyun.com 526
updates/7/x86_64 CentOS-7 - Updates - mirrors.aliyun.com 6,173
repolist: 16,771
[root@node2 yum.repos.d]# yum -y install ntp
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Package ntp-4.2.6p5-29.el7.centos.2.x86_64 already installed and latest version
Nothing to do