首先查看你LINUX的版本
cat /etc/redhat-release
uname -a
cat /proc/version
筆者的版本是: centos7.5
更換為阿里雲鏡像源
-
https://opsx.alibaba.com/mirror 打開,找到你對應的版本, 點擊幫助
-
復制腳本
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
- 執行命令更新源
yum clean all
yum makecache //將服務器上的軟件包信息緩存到本地,以提高搜索安裝軟件的速度
執行到此處就遇到以下錯誤
cp: 在"CentOS-Epel.repo" 后缺少了要操作的目標文件
Try 'cp --help' for more information.
[root@sgfoot2021 yum.repos.d]# cp CentOS-Epel.repo CentOS-Epel.repo.bak
[root@sgfoot2021 yum.repos.d]# vim CentOS-Epel.repo
[root@sgfoot2021 yum.repos.d]# yum makecache
已加載插件:fastestmirror, langpacks
Determining fastest mirrors
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
base | 3.6 kB 00:00:00
docker-ce-stable | 3.5 kB 00:00:00
http://mirrors.tencentyun.com/epel/7/x86_64/repodata/repomd.xml: [Errno 14] curl#6 - "Could not resolve host: mirrors.tencentyun.com; 未知的錯誤"
正在嘗試其它鏡像。
One of the configured repositories failed (EPEL for redhat/centos 7 - x86_64),
and yum doesn't have enough cached data to continue. At this point the only
safe thing yum can do is fail. There are a few ways to work "fix" this:
1. Contact the upstream for the repository and get them to fix the problem.
2. Reconfigure the baseurl/etc. for the repository, to point to a working
upstream. This is most often useful if you are using a newer
distribution release than is supported by the repository (and the
packages for the previous distribution release still work).
3. Run the command with the repository temporarily disabled
yum --disablerepo=epel ...
4. Disable the repository permanently, so yum won't use it by default. Yum
will then just ignore the repository until you permanently enable it
again or use --enablerepo for temporary usage:
yum-config-manager --disable epel
or
subscription-manager repos --disable=epel
5. Configure the failing repository to be skipped, if it is unavailable.
Note that yum will try to contact the repo. when it runs most commands,
so will have to try and fail each time (and thus. yum will be be much
slower). If it is a very temporary problem though, this is often a nice
compromise:
yum-config-manager --save --setopt=epel.skip_if_unavailable=true
failure: repodata/repomd.xml from epel: [Errno 256] No more mirrors to try.
http://mirrors.tencentyun.com/epel/7/x86_64/repodata/repomd.xml: [Errno 14] curl#6 - "Could not resolve host: mirrors.tencentyun.com; 未知的錯誤"
- 解決以上問題
cd /etc/yum.repos.d
vim CentOS-Epel.repo
#以下為內容, 換tencentyun更換成aliyun
[epel]
name=EPEL for redhat/centos $releasever - $basearch
failovermethod=priority
gpgcheck=1
gpgkey=http://mirrors.tencentyun.com/RPM-GPG-KEY-EPEL-7
enabled=1
baseurl=http://mirrors.tencentyun.com/epel/$releasever/$basearch/
- 更換后的CentOS-Epel.repo
[epel]
name=EPEL for redhat/centos $releasever - $basearch
failovermethod=priority
gpgcheck=1
gpgkey=http://mirrors.tencentyun.com/RPM-GPG-KEY-EPEL-7
enabled=1
baseurl=http://mirrors.tencentyun.com/epel/$releasever/$basearch/
執行以下命令,更新
yum clean all
yum makecache
yum -y update