1、先確保可以運行wget命令,若不可以運行wget命令,先用默認yum源安裝wget工具:yum install -y wget
2、備份系統默認yum源:
[root@localhost ~]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
3、下載阿里雲yum源,這裏下載的是centos7:
[root@localhost ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
4、生成緩存:
[root@localhost ~]# yum clean all
[root@localhost ~]# yum makecache
5、完成修改yum源
注意事項:若新手剛完成centos的安裝可能沒有wget工具包,此時要是直接備份yum源會報錯:
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
There are no enabled repos.
Run "yum repolist all" to see the repos you have.
You can enable repos with yum-config-manager --enable <repo>