解决rehl8 Unable to read consumer identity的问题

看看现在的时间吧01:00……本来想着今天能早点睡了,结果被这个问题折磨了一个多小时(尝试百度,然后CSDN上各种牛鬼蛇神的答案折磨)

感谢susu老师的录屏,经过几步简单的操作让我今晚能安心入眠。

起因

在进行源码编译安装的开头

1
2
3
4
[root@localhost ~]# yum -y install gcc make
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Error: There are no enabled repos.

哈哈出现了这个问题”This system is not registered to Red Hat”

其实就是需要换一下国内源,而用CentOS应该是没有问题的,这里就介绍以下rehl8的解决办法。

新解决办法

2023.1.2 好像阿里云的epel被删了,所以如果配置的阿里云的会失效了

挂好光驱之后

配置内容:

1
2
3
4
5
6
7
8
9
10
[AppStream]
name=rhel8.2
baseurl=file:///dvd/AppStream
enabled=1
gpgcheck=0
[BaseOS]
name=rhel8.2
baseurl=file:///dvd/BaseOS
enabled=1
gpgcheck=0

应该是可以用yum的了…

旧解决办法(!epel失效!)

先挂好光驱

临时挂载

1
2
[root@localhost ~]# mkdir /dvd/
[root@localhost ~]# mount /dev/cdrom /dvd/ #把光驱挂到/dvd下

至关重要的一步!!

修改配置文件,这里进行换源

1
[root@localhost ~]# vim /etc/yum.repos.d/dvd.repo

直接复制粘贴以下内容,但是注意如果你的不是挂载/dvd/下的,在注释的地方要作相应变动。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
[BaseOS]
name=BaseOS
baseurl=file:///dvd/BaseOS #具体路径修改
gpgcheck=1
gpgkey=/etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
[AppStream]
name=AppStream
baseurl=file:///dvd/AppStream #具体路径修改
gpgcheck=0
[epel]
name=EPEL
baseurl=http://mirrors.aliyun.com/epel/$releasever/Everything/$basearch
gpgcheck=0
enabled=1
[httpAppstream]
name=aliyun Appstream
baseurl=https://mirrors.aliyun.com/centos/$releasever/AppStream/$basearch/os
gpgcheck=0

记得ESC+:wq保存~

这一步设置之后就可以解决问题了!

重启之后都要重新mount,不太方便,接着进行:

永久挂载

1
2
3
4
[root@localhost ~]# vim /etc/fstab
#在末尾添加 空格分隔即可
/dev/cdrom /dvd/ iso9660 defaults 0 0
[root@localhost ~]# reboot #重启一下

检查挂好没

1
[root@localhost ~]# mount #看最后是否有 /dev/sr0 on /dvd....

开始装编译器

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[root@localhost ~]# yum clean /all  #清一下缓存
[root@localhost ~]# yum repolist -v #重新加载一下
[root@localhost ~]# yum -y install gcc gcc-c++ make
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
上次元数据过期检查:0:00:37 前,执行于 2022年11月02日 星期三 00时55分25秒。
错误:
问题 1: cannot install the best candidate for the job
- nothing provides libgcc >= 8.5.0-4.el8_5 needed by gcc-8.5.0-4.el8_5.x86_64
- nothing provides libgomp = 8.5.0-4.el8_5 needed by gcc-8.5.0-4.el8_5.x86_64
问题 2: cannot install the best candidate for the job
- nothing provides libstdc++ = 8.5.0-4.el8_5 needed by gcc-c++-8.5.0-4.el8_5.x86_64
(尝试添加 '--skip-broken' 来跳过无法安装的软件包 或 '--nobest' 来不只使用最佳选择的软件包)

这时候报错了。

确实,又报错了哈哈,应该是版本问题,还好susu也有讲,按照提示加上’–nobest’即可。

1
[root@localhost ~]# yum -y install --nobest gcc gcc-c++ make

搞掂!舒服了~ Zzz

对了,这时候别忘了拍张快照,一劳永逸:)