文章目录
第一步:备份你的原镜像文件,以免出错后可以恢复。
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
好了,成功了!有啥问题可以留言!
最新评论
有快3个月了没续费了,如何重新激活我的服务?
楼主,有一点不明白: “准备好你的服务器,确认账号(一般是 root)和密码,系统建议 Centos7 ×64+、Ubuntu、Debian”是指自己要准备一台安装了上述系统的电脑做服务器还是指购买的
网上一堆的节点怎么填写,看不懂得
请问证书会过期嘛?要怎么处理
好怕被墙,vmess+ws
搞定了!网速很快哦,感谢感谢!不过最后一步还是要提醒小白们一下,v2ray设置好以后,要点下电脑右下角的V,点击鼠标右键,点”系统代理”,点“自动配置系统代理”,V变成红色了,就可以google了。