当前位置: > CentOS > CentOS服务器 > 环境配置 >

CentOS 6.5下本地yum源与网络yum源同时使用

时间:2014-10-22 09:51来源:linux.it.net.cn 作者:it

一、本地yum源

1、系统默认已经安装了可使用yum的软件包,所以可以直接配置:

[root@localhost ~]# cd /etc/yum.repos.d/                         yum源配置文件放置目录

 

[root@localhost yum.repos.d]# mv CentOS-Base.repo CentOS-Base.repo.bak    先将网络yum源        配置文件更名(让其失效)

[root@localhost yum.repos.d]# vim CentOS-Media.repo                编辑本地yum源文件

 

[c6-media]

name=CentOS-$releasever - Media        本地yum源名称(可随意修改)

baseurl=file:///mnt/sr0                光盘挂载目录/mnt/sr0

gpgcheck=1                             

enabled=1                              使用此yum源(等于0为不启用)

gpgkey=file:///mnt/sr0/RPM-GPG-KEY-CentOS-6      本地yum源密钥

 

二、网络yum源(前提是必须能连上互联网,此处使用的yum源是中国科技大学的地址如下:

中国科技大学:http://centos.ustc.edu.cn/centos/)

[root@localhost yum.repos.d]# mv CentOS-Base.bak CentOS-Base.repo      如果之前没更名就不用操作此步骤

[root@localhost yum.repos.d]# vim CentOS-Base.repo            编辑网络yum源文件

 

[base]

name=CentOS-$releasever - Base

#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os

baseurl=http://centos.ustc.edu.cn/centos/$releasever/os/$basearch/

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

 

#released updates 

[updates]

name=CentOS-$releasever - Updates

#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates

baseurl=http://centos.ustc.edu.cn/centos/$releasever/updates/$basearch/

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

 

#additional packages that may be useful

[extras]

name=CentOS-$releasever - Extras

#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras

baseurl=http://centos.ustc.edu.cn/centos/$releasever/extras/$basearch/

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

 

#additional packages that extend functionality of existing packages

[centosplus]

name=CentOS-$releasever - Plus

#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus

baseurl=http://centos.ustc.edu.cn/centos/$releasever/centosplus/$basearch/

gpgcheck=1

enabled=0

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

 

#contrib - packages by Centos Users

[contrib]

name=CentOS-$releasever - Contrib

#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib

baseurl=http://centos.ustc.edu.cn/centos/$releasever/contrib/$basearch/

gpgcheck=1

enabled=0

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6


三、注意事项:

使用yum时最好只能让一个yum源生效,因为系统默认优先使用网络yum源。

(责任编辑:IT)
------分隔线----------------------------