備份原配置文件
進入yum源配置目錄:
cd /etc/yum.repos.d
如果沒有先安裝wget:
sudo yum install wget
修改yum源扛禽,就是修改CentOS-Base.repo的內(nèi)容,所以我們要先備份一下原來的:
sudo mv CentOS-Base.repo CentOS-Base.repo.backup
下載新配置文件
然后用wget下載國內(nèi)的yum源(即CentOS-Base.repo文件)拆内,新的在哪呢旋圆?目前國內(nèi)主要有三個yum源:
個人比較推薦中科大宠默,不管是centos還是Ubuntu
阿里云
CentOS7
sudo wget -O CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
CentOS6
sudo wget -O CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
CentOS5
sudo wget -O CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
網(wǎng)易
CentOS7
sudo wget -O CentOS-Base.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo
CentOS6
sudo wget -O CentOS-Base.repo http://mirrors.163.com/.help/CentOS6-Base-163.repo
CentOS5
sudo wget -O CentOS-Base.repo http://mirrors.163.com/.help/CentOS5-Base-163.repo
中科大
CentOS7
sudo wget -O CentOS-Base.repo https://lug.ustc.edu.cn/wiki/_export/code/mirrors/help/centos?codeblock=3
CentOS6
sudo wget -O CentOS-Base.repo https://lug.ustc.edu.cn/wiki/_export/code/mirrors/help/centos?codeblock=2
CentOS5
sudo wget -O CentOS-Base.repo https://lug.ustc.edu.cn/wiki/_export/code/mirrors/help/centos?codeblock=1
更新元數(shù)據(jù)
先清除原來的元數(shù)據(jù)緩存
sudo yum clean all
更新新的元數(shù)據(jù)緩存
sudo yum makecache
原創(chuàng)聲明
本文發(fā)布于簡書【Happyjava】麸恍。Happy的簡書地址:http://www.reibang.com/u/f69002e01708,Happy的個人博客:http://blog.happyjava.cn搀矫。歡迎轉(zhuǎn)載抹沪,但須保留此段聲明。