Chinaunix首页 | 论坛 | 博客
  • 博客访问: 609268
  • 博文数量: 244
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 130
  • 用 户 组: 普通用户
  • 注册时间: 2016-06-27 09:53
个人简介

记录学习,记录成长

文章分类

全部博文(244)

我的朋友

分类: LINUX

2015-06-02 16:36:49

配置(修改)网络yum源
以中科大yum源为例系统是32位,这次只是修改一下源
1.  创建repo文件(将之前的文件备份)
1.1  CentOS-Base.repo文件(网络yum源)
[root@www yum.repos.d]# vim CentOS-Base.repo 
[base]
name=CentOS-Base
baseurl= /> gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

#released updates 
[updates]
name=CentOS-Updates
baseurl= /> gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

#additional packages that may be useful
[extras]
name=CentOS-Extras
baseurl= /> gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-Plus
baseurl= /> gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

#contrib - packages by Centos Users
[contrib]
name=CentOS-Contrib
baseurl= /> gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-Debug-6

1.2  CentOS-Debuginfo.repo文件(Debug信息的yum源)
[debug]
name=CentOS-6 - Debuginfo
baseurl= /> gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-Debug-6
enabled=0

1.3  CentOS-Media.repo文件 (本地光盘yum源)
[c6-media]
name=CentOS-$releasever - Media
baseurl=file:///media/CentOS/
        file:///media/cdrom/
        file:///media/cdrecorder/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
可以创建一个目录将光盘挂载到该目录上,然后修改文件的路径为指定的路径即可;

1.4  CentOS-Vault.repo文件(虚拟yum源)
[C6.6-base]
name=CentOS-6.6 - Base
baseurl= /> gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=0

[C6.6-updates]
name=CentOS-6.6 - Updates
baseurl= /> gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=0

[C6.6-extras]
name=CentOS-6.6 - Extras
baseurl= /> gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=0

[C6.6-contrib]
name=CentOS-6.6 - Contrib
baseurl= /> gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=0

[C6.6-centosplus]
name=CentOS-6.6 - CentOSPlus
baseurl= /> gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=0
将其中的数字可以改为6.0-6.7都可以,源文件是6.0-6.3
注意:
(1)上文的gpgkey也可以写为gpgkey=这样就是联网获取了,不需要下载到本地;
(2)关于变量
?$releasever:代表发行版的版本,从[main]部分的distroverpkg获取,如果没有,则根据redhat-release包进行判断。
?$arch:cpu体系,如i686,athlon等
?$basearch:cpu的基本体系组,如i686和athlon同属i386,alpha和alphaev6同属alpha。
文件中的如也可以使用变量baseurl= /> (3)配置本地yum源时要把其他源关闭,简单点就是重命名为非.repo文件即可;
(4)配置网络yum源只需修改CentOS-Base.repo,配置本地yum源只需修改CentOS-Media.repo即可,另外两个文件我也不太清楚具体是怎么工作的,所以没做修改直接用的还是原来系统装的那个;
(5)配置本地yum源时别忘了把CentOS-Media.repo中的enabled=0改为enabled=1
2.  下载对应文件
[root@localhost rpm-gpg]# cd /etc/pki/rpm-gpg/
[root@localhost rpm-gpg]# wget ./
[root@localhost rpm-gpg]# wget ./
3.  导入KEY
[root@localhost rpm-gpg]# rpm --import RPM-GPG-KEY-CentOS-6 
[root@localhost rpm-gpg]#  rpm --import RPM-GPG-KEY-CentOS-Debug-6
3.  执行命令
yum  clean all
yum makecache

