紅帽系統(tǒng)更換CentOS源

1. 首先到 http://mirrors.163.com/centos 下載軟件包

i386地址:http://mirrors.163.com/centos/6/os/i386/Packages/
x86_64地址:http://mirrors.163.com/centos/6/os/x86_64/Packages/
必需要下載的軟件包有(以64位系統(tǒng)為例):

python-iniparse-0.3.1-2.1.el6.noarch.rpm
yum-3.2.29-69.el6.centos.noarch.rpm
yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
yum-plugin-fastestmirror-1.1.30-30.el6.noarch.rpm

下載命令(以下僅前兩個有效):

wget http://mirrors.163.com/centos/6/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-3.2.29-69.el6.centos.noarch.rpm
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-30.el6.noarch.rpm

經(jīng)測試,以上命令僅僅前兩個有效,后兩個軟件包需在http://mirrors.163.com/centos/6/os/x86_64/Packages手工下載下來,再安裝。

2. 卸載RedHat自帶的yum

rpm -qa | grepyum | xargs rpm -e --nodeps

3. 安裝下載的centos的rpm包:

rpm -ivh python-iniparse-0.3.1-2.1.el6.noarch.rpm
rpm -ivh yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
rpm -ivhyum-3.2.29-69.el6.centos.noarch.rpm yum-plugin-fastestmirror-1.1.30-30.el6.noarch.rpm

4. 下載CentOS6-Base-163.repo文件

http://mirrors.163.com的centos幫助文檔中下載CentOS6-Base-163.repo文件,存放到/etc/yum.repos.d中:

wget http://mirrors.163.com/.help/CentOS6-Base-163.repo

5. 編輯CentOS6-Base-163.repo文件

將 CentOS6-Base-163.repo 文件其中的 $releasever 更改為centos的版本號。
以下是修改好的(文件夾中有修改好的CentOS6-Base-163.repo,可直接替換后使用):

#CentOS-Base.repo
# Themirror system uses the connecting IP address of the client and the
# updatestatus of each mirror to pick mirrors that are updated to and
#geographically close to the client.  You should use this for CentOSupdates
#unless you are manually picking other mirrors.
# Ifthe mirrorlist= does not work for you, as a fall back you can try the
#remarked out baseurl= line instead.
[base]
name=CentOS-6- Base - 163.com
baseurl=http://mirrors.163.com/centos/6/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=os
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

#releasedupdates
[updates]
name=CentOS-6- Updates - 163.com
baseurl=http://mirrors.163.com/centos/6/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

#additionalpackages that may be useful
[extras]
name=CentOS-6- Extras - 163.com
baseurl=http://mirrors.163.com/centos/6/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

#additionalpackages that extend functionality of existing packages
[centosplus]
name=CentOS-6- Plus - 163.com
baseurl=http://mirrors.163.com/centos/6/centosplus/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

#contrib- packages by Centos Users
[contrib]
name=CentOS-6- Contrib - 163.com
baseurl=http://mirrors.163.com/centos/6/contrib/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=contrib
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

6. 清除原有緩存

yum clean all

如果提示yum源被另一個進(jìn)程鎖住了錯誤,使用一下命令解鎖:

rm -rf /var/run/yum.pid

7. 獲取yum列表

yum makecache

出現(xiàn)下面提示,表示yum更改完成:
Metadata CacheCreated

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容