RedHat使用yum安装出现This system is not registered to Red Hat Subscription Management - wxh1994/learn GitHub Wiki
现象
- [root@bogon ~]# yum install gcc-c++
- 已加载插件: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. 没有已启用的源。 执行 "yum repolist all" 查看您拥有的源。 您可以用 yum-config-manager --enable <源名> 来启用源
解决
一下载并安装yum包
- 查找所安装的yum包
- [root@bogon ~]# rpm -qa|grep yum
- yum-utils-1.1.31-34.el7.noarch
- PackageKit-yum-1.0.7-5.el7.x86_64
- yum-3.4.3-132.el7.noarch
- yum-metadata-parser-1.1.4-10.el7.x86_64
- yum-rhn-plugin-2.0.1-5.el7.noarch
- yum-langpacks-0.4.2-4.el7.noarch
- 卸载这些包
- [root@bogon ~]# rpm -qa|grep yum|xargs rpm -e --nodeps
- 警告:/etc/yum/pluginconf.d/langpacks.conf 已另存为 /etc/yum/pluginconf.d/langpacks.conf.rpmsave
- 检查是否卸载完
- [root@bogon ~]# rpm -qa|grep yum
- 下载所需的rpm包 http://mirrors.kernel.org/centos/ 到此目录下查找yum、yum-plugin-fastestmirror、yum-metadata-parser、python-urlgrabber这四个软件包下载。 依次运行:
- wget https://mirrors.edge.kernel.org/centos/7.6.1810/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
- wget https://mirrors.edge.kernel.org/centos/7.6.1810/os/x86_64/Packages/python-urlgrabber-3.10-9.el7.noarch.rpm
- wget https://mirrors.edge.kernel.org/centos/7.6.1810/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-50.el7.noarch.rpm
- wget https://mirrors.edge.kernel.org/centos/7.6.1810/os/x86_64/Packages/yum-3.4.3-161.el7.centos.noarch.rpm 下载完成:
- [root@bogon download]# ll
- 总用量 1444
- -rw-r--r--. 1 root root 110944 11月 12 23:19 python-urlgrabber-3.10-9.el7.noarch.rpm
- -rw-r--r--. 1 root root 1296152 11月 12 23:27 yum-3.4.3-161.el7.centos.noarch.rpm
- -rw-r--r--. 1 root root 28348 7月 4 2014 yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
- -rw-r--r--. 1 root root 34500 11月 12 23:27 yum-plugin-fastestmirror-1.1.31-50.el7.noarch.rpm
- 安装 依次运行
- rpm -ivh yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
- rpm -ivh --force python-urlgrabber-3.10-9.el7.noarch.rpm
- rpm -ivh yum-plugin-fastestmirror-1.1.31-50.el7.noarch.rpm yum-3.4.3-161.el7.centos.noarch.rpm 其中运行第三条汇报如下问题
- [root@bogon download]# rpm -ivh yum-plugin-fastestmirror-1.1.31-50.el7.noarch.rpm yum-3.4.3-161.el7.centos.noarch.rpm
- 警告:yum-plugin-fastestmirror-1.1.31-50.el7.noarch.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
- 错误:依赖检测失败:
- rpm >= 0:4.11.3-22 被 yum-3.4.3-161.el7.centos.noarch 需要 解决方法如下
- wget http://mirrors.163.com/centos/7/os/x86_64/Packages/rpm-4.11.3-35.el7.x86_64.rpm
- rpm -Uvh rpm-4.11.3-35.el7.x86_64.rpm --nodeps 然后再次运行
- rpm -ivh yum-plugin-fastestmirror-1.1.31-50.el7.noarch.rpm yum-3.4.3-161.el7.centos.noarch.rpm
二更新yum源
- [root@bogon download]# cd /etc/yum.repos.d/
- [root@bogon yum.repos.d]# rm redhat.repo rm:是否删除普通文件 "redhat.repo"?y
- [root@bogon yum.repos.d]# touch CentOS-Base.repo
- [root@bogon yum.repos.d]# chmod +777 CentOS-Base.repo
- [root@bogon yum.repos.d]# vi CentOS-Base.repo
打开网址http://mirrors.163.com/.help/centos.html 在里面找到对应版本下载repo文件,把它放在/etc/yum.repos.d/下面,然后打开文件将里面$releasever全部修改为版本号7 得到如下文本,将此文本粘贴到CentOS-Base.repo
#CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS- - Base - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=&arch=$basearch&repo=os
baseurl=http://mirrors.163.com/centos/7/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS- - Updates - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=&arch=$basearch&repo=updates
baseurl=http://mirrors.163.com/centos/7/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS- - Extras - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=&arch=$basearch&repo=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- - Plus - 163.com
baseurl=http://mirrors.163.com/centos/7/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
最后 清理缓存,重新建立缓存,依次执行
- yum clean all
- yum makecache