4.  使用第三方软件库
Centos/RHEL默认的yum软件仓库非常有限,仅仅限于发行版本那几张盘里面的常规包和一些软件包的更新,利用RpmForge可以增加非常多的第三方rpm软件包;
4.1  安装yum-priorities插件
这个插件是用来设置yum在调用源时的顺序的。因为官方提供的软件源,都是比较稳定和被推荐使用的。因此,官方源的顺序要高于第三方源的顺序。如何保证这个顺序,就需要安装yum-priorities这插件了。
[root@localhost ~]# yum install yum-plugin-priorities -y
4.2  设置.repo文件
在文件中插入一行priority=N (N为1到99的正整数,数值越小越优先);
一般配置[base], [updates], [extras] 的priority=1,[CentOSplus],[contrib]的priority=2,其他第三的软件源为:priority=N (推荐N>10)
4.3  下载对应rpmforge的包
[root@localhost yum.repos.d]# wget /> 4.4  安装DAG的PGP Key
[root@localhost yum.repos.d]# rpm --import /> 4.5  验证rpmforge的rpm文件包
[root@localhost yum.repos.d]# rpm -K rpmforge-release-0.5.3-1.el6.rf.i686.rpm
rpmforge-release-0.5.3-1.el6.rf.i686.rpm: (sha1) dsa sha1 md5 gpg OK
4.6  安装
[root@localhost yum.repos.d]# rpm -ivh rpmforge-release-0.5.3-1.el6.rf.i686.rpm
Preparing...                ########################################### [100%]
   1:rpmforge-release       ########################################### [100%]
4.7  设置/etc/yum.repos.d/rpmforge.repo文件中源的级别
[rpmforge]
name = RHEL $releasever - RPMforge.net - dag
baseurl = /> mirrorlist = /> #mirrorlist = file:///etc/yum.repos.d/mirrors-rpmforge
enabled = 1
protect = 0
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag
gpgcheck = 1
priority=12

5.  centos shiyong EPEL源
http://blog.chinaunix.net/uid-30212356-id-5161161.html

6.  说明
6.1  /etc/yum.conf文件
[main]
cachedir=/var/cache/yum #yum 缓存的目录,yum 在此存储下载的rpm 包和数据库,默认设置为/var/cache/yum

keepcache=0 #安装完成后是否保留软件包,0为不保留(默认为0),1为保留

debuglevel=2 #Debug 信息输出等级,范围为0-10,缺省为2

logfile=/var/log/yum.log #yum 日志文件位置。用户可以到/var/log/yum.log 文件去查询过去所做的更新。

pkgpolicy=newest #包的策略。一共有两个选项,newest和last,这个作用是如果你设置了多个repository,而同一软件在不同的repository 中同时存在,yum 应该安装哪一个,如果是newest,则yum 会安装最新的那个版本。如果是last,则yum 会将服务器id 以字母表排序,并选择最后的那个服务器上的软件安装。一般都是选newest。

distroverpkg=redhat-release #指定一个软件包,yum会根据这个包判断你的发行版本,默认是redhat-release,也可以是安装的任何针对自己发行版的rpm 包。

tolerant=1 #有1和0两个选项,表示yum是否容忍命令行发生与软件包有关的错误,比如你要安装1,2,3三个包,而其中3此前已经安装了,如果你设为1,则yum 不会出现错误信息。默认是0。

exactarch=1
#有1和0两个选项,设置为1则yum 只会安装和系统架构匹配的软件包,例如,yum 不会将i686的软件包安装在适合i386的系统中。默认为1。

retries=6 #网络连接发生错误后的重试次数,如果设为0,则会无限重试。默认值为6

obsoletes=1 #这是一个update的参数具体参阅yum(8),简单的说就是相当于upgrade,允许更新陈旧的RPM包

plugins=1 #是否启用插件,默认1为允许,0表示不允许。我们一般会用yum-fastestmirror这个插件。

bugtracker_url= />
# Note: yum-RHN-plugin doesn't honor this.
metadata_expire=1h
installonly_limit = 5
# PUT YOUR REPOS HERE OR IN separate files named file.repo
# in /etc/yum.repos.d

6.2  国内yum源
(1). 企业贡献:
搜狐开源镜像站: /> 网易开源镜像站: /> (2). 大学教学:
北京理工大学:
(IPv4 only)
(IPv6 only)
北京交通大学:
(IPv4 only)
(IPv6 only)
(IPv4+IPv6)
兰州大学: /> 厦门大学: /> 清华大学:
(IPv4+IPv6)
(IPv6 only)
(IPv4 only)
天津大学: /> 中国科学技术大学:
(IPv4+IPv6)
/> /> 东北大学:
(IPv4 only)
(IPv6 only)
电子科技大学: />
阅读(540) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~