redhat7

一、我们需要查询下rpm库中的yum文件

rpm -qa | grep yum

 

 

 

二、切换到root用户,通过以下命令删除yum文件

rpm -qa | grep yum | xargs rpm -e --nodeps

三、寻找并下载阿里镜像站下以下文件,有可能后面的版本号不同 最好自行搜索(目前是最新版本2020.2.19)

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-3.4.3-163.el7.centos.noarch.rpm 
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-52.el7.noarch.rpm 
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-utils-1.1.31-52.el7.noarch.rpm 
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/python-urlgrabber-3.10-9.el7.noarch.rpm

四、下载完成后,通过以下命令将文件安装到系统中

因为安装会有依赖的问题,所以加上--force参数强制安装

rpm -ivh yum-metadata-parser-1.1.4-10.el7.x86_64.rpm yum-3.4.3-163.el7.centos.noarch.rpm yum-plugin-fastestmirror-1.1.31-52.el7.noarch.rpm yum-utils-1.1.31-52.el7.noarch.rpm python-urlgrabber-3.10-9.el7.noarch.rpm --force --nodeps

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

(把原来redhat的文件备份)

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

六、修改刚下载的文件 将所有$releasever替换为7

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

:%s/$releasever/7/g

 

七、运行以下命令即可

yum clean all 
yum makecache
yum list ---查看

 

https://blog.csdn.net/yangZHyu/article/details/80565032稍做修改

 

 更换本地镜像yum源

这次是redhat6.1

vi /etc/yum.repos.d/rhel-source.repo

文件内容

[media]
name=Red Hat Enterprise Linux 6.1
baseurl=file:///zcs/iso 这里是镜像位置
enabled=1
gpgcheck=1

镜像文件长这个样子

 

 

 

 







posted on 2020-02-19 10:54  我有我的信仰  阅读(1618)  评论(0)    收藏  举报