1状原、備份
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
2、下載新的CentOS-Base.repo 到/etc/yum.repos.d/
CentOS 5
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
或者
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
CentOS 6
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
或者`
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
CentOS 7
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
或者
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
3、生成緩存
yum makecache #生成緩存 立即生效
1)先安裝wget
yum install -y wget
- 查詢國內(nèi)鏡像源
打開阿里鏡像http://mirrors.aliyun.com/
點(diǎn)擊幫助:
3)下載CentOS 7的repo文件
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
#或者
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
如果提示報(bào)錯(cuò)wget: unable to resolve host address ‘mirrors.aliyun.com’
意思是無法解析主機(jī)地址崎淳。應(yīng)該是與DNS解析有關(guān)涡贱。
DNS的解析配置文件是/etc/resolv.conf
編輯命令:vi /etc/resolv.conf
添加下面的地址(注意:我這里是私有云)
nameserver 183.221.253.100
nameserver 10.101.10.48
nameserver 10.101.51.169
nameserver 211.137.96.205
公有云一般添加google的DNS服務(wù)器和移動(dòng)咏删,電信或聯(lián)通的DNS服務(wù)器,根據(jù)自己需要添加问词。
4)更新鏡像源
清除緩存
yum clean all
生成緩存
yum makecache
[root@localhost ~]# yum clean all
Loaded plugins: fastestmirror
Cleaning repos: base extras updates
Cleaning up everything
Cleaning up list of fastest mirrors
[root@localhost ~]# yum makecache
Loaded plugins: fastestmirror
.......省略