安装wget
原生CentOS7没有wget工具,而后续要下载阿里云的源,所以我们要先安装wget.
[root@DW1 ~]# cd /etc/yum.repos.d/
[root@DW1 yum.repos.d]# yum -y install wget
备份系统原生的yum源
有些博客没有注意与前一步的顺序,如果我们先备份源,就会因为没有yum源而无法安装wget.
[root@DW1 yum.repos.d]# mkdir repo_bak
[root@DW1 yum.repos.d]# mv *.repo repo_bak/
[root@DW1 yum.repos.d]# ls
repo_bak
下载阿里云yum源
下载CentOS-Base.repo到/etc/yum.repos.d/路径下:
[root@DW1 yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
[root@DW1 yum.repos.d]# ls
CentOS-Base.repo repo_bak
# 清除并生成新的缓存
[root@DW1 yum.repos.d]# yum clean all
[root@DW1 yum.repos.d]# yum makecache
安装EPEL源
[root@DW1 yum.repos.d]# yum list | grep epel-release
epel-release.noarch 7-11 extras
[root@DW1 yum.repos.d]# yum install -y prep epel-release
# 安装完成后
[DW1 yum.repos.d]# ls
CentOS-Base.repo epel.repo epel-testing.repo repo_bak
# 再次清除并生成新的缓存
[root@DW1 yum.repos.d]# yum clean all
[root@DW1 yum.repos.d]# yum makecache
查看所有的yum源
安装完成后,查看系统下所有的yum源:
[root@DW1 yum.repos.d]# yum repolist enabled
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* epel: mirror01.idc.hinet.net
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
repo id repo name status
base/7/x86_64 CentOS-7 - Base - mirrors.aliyun.com 10,019
epel/x86_64 Extra Packages for Enterprise Linux 7 - x86_64 13,327
extras/7/x86_64 CentOS-7 - Extras - mirrors.aliyun.com 419
updates/7/x86_64 CentOS-7 - Updates - mirrors.aliyun.com 2,303
repolist: 26,068
[root@DW1 yum.repos.d]# yum repolist all
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* epel: mirror01.idc.hinet.net
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
repo id repo name status
base/7/x86_64 CentOS-7 - Base - mirrors.aliyun.com enabled: 10,019
centosplus/7/x86_64 CentOS-7 - Plus - mirrors.aliyun.com disabled
contrib/7/x86_64 CentOS-7 - Contrib - mirrors.aliyun.com disabled
epel/x86_64 Extra Packages for Enterprise Linux 7 - x86_64 enabled: 13,327
epel-debuginfo/x86_64 Extra Packages for Enterprise Linux 7 - x86_64 - Debug disabled
epel-source/x86_64 Extra Packages for Enterprise Linux 7 - x86_64 - Source disabled
epel-testing/x86_64 Extra Packages for Enterprise Linux 7 - Testing - x86_64 disabled
epel-testing-debuginfo/x86_64 Extra Packages for Enterprise Linux 7 - Testing - x86_64 - De disabled
epel-testing-source/x86_64 Extra Packages for Enterprise Linux 7 - Testing - x86_64 - So disabled
extras/7/x86_64 CentOS-7 - Extras - mirrors.aliyun.com enabled: 419
updates/7/x86_64 CentOS-7 - Updates - mirrors.aliyun.com enabled: 2,303
repolist: 26,068