更改 Centos 6 的 yum 源

1.查看当前使用的源:

yum repolist all

阿里源网址,使用方法点右边的帮助可以看到:https://opsx.alibaba.com/mirror

2.更改源:

第一步:备份你的原镜像文件,以免出错后可以恢复。

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup 

第二步:下载新的CentOS-Base.repo 到/etc/yum.repos.d/

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo

第三步:运行yum makecache生成缓存

yum clean all  //没有执行这一步可能会不成功
yum makecache  

第四步:更新系统

[root@localhost yum.repos.d]# yum -y update   

第五步:看到以下信息说明更改成功

[root@localhost ~]# yum -y update
已加载插件:fastestmirror, refresh-packagekit, security
设置更新进程Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com

 

转载于:https://www.cnblogs.com/gavinyyb/p/8350014.html

### CentOS 6 Yum配置 对于CentOS 6系统的yum配置,由于该操作系统已经停止更新和支持,官方提供了不再更新的软件镜像[^3]。 #### 进入Yum配置目录 为了修改yum,需进入对应的配置文件夹: ```bash cd /etc/yum.repos.d/ ``` #### 清理原有配置文件 移除原有的yum配置文件可以避免冲突: ```bash rm -rf * ``` 此操作会删除`/etc/yum.repos.d/`下的所有文件,请谨慎执行[^2]。 #### 创建新的Yum配置文件 创建一个新的repo文件用于指定新的yum位置。这里以阿里云为例来展示如何设置: ```bash vi aliyun.repo ``` 在打开后的编辑器中输入以下内容: ```ini [base] name=CentOS-$releasever - Base - mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/ gpgcheck=1 enabled=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6 [updates] name=CentOS-$releasever - Updates - mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/ gpgcheck=1 enabled=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6 [extras] name=CentOS-$releasever - Extras - mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/ gpgcheck=1 enabled=1 gpgkey=http://mirror.centos.org/centos/RPM-EXTRA ``` 保存并关闭文件。 #### 更新Yum缓存 为了让新配置生效,需要清理旧的元数据并重建缓存: ```bash yum clean all yum makecache ``` 通过上述步骤即可完成针对CentOS 6系统的yum配置工作[^4]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值