CentOS配置国内源

备份原有文件

到仓库配置文件夹下

1
cd /etc/yum.repos.d/

显示一些原有文件

1
2
3
4
[jackey@localhost yum.repos.d]$ ls
CentOS-Base.repo CentOS-fasttrack.repo CentOS-Vault.repo
CentOS-CR.repo CentOS-Media.repo CentOS-x86_64-kernel.repo
CentOS-Debuginfo.repo CentOS-Sources.repo

备份原文件

1
2
sudo mkdir repo_bak
sudo mv *.repo repo_bak/

添加阿里源

1
2
sudo wget http://mirrors.aliyun.com/repo/Centos-7.repo
sudo wget -O /etc/yum.repos.d/epel-7.repo http://mirrors.aliyun.com/repo/epel-7.repo

更新软件包

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[jackey@localhost yum.repos.d]$ sudo yum update
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
epel | 4.7 kB 00:00
(1/3): epel/x86_64/group_gz | 95 kB 00:00
(2/3): epel/x86_64/updateinfo | 1.0 MB 00:00
(3/3): epel/x86_64/primary_db | 6.8 MB 00:01
Resolving Dependencies
--> Running transaction check
---> Package augeas-libs.x86_64 0:1.4.0-9.el7 will be updated
---> Package augeas-libs.x86_64 0:1.4.0-9.el7_8.1 will be an update
...

查看可用源

1
2
3
4
5
6
7
8
9
10
11
12
[jackey@localhost yum.repos.d]$ sudo yum repolist enabled
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
repo id repo name status
base/7/x86_64 CentOS-7 - Base - mirrors.aliyun.com 10,070
epel/x86_64 Extra Packages for Enterprise Linux 7 - x86_64 13,276
extras/7/x86_64 CentOS-7 - Extras - mirrors.aliyun.com 392
updates/7/x86_64 CentOS-7 - Updates - mirrors.aliyun.com 671
repolist: 24,409

CentOS配置国内源
https://blog.jackeylea.com/linux/setup-the-china-source-of-centos/
作者
JackeyLea
发布于
2020年5月20日
许可协议