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位系统为例):
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
经测试,以上命令仅仅前两个有效,后两个软件包需在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源被另一个进程锁住了错误,使用一下命令解锁:
rm -rf /var/run/yum.pid
7. 获取yum列表
yum makecache
出现下面提示,表示yum更改完成:
Metadata CacheCreated
网友评论