Centos7使用wget修改为阿里云镜像源
1. 使用wget修改为阿里云镜像源
1.安装wget
yum install -y wget
2.完事前都做备份
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
如修改 /etc/yum.repos.d/CentOS-Base.repo
:%s/#baseurl/baseurl
3.下载阿里云镜像文件
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
4.清理缓存
yum clean all
5.生成缓存
yum makecache
6.更新最新源设置
yum update -y
其他:
如果要手动修改的话:
就vi 修改 CentOS-Base.repo 全局替换
baseurl=http://mirror.centos.org/centos/
r
e
l
e
a
s
e
v
e
r
/
u
p
d
a
t
e
s
/
releasever/updates/
releasever/updates/basearch/
baseurl=http://mirrors.aliyun.com/centos/
r
e
l
e
a
s
e
v
e
r
/
u
p
d
a
t
e
s
/
releasever/updates/
releasever/updates/basearch/
替换为阿里云的地址
2. 错误:Could not retrieve mirrorlist http://mirrorlist.centos.org/?
[root@localhost yum.repos.d]# yum -y install gcc
已加载插件:fastestmirror
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was
14: curl#7 - "Failed to connect to 2604:1580:fe02:2::10: 网络不可达"
修改 CentOS-Base.repo 中 mirrorlist 为 #mirrorlist, #baseurl 为 baseurl
[root@localhost yum.repos.d]# cat CentOS-Base.repo
……
……
#
[base]
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
#baseurl=http://10.153.3.130/centos/$releasever/os/$basearch/
参考:
https://blog.csdn.net/u014514528/article/details/101083047