美文网首页
rhel 7 配置国内公网yum源

rhel 7 配置国内公网yum源

作者: 不明世事的运维人 | 来源:发表于2023-02-13 21:05 被阅读0次
rhel7 配置国内163 Centos yum 源,会因为未注册而不能使用;

红帽需要操作系统注册后才能使用yum。如果是这样就很头疼了,如果我们内网环境无法注册,或者我们不想注册难道不能使用了吗?
办法还是有的,那就让我们把这个功能关掉。

[问题分析]
1、yum源调用订阅管理器插件(其实是一个脚本)

 /usr/lib/yum-plugins/subscription-manager.py 

这个脚本中定义了订阅管理器的配置文件

db8cee403694487980f3bf1da772fcba.png

2、订阅管理器配置文件定义功能启停

/etc/yum/pluginconf.d/subscription-manager.conf 
[main] 
enabled=1

3、如果订阅管理器是开启的,就会更新repo文件
/etc/yum.repos.d/redhat.repo
也就是说开启订阅管理器,就会更新或者重置redhat.repo,即使你把这个文件删掉,也不管用。
[解决方法]
关闭订阅管理器功能

[root@localhost yum.repos.d]# vim /etc/yum/pluginconf.d/subscription-manager.conf
[main]
enabled=0

将enabled置为0即可。

测试过程:

  1. 首先移除/etc/yum.repos.d/ 下的 rhel 源
[root@mysqlhost ~]# cd /etc/yum.repos.d/
[root@mysqlhost yum.repos.d]# ls
 redhat.repo
[root@mysqlhost yum.repos.d]# rm *
rm: remove regular file ‘redhat.repo’? y
[root@mysqlhost yum.repos.d]# ll
total 0
[root@mysqlhost yum.repos.d]# 
  1. 下载163 镜像仓库的yum源,然后查看文件
[root@mysqlhost yum.repos.d]# wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
--2023-02-14 20:11:21--  http://mirrors.163.com/.help/CentOS7-Base-163.repo
Resolving mirrors.163.com (mirrors.163.com)... 101.71.33.11
Connecting to mirrors.163.com (mirrors.163.com)|101.71.33.11|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1572 (1.5K) [application/octet-stream]
Saving to: ‘CentOS7-Base-163.repo’

100%[=======================================================================================>] 1,572       --.-K/s   in 0s      

2023-02-14 20:11:21 (102 MB/s) - ‘CentOS7-Base-163.repo’ saved [1572/1572]

[root@mysqlhost yum.repos.d]# ls
CentOS7-Base-163.repo
  1. 使用 yum clean all 清除yum 缓存
[root@mysqlhost yum.repos.d]# yum clean all 
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager

This system is not registered with an entitlement server. You can use subscription-manager to register.

Cleaning repos: base extras updates
[root@mysqlhost yum.repos.d]# ls
CentOS7-Base-163.repo  redhat.repo

发现清理过程中报错该系统未注册,您可以使用订阅管理器进行注册。并且会讲原有的redat.repo 回复回来,

  1. 配置关闭订阅管理器功能
[root@mysqlhost yum.repos.d]# vim /etc/yum/pluginconf.d/subscription-manager.conf 
[main]
enabled=0
  1. 关闭订阅管理器后再次执行:
    a. 移除rhel 的repl 源
    b. 执行 yum makecache
