rhel源更换为centos源

禁用 RHEL 的每个仓库配置

修改目录 /etc/yum.repos.d  下每个文件,将 enable=1 改为 enable=0,或者也可以将这个目录清空

建立 CentOS 的配置 /etc/yum.repos.d/centos.repo ,内容为:

[CentOS5 base]
name=CentOS-5-Base
mirrorlist=http://mirrorlist.centos.org/?release=5&arch=$basearch&repo=os
gpgcheck=1
enabled=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
[CentOS5 updates]
name=CentOS-5-Updates
mirrorlist=http://mirrorlist.centos.org/?release=5&arch=$basearch&repo=updates
gpgcheck=1
enabled=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
[CentOS5plus]
name=CentOS-5-Plus
mirrorlist=http://mirrorlist.centos.org/?release=5&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5

这些仓库需要 GPG 验证,还需要把公钥复制下来。 或者也可以将 centos.repo 中 gpgcheck=1 改为 gpgcheck=0 来避免验证:
rpm --import http://isoredirect.centos.org/centos/5/os/i386/RPM-GPG-KEY-CentOS-5

测试是否可用
  1. # yum list available  
  2. Loaded plugins: product-id, refresh-packagekit, security, subscription-manager  
  3. This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.  
  4. Bad id for repo: CentOS5 base, byte =   7  
  5. Bad id for repo: CentOS5 updates, byte =   7  

上面的仓库地址是在 这里 找到的,因为 仓库 ID 带了空格造成 错误 Bad id for repo: CentOS5 base, byte =   7,去掉空格就可以了

Bad id 说的就是 repo 文件中方括号中的 仓库 ID, byte = 7 为引起错误的地方

对于 “This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register” 问题

可在使用 yum 时禁用相应插件,如:

  1. yum --disableplugin=subscription-manager list available  

或 将 /etc/yumconf 中 plugins=1 改为 plugins=0 来禁用所有插件

也可以禁用指定插件,在 /etc/yum/pluginconf.d 下找到插件对应的文件 ,如要禁用 subscription-manager 插件,修改 /etc/yum/pluginconf.d/subscription-manager.conf 文件

将 enabled=1 改为 enabled=0 即可


如果要得到更好的支持,可以把 CentOS 的 Release Node : centos-release 和 centos-release-notes 安装上










wget http: //dl .fedoraproject.org /pub/epel/beta/7/x86_64/epel-release-7-1 .noarch.rpm
yum  install  epel-release-7-1.noarch.rpm

或者用 rpm -ivh epel-release-7-1.noarch.rpm 安装

查看是否安装成功:

yum repolist

二、redhat配置centos源

vi /etc/yum.repos.d/CentOS-Base.repo

[base]

name=CentOS-5-Base

#mirrorlist=http://mirrorlist.centos.org/?release=$releasever5&arch=$basearch&repo=os

#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/

baseurl=http://ftp.sjtu.edu.cn/centos/7/os/$basearch/

gpgcheck=0

gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-7

#released updates

[updates]

name=CentOS-$releasever – Updates

#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates

baseurl=http://ftp.sjtu.edu.cn/centos/7/updates/$basearch/

gpgcheck=0

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

[extras]

name=CentOS-$releasever – Extras

#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras

baseurl=http://ftp.sjtu.edu.cn/centos/7/extras/$basearch/

gpgcheck=0

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

b[centosplus]

name=CentOS-$releasever – Plus

#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus

baseurl=http://ftp.sjtu.edu.cn/centos/7/centosplus/$basearch/

gpgcheck=0

enabled=0

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

rpm -- import  http: //mirror .centos.org /centos/RPM-GPG-KEY-CentOS-7
rpm -qa gpg-pubkey









1 删除rhel自带的yum包:

 
 
  1. rpm -aq | grep yum |xargs rpm -e --nodeps

2 安装yum:

 
 
  1. [china~/yum_64#]rpm -ivh python-iniparse-0.3.1-2.1.el6.noarch.rpm
  2. warning:python-iniparse-0.3.1-2.1.el6.noarch.rpm: Header V3 RSA/SHA256 Signature, keyID c105b9de: NOKEY
  3. Preparing...               ########################################### [100%]
  4. packagepython-iniparse-0.3.1-2.1.el6.noarch is already installed
  5. [china~/yum_64#]rpm -ivh yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
  6. warning:yum-metadata-parser-1.1.2-16.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, keyID c105b9de: NOKEY
  7. Preparing...               ########################################### [100%]
  8.    1:yum-metadata-parser    ###########################################[100%]
  9. [china~/yum_64#]rpm -ivh yum-3.2.29-40.el6.centos.noarch.rpmyum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm
  10. warning:yum-3.2.29-40.el6.centos.noarch.rpm: Header V3 RSA/SHA1 Signature, key IDc105b9de: NOKEY
  11. Preparing...               ########################################### [100%]
  12.   1:yum-plugin-fastestmirro########################################### [50%]
  13.   2:yum                   ########################################### [100%]
  14. [ichina~/yum_64#]

若提示需要依赖

 
 
  1. libc.so.6 is neededby yum-metadata-parser-1.1.2-16.el6.i686
  2. libc.so.6(GLIBC_2.0)is needed by yum-metadata-parser-1.1.2-16.el6.i686
  3. libc.so.6(GLIBC_2.1.3)is needed by yum-metadata-parser-1.1.2-16.el6.i686
  4. libglib-2.0.so.0 is needed by yum-metadata-parser-1.1.2-16.el6.i686
  5. libpthread.so.0 is needed by yum-metadata-parser-1.1.2-16.el6.i686
  6. libpython2.6.so.1.0 is needed by yum-metadata-parser-1.1.2-16.el6.i686
  7. libsqlite3.so.0 is needed by yum-metadata-parser-1.1.2-16.el6.i686
  8. libxml2.so.2 is needed by yum-metadata-parser-1.1.2-16.el6.i686
  9. libxml2.so.2(LIBXML2_2.4.30) is needed by yum-metadata-parser-1.1.2-16.el6.i686

安装: glibc-2.12-1.107.el6.x86_64.rpm http://pkgs.org/centos-6/centos-x86_64/glibc-2.12-1.132.el6.x86_64.rpm.html

3 添加网易163的yum源

获取文件:CentOS6-Base-163.repo

 
 
  1. wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
  2. cp CentOS-Base-163.repo rhel-source.repo
  3. sed -i 's/\$releasever/6/g' rhel-source.repo

4 清空 yum 缓存

 
 
  1. yum clean all

5 将服务器上的软件包信息缓存到本地

提高yum的更新效率

 
 
  1. yum makecache

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值