腾讯云更换镜像源遇到的坑

首先查看你LINUX的版本

cat /etc/redhat-release
uname -a
cat /proc/version

笔者的版本是: centos7.5

更换为阿里云镜像源

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
posted @ 2019-06-13 14:14  三百里江山  阅读(3902)  评论(0编辑  收藏  举报