[root@mysqlhost yum.repos.d]# ls
CentOS7-Base-163.repo  redhat.repo
[root@mysqlhost yum.repos.d]# rm redhat.repo 
rm: remove regular file ‘redhat.repo’? y
[root@mysqlhost yum.repos.d]# ll
total 4
-rw-r--r--. 1 root root 1572 Dec  1  2016 CentOS7-Base-163.repo
[root@mysqlhost yum.repos.d]# yum makecache 
Loaded plugins: langpacks, product-id, search-disabled-repos
http://mirrors.163.com/centos/7Server/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 open a ticket with Red Hat Support.



 One of the configured repositories failed (CentOS-7Server - 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 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. Run the command with the repository temporarily disabled
            yum --disablerepo=base ...

     4. Disable the repository permanently, 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
        or
            subscription-manager repos --disable=base

     5. 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.163.com/centos/7Server/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found

发现报错为找不到对应的路径:

http://mirrors.163.com/centos/7Server/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found

6 、查看163 的repl源文件,并查看源地址的网站,以及前面的报错找不到的对应路径。


image.png
image.png image.png
发现是因为 repo 中 的/$releasever/ 获取的值获取错误了,因为系统是rhel,而我们用的源是Centos 因此将 /$releasever/直接改为/7/ 即可。
image.png

再次执行yum makecache ,并尝试使用yum 安装lrzsz 工具

[root@mysqlhost yum.repos.d]# yum makecache 
Loaded plugins: langpacks, product-id, search-disabled-repos
base                                                                                                      | 3.6 kB  00:00:00     
extras                                                                                                    | 2.9 kB  00:00:00     
updates                                                                                                   | 2.9 kB  00:00:00     
(1/10): base/x86_64/group_gz                                                                              | 153 kB  00:00:00     
(2/10): base/x86_64/primary_db                                                                            | 6.1 MB  00:00:01     
(3/10): base/x86_64/filelists_db                                                                          | 7.2 MB  00:00:01     
(4/10): extras/x86_64/primary_db                                                                          | 249 kB  00:00:00     
(5/10): extras/x86_64/filelists_db                                                                        | 276 kB  00:00:00     
(6/10): base/x86_64/other_db                                                                              | 2.6 MB  00:00:00     
(7/10): extras/x86_64/other_db                                                                            | 149 kB  00:00:00     
(8/10): updates/x86_64/filelists_db                                                                       |  11 MB  00:00:00     
(9/10): updates/x86_64/other_db                                                                           | 1.3 MB  00:00:00     
(10/10): updates/x86_64/primary_db                                                                        |  19 MB  00:00:01     
Metadata Cache Created
[root@mysqlhost yum.repos.d]# 
[root@mysqlhost yum.repos.d]# 
[root@mysqlhost yum.repos.d]# yum -y install lrzsz
Loaded plugins: langpacks, product-id, search-disabled-repos
Resolving Dependencies
--> Running transaction check
---> Package lrzsz.x86_64 0:0.12.20-36.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=================================================================================================================================
 Package                     Arch                         Version                               Repository                  Size
=================================================================================================================================
Installing:
 lrzsz                       x86_64                       0.12.20-36.el7                        base                        78 k

Transaction Summary
=================================================================================================================================
Install  1 Package

Total download size: 78 k
Installed size: 181 k
Downloading packages:
warning: /var/cache/yum/x86_64/7Server/base/packages/lrzsz-0.12.20-36.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Public key for lrzsz-0.12.20-36.el7.x86_64.rpm is not installed
lrzsz-0.12.20-36.el7.x86_64.rpm                                                                           |  78 kB  00:00:00     
Retrieving key from http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
 Userid     : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
 Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
 From       : http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : lrzsz-0.12.20-36.el7.x86_64                                                                                   1/1 
  Verifying  : lrzsz-0.12.20-36.el7.x86_64                                                                                   1/1 

Installed:
  lrzsz.x86_64 0:0.12.20-36.el7                                                                                                  

Complete!
[root@mysqlhost yum.repos.d]#                                                                  

最终成功。

相关文章

  • rhel 7 配置国内公网yum源

    rhel7 配置国内163 Centos yum 源,会因为未注册而不能使用; 红帽需要操作系统注册后才能使用yu...

  • RHEL 配置第三方源

    RHEL6.2 配置第三方源 yum可以自动解决软件包的依赖问题,简化软件安装,但RHEL的yum源是收费的,无法...

  • ansible EPRL源

    红帽(CentOS)需要配置EPEL源 RHEL/CentOS 6 yum installhttps://dl.f...

  • Linux配置网络YUM源

    若yum下载的时候出现了如下报错 可通过配置网络yum 源RHEL7.2解决

  • yum切换国内源

    yum切换国内源 配置dns服务器 配置yum的源 参考链接: yum配置国内源 备份/etc/yum.repos...

  • PHP7.0安装

    更新yum源 系统版本CentOS/RHEL 7.x: CentOS/RHEL 6.x: php7.0安装 上述命...

  • RHEL7 本地yum源配置

    我们在安装Redhat的时候一般都不会填写注册信息,因为该产品是要购买的,所以我们在使用安装好的Redhat时有的...

  • 常用yum源介绍及配置

    参考: CentOS 7下配置本地yum源及yum客户端 Centos7 配置本地源+阿里yum源/epel-yu...

  • Oracle专题一之Oracle的安装

    10g安装 配置YUM源(国内阿里的还不错,也可以配置挂载的yum源) yum install -y binuti...

  • DHCP配置文档

    1、配置YUM vim /etc/yum.repos.d/rhel-debuginfo.repo [rhel-de...

网友评论

      本文标题:rhel 7 配置国内公网yum源

      本文链接:https://www.haomeiwen.com/subject/zvdskdtx.html