RedHat企业版7 “yum”重装 CentOS7 “yum”

默认情况下红帽的yum是需要注册的,据我所知要钱。而CentOSRedHat几乎是一样的,所以redhat的软件centos也可用,于是上网查资料没想到还真是可以,所以写了一个备忘录。万一以后还要用到呢。

也希望本文可以帮到有需要的人。

1.查看系统预装的yum rpm包:

rpm - qa | grep yum

以下是我的系统预装的软件(我的是redhat7):

[root@localhost ~]# rpm -qa|grep yum
yum-langpacks-0.4.2-4.el7.noarch
yum-metadata-parser-1.1.4-10.el7.x86_64
yum-3.4.3-132.el7.centos.0.1.noarch
yum-utils-1.1.31-34.el7.noarch
yum-plugin-fastestmirror-1.1.31-34.el7.noarch
yum-rhn-plugin-2.0.1-5.el7.noarch
PackageKit-yum-1.0.7-5.e17.x86_64

2.卸载上面的rpm包:

rpm -e yum-langpacks-0.4.2-4.el7.noarch --nodeps

后面的卸载方式依照上面。

3.更改yum仓库:

cd /etc/yum.repos.d/

wget 

下載文件:

其他对应即可。

下载centos 的rpm包:

对应你卸载的rpm包下载:(我卸载了这些所以我下载这些)

yum-langpacks-0.4.2-4.el7.noarch
yum-metadata-parser-1.1.4-10.el7.x86_64
yum-3.4.3-132.el7.centos.0.1.noarch
yum-utils-1.1.31-34.el7.noarch
yum-plugin-fastestmirror-1.1.31-34.el7.noarch
yum-rhn-plugin-2.0.1-5.el7.noarch
PackageKit-yum-1.0.7-5.e17.x86_64

下载地址:

4.安装rpm包:

rpm -ivh yum-3.4.3-132.el7.centos.0.1.noarch.rpm yum-plugin-fastestmirror-1.1.31-34.el7.noarch.rpm

上面两个包要一起安装,不然会有依赖错误

在安装其他的rpm包

5.清除缓存:

yum clean all

6.建立緩存:

yum makecache

如果出現一下報錯:

[root@localhost ~]# yum makecache                             
Loaded plugins: fastestmirror, langpacks, product-id, search-disabled-repos, subscription-
              : manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Could not retrieve mirrorlist =$releasever&arch=x86_64&repo=os error was
14: HTTP Error 404 - Not Found
%24releasever/os/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/
 
 
 One of the configured repositories failed (CentOS-$releasever - Base - 163.com),
 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 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.
$releasever/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found 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.
$releasever/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found

将/etc/yum.repos.d/CentOS7-Base-163.repo 文件中的$releasever替换成你的系统版本号即可。

到此yum已经替换好了。

可以用yum安装软件了:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/14658.html