凉城旧巷
Python从入门到自闭,Java从自闭到放弃,数据库从删库到跑路,Linux从rm -rf到完犊子!!!

RedHat换源

1、卸载redhat源

# 查看已安装yum
rpm -qa | grep yum

[fhu@vmachine ~]$ rpm -qa | grep yum
PackageKit-yum-1.1.10-2.el7.centos.x86_64
yum-plugin-fastestmirror-1.1.31-53.el7.noarch
yum-rhn-plugin-2.0.1-10.el7.noarch
yum-3.4.3-167.el7.centos.noarch
yum-metadata-parser-1.1.4-10.el7.x86_64
yum-utils-1.1.31-53.el7.noarch
yum-langpacks-0.4.2-7.el7.noarch
# 卸载
[fhu@vmachine ~]$ rpm -e yum-rhn-plugin-2.0.1-10.el7.noarch --nodeps
[fhu@vmachine ~]$ rpm -e yum-metadata-parser-1.1.4-10.el7.x86_64 --nodeps
[fhu@vmachine ~]$ rpm -e yum-3.4.3-158.el7.noarch --nodeps
...

# 一键卸载
rpm -qa | grep yum | xargs rpm -e --nodeps

 

2、下载yum软件包

如果Not found,可能是源文件已更新,请去源网站中查询具体版本号

wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-3.4.3-168.el7.centos.noarch.rpm
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-utils-1.1.31-54.el7_8.noarch.rpm
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/python-urlgrabber-3.10-10.el7.noarch.rpm

 

3、安装yum软件包

# 因为安装会有依赖的问题,所以加上--force参数强制安装
[root@vmachine ~]$ rpm -ivh yum-* --force --nodeps

 

4、创建yum配置文件

下载阿里镜像到/etc/yum.repos.d/目录下

$ wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
# 修改Centos-7.repo文件 将所有$releasever替换为7

vim /etc/yum.repos.d/CentOS-Base.repo

:%s/$releasever/7/g

5、运行yum makecache命令生成缓存

[root@vmachine ~]$ yum clean all
[root@vmachine ~]$ yum makecache

注意:

如果一直提示以下错误,是因为redhat自带的插件subscription-manager给弄得的。而这个插件的作用就是Red Hat Subscription Manager订阅管理器,就是它让你一直register

Loaded plugins: fastestmirror, langpacks, product-id, search-disabled-repos, subscription-manager

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

# 禁用该插件
[root@vmachine ~]$ vim /etc/yum/pluginconf.d/subscription-manager.conf

# 将enabled改为0
[main]
enabled=0

 

6、关闭防火墙

[root@vmachine ~]$ systemctl stop  firewalld.service
[root@vmachine ~]$ systemctl disable  firewalld.service
posted on 2021-08-23 11:24  凉城旧巷  阅读(399)  评论(0编辑  收藏  举报