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
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 配置文件;
7.更新yum源yum clean all
yum makecache
此时会出现一个错误:
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是不开启,一般情况可以关掉。
到这里就操作完成了。