RedHat Enterprise Server RHEL  v7.7 yum更换国内阿里云镜像源

 

一般情况下安装了rhel v7后都使用光盘或是在内网建立yum源来安装和更新软件。如果可以连接到外网使用国内阿里云镜像yum源的话,就太方便了,以下是更换过程。

 

1,首先核对一下当前系统使用的yum版本

#rpm -qa | grep yum

只要是已经安装了yum就可以进行以下更换步骤。

 

2,su到root账号,使用命令删除yum相关文件

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

 

3,先打开浏览器打开https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/核对一下以下软件包版本,建议使用最新的软件包。然后下载到/tmp/install里

#mkdir /tmp/install
#cd /tmp/install
#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 

 

4,下载的软件包由于直接安装会有依赖的问题,所以加上--force参数强制安装

#rpm -ivh yum-metadata-parser-1.1.4-10.el7.x86_64.rpm \
python-urlgrabber-3.10-9.el7.noarch.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 \
--force --nodeps

 

5,下载阿里yum镜像配置文件到/etc/yum.repos.d/目录

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

 

6,编辑刚下载的yum配置文件 将所有$releasever替换为7

#vi /etc/yum.repos.d/CentOS-Base.repo

:%s/$releasever/7/g

 

7,运行以下命令更新yum源

#yum clean all 
#yum makecache
#yum update

 

8,测试一下使用阿里镜像yum源安装一个软件

#yum install -y redhat-lsb

完成后就可以使用相关命令了。

#lsb-release -d
Description:    NAME="Red Hat Enterprise Linux Server"
#
#lsb-release -a
LSB Version:    :core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch
Distributor ID: n/a
Description:    NAME="Red Hat Enterprise Linux Server"
Release:        n/a
Codename:       n/a
#

 

posted on 2019-12-03 18:02  zlg88  阅读(2791)  评论(0编辑  收藏  举报