Centos6 换源

#主要是为了提高安装速度以及epel中自带源众多木有的软件。 

#Author wood_man
#2016.06.01 v 2.0

 

1. 测试环境

VMware 10.0     
CentOS release  6.6 (Final) i386  
kernel 
2.6.32-504.el6.i686  
 
2.准备工作
(1) 删除yum源
#rm -f /etc/yum.repo.d/*
(2) 安装和配置 
网易:
#wget  http://mirrors.163.com/.help/CentOS6-Base-163.repo -O /etc/yum.repos.d/163.repo 
重庆大学:
#wget  http://mirrors.cqu.edu.cn/distri/CentOS/6/CentOS-Base.repo  
#网易和重庆大学的镜像配置一个即可。
epel:

#rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
#(如果报错则)epel.repo中注释所有的 "#mirrorlist "使用 "baseurl "并且 "enabled=1"。
#sed -r -i 's@#(baseurl)@\1@g' epel.repo
# sed -i 's@mirrorlist@#&@g' epel.repo
 
本地源 :
#cat /etc/yum.repos.d/local.repo
[Local]
name=Centos6 - Local
baseurl= file:///mnt/cdrom/
enabled=1
gpgcheck=0 
 
#yum clean all 
#yum makecache 
# 慎用缓存到本地安装速度快,但占用带宽和磁盘;缓存位置在/etc/yum.conf定义。
#yum repolist
 

#删除epel
rpm -e --nodeps(强制)  epel-release

转载于:https://www.cnblogs.com/woodman/p/6137134.html

### 回答1: 首先,您需要打开终端,然后输入以下命令来备份原来的源: sudo mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak 然后,使用以下命令下载阿里云的 CentOS 6 的源: wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo 最后,使用以下命令清除 yum 缓存并生成新的缓存: sudo yum clean all sudo yum makecache 这样就可以使用阿里云的 CentOS 6 源了。 注意:上面的命令假设您正在使用阿里云的源。如果您想使用其他源,请替换掉上述命令中的 URL。 ### 回答2: CentOS 6是一种基于Linux的操作系统,阿里源是一种软件源,用于下载和安装软件包。要更换CentOS 6的阿里源,您可以按照以下步骤进行操作: 1. 使用root用户登录到CentOS 6系统。 2. 打开终端窗口,输入以下命令以备份旧的软件源列表文件: ``` cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup ``` 3. 使用文本编辑器(例如vi或nano)打开软件源列表文件: ``` vi /etc/yum.repos.d/CentOS-Base.repo ``` 4. 在打开的文件中,将所有以`baseurl`和`mirrorlist`开头的行注释掉(在行的最前面添加#字符)。 5. 在文件的末尾添加以下内容,以使用阿里源: ``` [base] name=CentOS-$releasever - Base baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/ gpgcheck=1 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-$releasever [updates] name=CentOS-$releasever - Updates baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/ gpgcheck=1 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-$releasever [extras] name=CentOS-$releasever - Extras baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/ gpgcheck=1 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-$releasever ``` 6. 保存文件并退出编辑器。 7. 清除并重建软件源缓存,以使更改生效: ``` yum clean all yum makecache ``` 现在,您已成功更换CentOS 6的阿里源。您可以使用yum命令安装和更新软件包时,系统将从阿里源下载软件包。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值