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 #