redhat7更换yum源 国内阿里镜像

众所周知,redhat是一款服务收费的系统,如果没有注册使用的话,yum是不允许使用的,接下来我会介绍下redhat7下更换yum源的操作

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

rpm -qa | grep yum

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

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


三、寻找并下载阿里镜像站下以下文件,有可能后面的版本号不同 最好自行搜索,不要复制命令

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

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

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

rpm -ivh yum-metadata-parser-1.1.4-10.el7.x86_64.rpm yum-3.4.3-158.el7.centos.noarch.rpm yum-plugin-fastestmirror-1.1.31-45.el7.noarch.rpm yum-utils-1.1.31-45.el7.noarch.rpm --force --nodeps

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

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/$releaserver/7/g

七、运行以下命令即可

yum clean all 
yum makecache
yum update


猜你喜欢

转载自blog.csdn.net/yangZHyu/article/details/80565032
今日推荐