Redhat 7.1使用CentOS 7 的Yum网络源


redhat 的更新包只对注册的用户生效因为centos的系统和redhat的系统极其相似,所以完全可以在redhat的环境上布置centos的网络yum源。

环境:redhat7.1 

前提:能够PING通外网

1、首先查看redhat 7.1系统本身所安装的那些yum 软件包:

root@serverb ~]#  rpm -qa | grep yum
yum-3.4.3-125.el7.noarch
yum-metadata-parser-1.1.4-10.el7.x86_64
yum-langpacks-0.4.2-3.el7.noarch
yum-utils-1.1.31-29.el7.noarch
yum-rhn-plugin-2.0.1-5.el7.noarch

2、删除这些软件包:

用这个命令:rpm -e yum --nodeps
  rpm -e yum-utils --nodeps

  rpm -e yum-langpacks --nodeps
  rpm -e PackageKit-yum --nodeps
  rpm -e yum-rhn-plugin --nodeps

 rpm -e yum-metadata-parser --nodeps

3.进入以下网站上面查看软件包的版本是否升级或者找到自己系统所对应的文件包版本更新;

网易163网络源地址:http://mirrors.163.com/

CentOS网络源地址:http://centos.ustc.edu.cn/centos/

4.找到自己所需要的版本下载:

http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-utils-1.1.31-34.el7.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-updateonboot-1.1.31-34.el7.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-34.el7.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-132.el7.centos.0.1.noarch.rpm

5.安装软件包:

rpm -ivh yum-*

6.新建repo 配置文件;

[root@localhost ~]# vim /etc/yum.repos.d/CentOS-Base.repo

 

[base]

name=CentOS-$releasever -Base

#baseurl=http://mirrors.sohu.com/centos/7/os/$basearch/ 这个是国外的yum源地址,获取不到内容

baseurl=http://mirrors.163.com/centos/7/os/$basearch/

gpgcheck=1

 

#released updates

[updates]

name=CentOS-$releasever - Updates

baseurl=http://mirrors.163.com/centos/7/updates/$basearch/

gpgcheck=1

gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

 

#packages used/produced in the build but not released

[addons]

name=CentOS-$releasever - Addons

baseurl=http://mirrors.163.com/centos/$releasever/addons/$basearch/

gpgcheck=1

#gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful

[extras]

name=CentOS-$releasever - 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-$releasever - Plus

baseurl=http://mirrors.163.com/centos/7/centosplus/$basearch/

gpgcheck=1

enabled=0

7.更新yum源

yum clean  all 
   yum makecache 

此时会出现一个错误:

Loaded plugins: fastestmirror, product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
http://mirrors.163.com/centos/%24releasever/addons/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
Trying other mirror.
To address this issue please refer to the below knowledge base article 

https://access.redhat.com/articles/1320623

If above article doesn't help to resolve this issue please create a bug on  https://bugs.centos.org/

http://mirrors.sohu.com/centos/7/os/x86_64/repodata/repomd.xml 

: [Errno 14] curl#56 - "Recv failure: Connection reset by peer"
Trying other mirror.


 One of the configured repositories failed (CentOS-$releasever -Base),
 and yum doesn't have enough cached data to continue. At this point the only
 safe thing yum can do is fail. There are a few ways to work "fix" this:

     1. Contact the upstream for the repository and get them to fix the problem.

     2. Reconfigure the baseurl/etc. for the repository, to point to a working
        upstream. This is most often useful if you are using a newer
        distribution release than is supported by the repository (and the
        packages for the previous distribution release still work).

     3. Disable the repository, so yum won't use it by default. Yum will then
        just ignore the repository until you permanently enable it again or use
        --enablerepo for temporary usage:

            yum-config-manager --disable base

     4. Configure the failing repository to be skipped, if it is unavailable.
        Note that yum will try to contact the repo. when it runs most commands,
        so will have to try and fail each time (and thus. yum will be be much
        slower). If it is a very temporary problem though, this is often a nice
        compromise:

            yum-config-manager --save --setopt=base.skip_if_unavailable=true

failure: repodata/repomd.xml from base: [Errno 256] No more mirrors to try.
http://mirrors.sohu.com/centos/7/os/x86_64/repodata/repomd.xml 

: [Errno 14] curl#56 - "Recv failure: Connection reset by peer" 
按照提示执行下面两步即可解决:

yum-config-manager --disable base

yum-config-manager --save --setopt=base.skip_if_unavailable=true

8.可以安装一个软件测试下。

备注:我遇到一个报错。

error: public.gpg.key: import read failed(2).

按照提示

需要操作:rpm --import /etc/pki/rpm-gpg/*

这个要看具体目录,然后导入rpm-gpg.

gpgcheck是否进行数字签名检查,以防安装了被篡改的软件包,1为检查,0为不检查。

gpgcheck是gpg验证是否开启的选项,1是开启,0是不开启,一般情况可以关掉。

到这里就操作完成了。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值