RedHat6配置CentOS6的yum源方法

来源:互联网 发布:冰镇西瓜 知乎 编辑:程序博客网 时间:2024/05/01 20:27

相关资源:

163镜像地址:http://mirrors.163.com/

CentOS32位系统相关包地址:http://mirrors.163.com/centos/6/os/i386/Packages/

CentOS64位系统相关包地址:http://mirrors.163.com/centos/6/os/x86_64/Packages/


具体步骤:

1、下载相关包:

必须的包(这里我用的是64位系统):

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

下载命令如下[建议切换到/opt 目录下执行命令,因为下载操作将现在文件到当前所在目录]:

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

[PS:可根据自行需要选择相关版本]


2、卸载RedHat自带的yum

卸载命令如下:

rpm -qa | grep yum | xargs rpm -e --nodeps

PS:

xargs是一条Unix和类Unix操作系统的常用命令。它的作用是将参数列表转换成小块分段传递给其他命令,以避免参数列表过长的问题
--nodeps  强制卸载,不管依赖性

3、安装第1步已下载的文件包

安装命令会在当前所以目录寻找文件,所以需保证已切换到/opt 目录下,执行下列命令安装相关文件包

rpm -ivh python-iniparse-0.3.1-2.1.el6.noarch.rpmrpm -ivh yum-metadata-parser-1.1.2-16.el6.x86_64.rpmrpm -ivh yum-3.2.29-40.el6.centos.noarch.rpm yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm


4、下载CentOS的帮助文件到/etc/yum.repo.d中:

帮助文件的163镜像地址根目录为:http://mirrors.163.com/.help/


切换到/etc/yum.repo.d目录下,运行下列命令下载CentOS6-Base-163.repo文件:

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

5、编辑CentOS6-Base-163.repo文件,将其中的$releasever全部替换为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-6 - Base - 163.combaseurl=http://mirrors.163.com/centos/6/os/$basearch/#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=osgpgcheck=1gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6#released updates [updates]name=CentOS-6 - Updates - 163.combaseurl=http://mirrors.163.com/centos/6/updates/$basearch/#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updatesgpgcheck=1gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6#additional packages that may be useful[extras]name=CentOS-$releasever - Extras - 163.combaseurl=http://mirrors.163.com/centos/6/extras/$basearch/#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extrasgpgcheck=1gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6#additional packages that extend functionality of existing packages[centosplus]name=CentOS-$releasever - Plus - 163.combaseurl=http://mirrors.163.com/centos/6/centosplus/$basearch/#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplusgpgcheck=1enabled=0gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6#contrib - packages by Centos Users[contrib]name=CentOS-6 - Contrib - 163.combaseurl=http://mirrors.163.com/centos/6/contrib/$basearch/#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contribgpgcheck=1enabled=0gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

6、清除原有缓存

yum clean all

7、获取yum列表

yum makecache
[PS:成功后会看到"Metadata Cache Created"消息提示]






0 0