rhel7 配置國內(nèi)163 Centos yum 源昭灵,會因為未注冊而不能使用姓蜂;
紅帽需要操作系統(tǒng)注冊后才能使用yum挥唠。如果是這樣就很頭疼了滔吠,如果我們內(nèi)網(wǎng)環(huán)境無法注冊纲菌,或者我們不想注冊難道不能使用了嗎?
辦法還是有的疮绷,那就讓我們把這個功能關(guān)掉翰舌。
[問題分析]
1、yum源調(diào)用訂閱管理器插件(其實是一個腳本)
/usr/lib/yum-plugins/subscription-manager.py
這個腳本中定義了訂閱管理器的配置文件
2冬骚、訂閱管理器配置文件定義功能啟停
/etc/yum/pluginconf.d/subscription-manager.conf
[main]
enabled=1
3椅贱、如果訂閱管理器是開啟的,就會更新repo文件
/etc/yum.repos.d/redhat.repo
也就是說開啟訂閱管理器只冻,就會更新或者重置redhat.repo庇麦,即使你把這個文件刪掉,也不管用喜德。
[解決方法]
關(guān)閉訂閱管理器功能
[root@localhost yum.repos.d]# vim /etc/yum/pluginconf.d/subscription-manager.conf
[main]
enabled=0
將enabled置為0即可山橄。
測試過程:
- 首先移除/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]#
- 下載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
- 使用 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
發(fā)現(xiàn)清理過程中報錯該系統(tǒng)未注冊,您可以使用訂閱管理器進行注冊住诸。并且會講原有的redat.repo 回復(fù)回來驾胆,
- 配置關(guān)閉訂閱管理器功能
[root@mysqlhost yum.repos.d]# vim /etc/yum/pluginconf.d/subscription-manager.conf
[main]
enabled=0
- 關(guān)閉訂閱管理器后再次執(zhí)行:
a. 移除rhel 的repl 源
b. 執(zhí)行 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
發(fā)現(xiàn)報錯為找不到對應(yīng)的路徑:
http://mirrors.163.com/centos/7Server/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
6 、查看163 的repl源文件贱呐,并查看源地址的網(wǎng)站,以及前面的報錯找不到的對應(yīng)路徑丧诺。
發(fā)現(xiàn)是因為 repo 中 的
/$releasever/
獲取的值獲取錯誤了,因為系統(tǒng)是rhel,而我們用的源是Centos 因此將 /$releasever/
直接改為/7/
即可奄薇。再次執(zhí)行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]#
最終成功。