前述
刚安装的 Redhat 使用 yum 安装工具时,可能会报错:
Loaded plugins: product-id, search-disabled-repos, subscription-managerThis 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>
这是因为使用 redhat 自带的 yum源 要付费,所以需要自己重新生成 yum源
更新源
1、这里使用 Redhat 7.6 做演示,查询已经安装的 redhatd rpm包
rpm -qa |grep yum# yum-rhn-plugin-2.0.1-10.el7.noarch# yum-metadata-parser-1.1.4-10.el7.x86_64# yum-3.4.3-161.el7.noarch
2、卸载已安装的 rpm包
rpm -e yum-rhn-plugin-2.0.1-10.el7.noarch --nodepsrpm -e yum-metadata-parser-1.1.4-10.el7.x86_64 --nodepsrpm -e yum-3.4.3-161.el7.noarch --nodeps
3、从 163镜像网站 中下载 centos 的 rpm包,并安装,下载地址:/centos
# 下载 rpm包curl -O /centos/7.9./os/x86_64/Packages/yum-3.4.3-168.el7.centos.noarch.rpmcurl -O /centos/7.9./os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpmcurl -O /centos/7.9./os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpmcurl -O /centos/7.9./os/x86_64/Packages/yum-cron-3.4.3-168.el7.centos.noarch.rpm# 安装包rpm -ivh *.rpm --nodeps --force
注:由于 rpm包 的链接可能实时变化,所以最好根据包名到镜像网站中自行查找对应的包链接
4、更改 yum源 为 清华镜像源
# 进入源目录cd /etc/yum.repos.d/# 删除 redhat 默认源rm redhat.repo# 下载163的centos7源curl -O /.help/CentOS7-Base-163.repo# 替换 CentOS7-Base-163.repo 中的 $releasever 为 7sed -i ‘s/$releasever/7/g’ CentOS7-Base-163.repo
5、清除原缓存并缓存新的yum列表
# 清除原缓存yum clean all# 缓存新的yum列表yum makecache