RHEL6: how to use Centos6 yum

Ref:

http://www.dedecms.com/knowledge/servers/linux-bsd/2012/0819/8475.html


Almost right there.


1、删除RHEL原有的yum
rpm -aq|grep yum|xargs rpm -e --nodeps #删除

2、下载新的yum安装包 #这里我们使用CentOS的yum源

学校里的镜像

http://centos.ustc.edu.cn/centos/6.7/os/x86_64/Packages/


wget http://centos.ustc.edu.cn/centos/6.7/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm http://centos.ustc.edu.cn/centos/6.7/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm http://centos.ustc.edu.cn/centos/6.7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-30.el6.noarch.rpm http://centos.ustc.edu.cn/centos/6.7/os/x86_64/Packages/yum-3.2.29-69.el6.centos.noarch.rpm

结果:

下载完毕 --2015-08-15 14:16:00--
下载了:4 个文件,1.3s (820 KB/s) 中的 1.1M



3、安装yum软件包

rpm -ivh *.rpm

接着

[root@localhost z]# rpm -ivh yum*.rpm
warning: yum-3.2.29-69.el6.centos.noarch.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing...                ########################################### [100%]
   1:yum-metadata-parser    ########################################### [ 33%]
   2:yum-plugin-fastestmirro########################################### [ 67%]
   3:yum                    ########################################### [100%]
[root@localhost z]#



4、更改yum源 #我们使用网易的CentOS镜像源
cd /etc/yum.repos.d/
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo

vi CentOS6-Base-163.repo #编辑文件

学校则获取如下源


这是CentOS 6的:

# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#

[base]
name=CentOS-$releasever - Base - mirrors.ustc.edu.cn
baseurl=http://mirrors.ustc.edu.cn/centos/$releasever/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
gpgcheck=1
gpgkey=http://mirrors.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-6

#released updates
[updates]
name=CentOS-$releasever - Updates - mirrors.ustc.edu.cn
baseurl=http://mirrors.ustc.edu.cn/centos/$releasever/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=http://mirrors.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-6

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.ustc.edu.cn
baseurl=http://mirrors.ustc.edu.cn/centos/$releasever/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=http://mirrors.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-6

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

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


注意将其中带$的定义改掉。

否则yum makecache会出错。见附录出错报告。

修改后内容

# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#

[base]
name=CentOS-6.7 - Base - mirrors.ustc.edu.cn
baseurl=http://mirrors.ustc.edu.cn/centos/6.7/os/x86_64/
#mirrorlist=http://mirrorlist.centos.org/?release=6.7&arch=x86_64&repo=os
gpgcheck=1
gpgkey=http://mirrors.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-6

#released updates
[updates]
name=CentOS-6.7 - Updates - mirrors.ustc.edu.cn
baseurl=http://mirrors.ustc.edu.cn/centos/6.7/updates/x86_64/
#mirrorlist=http://mirrorlist.centos.org/?release=6.7&arch=x86_64&repo=updates
gpgcheck=1
gpgkey=http://mirrors.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-6

#additional packages that may be useful
[extras]
name=CentOS-6.7 - Extras - mirrors.ustc.edu.cn
baseurl=http://mirrors.ustc.edu.cn/centos/6.7/extras/x86_64/
#mirrorlist=http://mirrorlist.centos.org/?release=6.7&arch=x86_64&repo=extras
gpgcheck=1
gpgkey=http://mirrors.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-6

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-6.7 - Plus - mirrors.ustc.edu.cn
baseurl=http://mirrors.ustc.edu.cn/centos/6.7/centosplus/x86_64/
#mirrorlist=http://mirrorlist.centos.org/?release=6.7&arch=x86_64&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=http://mirrors.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-6

#contrib - packages by Centos Users
[contrib]
name=CentOS-6.7 - Contrib - mirrors.ustc.edu.cn
baseurl=http://mirrors.ustc.edu.cn/centos/6.7/contrib/x86_64/
#mirrorlist=http://mirrorlist.centos.org/?release=6.7&arch=x86_64&repo=contrib
gpgcheck=1
enabled=0
gpgkey=http://mirrors.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-6

修改方法:

vi c6.repo

替换如下

:%s/\$releaseserver/6.7/g

:%s/\$arch/x86_64/g

其中,

%:表示全局替换, s表示替换动作,/\$releaseserver/表示被替换者, 6.7表示替换后。g暂时不清楚,global?(FIXME)


附录:出错报告。

[root@localhost yum.repos.d]# yum makecache
已加载插件:fastestmirror, product-id, subscription-manager
Updating certificate-based repositories.
http://mirrors.ustc.edu.cn/centos/%24releasever/os/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404"
尝试其他镜像。
错误:Cannot retrieve repository metadata (repomd.xml) for repository: base. Please verify its path and try again
[root@localhost yum.repos.d]#

附录:正确报告

[root@localhost yum.repos.d]# yum makecache
已加载插件:fastestmirror, product-id, subscription-manager
Updating certificate-based repositories.
Loading mirror speeds from cached hostfile
base                                                     | 3.7 kB     00:00     
base/primary_db                                          | 4.6 MB     00:04     
base/other_db                                            | 2.8 MB     00:10     
extras                                                   | 3.4 kB     00:00     
extras/filelists_db                                      |  29 kB     00:00     
extras/prestodelta                                       |  601 B     00:00     
extras/primary_db                                        |  26 kB     00:00     
extras/other_db                                          |  30 kB     00:00     
updates                                                  | 3.4 kB     00:00     
updates/filelists_db                                     | 695 kB     00:03     
updates/prestodelta                                      |  64 kB     00:00 

你可能感兴趣的:(RHEL6: how to use Centos6 yum)