redhat7更換yum源位址為centos源

2021-10-12 12:55:52 字數 2247 閱讀 2760

檢視linux版本

[root@localhost yum.repos.d]

# uname -a

linux localhost.localdomain 3.10.0-693.el7.x86_64 #1 smp thu jul 6 19:56:57 edt 2017 x86_64 x86_64 x86_64 gnu/linux

[root@localhost yum.repos.d]

# cat /etc/redhat-release

red hat enterprise linux server release 7.4 (maipo)

[root@localhost yum.repos.d]

# cat /proc/version

linux version 3.10.0-693.el7.x86_64 ([email protected])

(gcc version 4.8.5 20150623 (red hat 4.8.5-16)

(gcc)

)#1 smp thu jul 6 19:56:57 edt 2017

[root@localhost yum.repos.d]

#

一、檢視系統原有yum所有元件

[root@syq yum.repos.d]

# rpm -qa |grep yum

yum-3.4.3-118.el7.noarch

yum-utils-1.1.31-24.el7.noarch

yum-rhn-plugin-2.0.1-4.el7.noarch

packagekit-yum-0.8.9-11.el7.x86_64

yum-langpacks-0.4.2-3.el7.noarch

yum-metadata-parser-1.1.4-10.el7.x86_64

二、解除安裝這些元件

[root@localhost ~]

# rpm -qa|grep yum|xargs rpm -e --nodeps(不檢查依賴,直接刪除rpm包)

wget 

wget

wget

wget

wget ( rpm -qa|

grep python-urlgrabber|

xargs rpm -e --nodeps )

rpm -ivh python-urlgrabber-3.10-8.el7.noarch.rpm

rpm -ivh yum-metadata-parser-1.1.4-10.el7.x86_64.rpm yum-3.4.3-150.el7.centos.noarch.rpm yum-plugin-fastestmirror-1.1.31-40.el7.noarch.rpm

四、更新yum源位址

cd  /etc/yum.repos.d/ #進入yum源位址的配置目錄下

mv /etc/yum.repos.d/centos-base.repo /etc/yum.repos.d/centos-base.repo.backup #備份以前的源位址

centos 5

wget -o /etc/yum.repos.d/centos-base.repo

centos 6

wget -o /etc/yum.repos.d/centos-base.repo

centos 7

wget -o /etc/yum.repos.d/centos-base.repo

更改centos-media.repo使其為不生效:

enabled=0

注意:修改centos-base.repo檔案中的$releasever全部替換為版本號7

$releasever 是乙個變數,這裡需要手動改為7

在vim中執行     :%s/$releasever/7/g                  快速替換,再儲存退出

:s///

五、更新yum源

yum clean all

yum makecache

yum update

參考:

公網yum 源位址

1.centos5.公網yum 源位址 root web cd etc yum.repos.d root web yum.repos.d wget o etc yum.repos.d centos base.repo 2.centos6.公網yum 源位址 root web cd etc yum.r...

紅帽網路yum常用源位址

root localhost vi etc yum.repos.d rhel source.repo 將這裡面的內容全部刪掉 不刪掉會出現問題,也可將原始檔重新命名rhel source.repo.back 替換成以下內容 base name centos releasever base baseu...

RedHat 7 配置本地yum源

本文配置本地yum源是把redhat 7的系統盤內容複製到伺服器硬碟的目錄 rh7iso中,然後配置yum指向該目錄。本文原始出處 江健龍的技術部落格 首先掛載光碟機到 mnt目錄 mount dev cdrom mnt 複製系統盤的內容到 rh7iso目錄中 cp r mnt rh7iso 進入y...