rhel7遇到错误信息
[root@localhost ~]# yum install gcc-c++ 已加载插件:langpacks, product-id, search-disabled-repos, subscription-manager This system is not registered with an entitlement server. You can use subscription-manager to register. There are no enabled repos. Run "yum repolist all" to see the repos you have. To enable Red Hat Subscription Management repositories: subscription-manager repos --enable <repo> To enable custom repositories: yum-config-manager --enable <repo>
由于Red Hat Enterprise Linux 7 的更新包只对注册的用户生效,所以需要自己手动更改成CentOS 的更新包,CentOS几乎和RedHat是一样的,所以无需担心软件包是否可安装,下面是安装步骤。
解决办法
1、查看redhat 7.0系统本身所安装的那些yum软件包 rpm -qa | grep yum
[root@localhost ~]# rpm -qa | grep yum yum-langpacks-0.4.2-7.el7.noarch yum-utils-1.1.31-52.el7.noarch PackageKit-yum-1.1.10-1.el7.x86_64 yum-rhn-plugin-2.0.1-10.el7.noarch yum-metadata-parser-1.1.4-10.el7.x86_64 yum-3.4.3-163.el7.noarch
2、卸载这些软件包(每台机器所带包不同全部卸载就可以)
[root@localhost ~]# rpm -e yum-langpacks-0.4.2-7.el7.noarch --nodeps [root@localhost ~]# rpm -e yum-utils-1.1.31-52.el7.noarch --nodeps [root@localhost ~]# rpm -e PackageKit-yum-1.1.10-1.el7.x86_64 --nodeps [root@localhost ~]# rpm -e yum-rhn-plugin-2.0.1-10.el7.noarch --nodeps [root@localhost ~]# rpm -e yum-metadata-parser-1.1.4-10.el7.x86_64 --nodeps [root@localhost ~]# rpm -e yum-3.4.3-163.el7.noarch --nodeps
3、检查电脑是否可以上网,如果不能上网需手动下载软件包并上传到服务器进行安装
[root@localhost ~]# ping www.baidu.com PING www.a.shifen.com (180.101.49.11) 56(84) bytes of data. 64 bytes from 180.101.49.11 (180.101.49.11): icmp_seq=1 ttl=128 time=22.8 ms 64 bytes from 180.101.49.11 (180.101.49.11): icmp_seq=2 ttl=128 time=26.0 ms 64 bytes from 180.101.49.11 (180.101.49.11): icmp_seq=3 ttl=128 time=23.9 ms 64 bytes from 180.101.49.11 (180.101.49.11): icmp_seq=4 ttl=128 time=30.4 ms 64 bytes from 180.101.49.11 (180.101.49.11): icmp_seq=5 ttl=128 time=32.1 ms 64 bytes from 180.101.49.11 (180.101.49.11): icmp_seq=6 ttl=128 time=31.4 ms 64 bytes from 180.101.49.11 (180.101.49.11): icmp_seq=7 ttl=128 time=23.1 ms ^C --- www.a.shifen.com ping statistics --- 7 packets transmitted, 7 received, 0% packet loss, time 6018ms rtt min/avg/max/mdev = 22.808/27.163/32.180/3.804 ms
4、进入以下网站上面查看软件包的版本是否升级或者找到自己系统所对应的文件包版本更新
网易163网络源地址:http://mirrors.163.com/
CentOS网络源地址:http://centos.ustc.edu.cn/centos/
阿里云网络源地址:https://mirrors.aliyun.com/centos/
5、找到自己所需要的版本下载(包名会经常更新选择有的版本即可,可手工下载导入系统)
进入网络源地址,使用Ctrl+F检索关键字
找到安装包链接处右键选择复制下载链接
然后在linux终端使用wget +复制的地址下载
#两个python依赖 wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/python-urlgrabber-3.10-10.el7.noarch.rpm wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm #5个yum相关 wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-3.4.3-168.el7.centos.noarch.rpm wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-updateonboot-1.1.31-54.el7_8.noarch.rpm wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-utils-1.1.31-54.el7_8.noarch.rpm
6、安装软件包
rpm -ivh python-iniparse-0.4-9.el7.noarch.rpm rpm -ivh python-urlgrabber-3.10-10.el7.noarch.rpm --force --nodeps rpm -ivh yum-metadata-parser-1.1.4-10.el7.x86_64.rpm yum-3.4.3-168.el7.centos.noarch.rpm yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm yum-utils-1.1.31-54.el7_8.noarch.rpm yum-updateonboot-1.1.31-54.el7_8.noarch.rpm --force --nodeps
其中python也需要,安装会有依赖的问题,所以加上--force参数强制安装
输入指令rpm -ivh yum-*遇到报错,依赖项问题. 所以加上 -force参数强制安装
[root@localhost ~]# rpm -ivh yum-* warning: yum-3.4.3-158.el7.centos.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY error: Failed dependencies: python-urlgrabber >= 3.10-8 is needed by yum-3.4.3-158.el7.centos.noarch rpm >= 0:4.11.3-22 is needed by yum-3.4.3-158.el7.centos.noarch [root@localhost ~]# rpm -ivh yum-utils-1.1.31-54.el7_8.noarch.rpm 警告:yum-utils-1.1.31-54.el7_8.noarch.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY 错误:依赖检测失败: yum >= 3.4.3-143 被 yum-utils-1.1.31-54.el7_8.noarch 需要
测试yum
输入yum,如出现以下信息则说明安装成功
7、新建yum源的配置repo文件
将之前的备份并新建一个yum.repos.d,然后下载新的
网易的CentOS镜像源
wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
阿里CentOS镜像源
wget http://mirrors.aliyun.com/repo/Centos-7.repo
将之前的备份并新建一个yum.repos.d,然后下载新的
cd /etc mv yum.repos.d yum.repos.d.backup mkdir yum.repos.d cd yum.repos.d wget -O CentOS7-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
通过vim打开并编辑repo
vim CentOS7-Base.repo
修改CentOS7-Base.repo文件将所有$releasever替换为7
vim /etc/yum.repos.d/CentOS7-Base.repo 执行 :%s/$releasever/7/g :wq #保存
8、使设置生效
清除所有yum缓存
yum clean all
重新建立yum缓存
yum makecache
9、测试yum是否可用
yum search vim
本文由一叶发布,不代表一叶立场,转载联系作者并注明出处:https://yiyeo.com/linux/151.html