文章目录
第一步:备份你的原镜像文件,以免出错后可以恢复。
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
第二步:下载新的阿里源CentOS-Base.repo 到 /etc/yum.repos.d
# 对于 CentOS 8
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo
# 对于 CentOS 7
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
第三步:运行 yum makecache 生成缓存
yum makecache
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
# 对于 CentOS 8
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo
# 对于 CentOS 7
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
第三步:运行 yum makecache 生成缓存
yum makecache
yum makecache
如果显示以下错误信息:
CentOS-8 - Base - mirrors.aliyun.com 76 B/s | 2.3 kB 00:30
Errors during downloading metadata for repository 'base':
- Status code: 404 for https://mirrors.aliyun.com/centos/8/BaseOS/x86_64/os/repodata/repomd.xml (IP: 222.218.83.244)
- Curl error (6): Couldn't resolve host name for http://mirrors.cloud.aliyuncs.com/centos/8/BaseOS/x86_64/os/repodata/repomd.xml [Could not resolve host: mirrors.cloud.aliyuncs.com]
- Curl error (28): Timeout was reached for http://mirrors.aliyuncs.com/centos/8/BaseOS/x86_64/os/repodata/repomd.xml [Connection timed out after 30001 milliseconds]
Error: Failed to download metadata for repo 'base': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were trie
则:
# 把CentOS-Base.repo文件中的以下网址
mirrors.aliyun.com/centos/
mirrors.aliyuncs.com/centos/
mirrors.cloud.aliyuncs.com/centos/
# 替换成
mirrors.aliyun.com/centos-vault/centos/
# 把epel.repo文件中的
enabled=1
# 修改成
enabled=0
或者直接把以下配置文件覆写到CentOS-Base.repo
:
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-$releasever - Base - mirrors.aliyun.com
#failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos-vault/centos/$releasever/BaseOS/$basearch/os/
http://mirrors.aliyun.com/centos-vault/centos/$releasever/BaseOS/$basearch/os/
http://mirrors.aliyun.com/centos-vault/centos/$releasever/BaseOS/$basearch/os/
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/centos-vault/centos/RPM-GPG-KEY-CentOS-Official
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
#failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos-vault/centos/$releasever/extras/$basearch/os/
http://mirrors.aliyun.com/centos-vault/centos/$releasever/extras/$basearch/os/
http://mirrors.aliyun.com/centos-vault/centos/$releasever/extras/$basearch/os/
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/centos-vault/centos/RPM-GPG-KEY-CentOS-Official
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
#failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos-vault/centos/$releasever/centosplus/$basearch/os/
http://mirrors.aliyun.com/centos-vault/centos/$releasever/centosplus/$basearch/os/
http://mirrors.aliyun.com/centos-vault/centos/$releasever/centosplus/$basearch/os/
gpgcheck=1
enabled=0
gpgkey=https://mirrors.aliyun.com/centos-vault/centos/RPM-GPG-KEY-CentOS-Official
[PowerTools]
name=CentOS-$releasever - PowerTools - mirrors.aliyun.com
#failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos-vault/centos/$releasever/PowerTools/$basearch/os/
http://mirrors.aliyun.com/centos-vault/centos/$releasever/PowerTools/$basearch/os/
http://mirrors.aliyun.com/centos-vault/centos/$releasever/PowerTools/$basearch/os/
gpgcheck=1
enabled=0
gpgkey=https://mirrors.aliyun.com/centos-vault/centos/RPM-GPG-KEY-CentOS-Official
[AppStream]
name=CentOS-$releasever - AppStream - mirrors.aliyun.com
#failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos-vault/centos/$releasever/AppStream/$basearch/os/
http://mirrors.aliyun.com/centos-vault/centos/$releasever/AppStream/$basearch/os/
http://mirrors.aliyun.com/centos-vault/centos/$releasever/AppStream/$basearch/os/
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/centos-vault/centos/RPM-GPG-KEY-CentOS-Official
第四步:查看当前yum源
yum repolist
yum repolist
输出:
repo id repo name
AppStream CentOS-8 - AppStream - mirrors.aliyun.com
base CentOS-8 - Base - mirrors.aliyun.com
extras CentOS-8 - Extras - mirrors.aliyun.com
Tips:可能用到的命令
# vim命令模式取代所有
:
%s/原字符字符串/新字符串/g
# vim命令模式取代所有
:
%s/原字符字符串/新字符串/g
好了,成功了!有啥问题可以留言!
最新评论
确认成功了,第五步确认已经修改完成了,可是还是不能再群晖控制面板里面网络关闭代理,不然docker注册表依然访问不了。拉去速度未有改善,我之前就是群晖网络添加代理,然后注册表同时添加镜像,我不知道现在
这可是个好东西啊,网站收藏了,抽空搞个VPS
那个国家选错了可以更改吗?
设备限制支持5个设备,我5个设备已经用满了,并且有一个设备不用了,怎么更换设备呢,怎么将不用的设备解绑呢?
还是不行,用了一天443端口就被墙了,防火墙似乎对这个端口特别敏感
服了 刚好是华为用户 请问该怎么办?