redhat 系统 配置 CentOS的yum源


如果系统是redhat 6.5 那么对应的CentOS 的源 也应该是6.5;
若系统是redhat7 同样的,对应的是CentOS7的源
而yum的源,通常采用国内的163 阿里 搜狐等镜像源


新安装了redhat6.5.安装后,登录系统,使用yum update 更新系统。提示:
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
无法更新。这是因为redhat 默认自带的 yum 源需要注册,才能更新。我们想不花钱也可以更新,需要替换掉redhat的yum源。

由以上问题得知:
1. 卸载默认的yum
2. 安装CentOS 的 yum
3. 从国内的镜像网站(通常是163 阿里 搜狐等镜像源网站)下载下来*.repo 文件 ,并放入/etc/yum.repos.d 文件夹下
4. 清除之前的缓存,重新构建新的缓存。

检查是否安装yum包
rpm -qa |grep yum    

redhat 系统 配置 CentOS的yum源_第1张图片

删除redhat自带的yum包

卸载上面显示的所有yum包:

rpm -qa|grep yum|xargs rpm -e --nodeps //不检查依赖,直接删除rpm包
根据对应的redhat 版本 在163镜像源网站上下载对应的yum 包
要下载的rpm 包 主要有三个(版本号可能会有差异,但包名肯定是一样的)
yum-metadata-parser-1.1.2-16.el6.i686.rpm
yum-3.2.29-40.el6.centos.noarch.rpm
yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm

wget http://mirrors.163.com/centos/7/os/i386/Packages/yum-metadata-parser-1.1.2-16.el6.i686.rpm
wget http://mirrors.163.com/centos/7/os/i386/Packages/yum-3.2.29-40.el6.centos.noarch.rpm
wget http://mirrors.163.com/centos/7/os/i386/Packages/yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm
为了解决安装过程中相互依赖的问题,可以直接用一个命令全部安装

rpm -ivh yum*   //全部安装
更换yum源。使用163的源

cd /etc/yum.repos.d/
wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
vim CentOS7-Base-163.repo //进行编辑
编辑文件,把文件里面的$releasever全部替换为版本号,即7 最后保存退出!

# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the 
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-7 - Base - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=os
baseurl=http://mirrors.163.com/centos/7/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

#released updates
[updates]
name=CentOS-7 - Updates - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=updates
baseurl=http://mirrors.163.com/centos/7/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-7 - Extras - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=extras
baseurl=http://mirrors.163.com/centos/7/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-7 - Plus - 163.com
baseurl=http://mirrors.163.com/centos/7/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
"CentOS7-Base-163.repo" 41L, 1462C            
清除原有缓存,重新构建缓存
yum clean all   //清除   
yum makecache   //构建
yum update    //更新系统,这时已经成功了

你可能感兴趣的:(linux)