四、添加第三方RepoForge源 RepoForge原名RPMforge是 RHEL 系统下的软件仓库,拥有 10000 多个软件包,被认为是最安全、最稳定的一个软件仓库。是由 Dag 及其它包装者合作维护的,包括 wine、vlc、mplayer、xmms-mp3 及其它受欢迎的媒体工具。它并不是 Red Hat 或 CentOS 的一部份,但却是为那些发行版本而设计的,可能与EPEL源冲突,使用要注意。
安装源:要添加rpmfusion软件源,首先要安装epel-release这个软件包,前面添加EPEL源时提到过,你可能会担心安装这个软件包会和添加的阿里的EPEL冲突,如果是先添加阿里源,问题不大。然后去RPMFusion官方网站Configuration标签页下载RPM Fusion free for RHEL 6 or compatible like CentOS(自由的)和RPM Fusion nonfree for RHEL 6 or compatible like CentOS(非自由的)这两个安装包进行源的安装,我的系统是6版本所以下这两个,如果不先安装epel-release这个软件包,在进行上面两个软件包安装时会错误。 软件源下载官方网址: https://rpmfusion.org/Configuration
八、添加本地DVD源。 在服务器不允许联网的情况下经常会用到本地DVD安装光盘的源。 系统安装完默认会在/etc/yum.repos.d/的源目录下成才一个CentOS-Media.repo 的源文件,我们只要对这个源文件进行相应的设置就行 1、查看CentOS-Media.repo 文件内容: [root@CentOS yum.repos.d]# cat CentOS-Media.repo # CentOS-Media.repo # # This repo can be used with mounted DVD media, verify the mount point for # CentOS-6. You can use this repo and yum to install items directly off the # DVD ISO that we release. # # To use this repo, put in your DVD and use it with the other repos too: # yum --enablerepo=c6-media [command] # # or for ONLY the media repo, do this: # # yum --disablerepo=\* --enablerepo=c6-media [command] [c6-media] #源名称,必填 name=CentOS-$releasever - Media #源描述,可以不填,但是会有提示 baseurl=file:///media/CentOS/ #挂载DVD光驱的可选目录/media/CentOS/ ,这个目录可以因个人方便改变成其他目录 file:///media/cdrom/ #挂载DVD光驱的可选目录/media/cdrom/ file:///media/cdrecorder/ #挂载DVD光驱的可选目录/media/cdrecorder/ gpgcheck=1 #是否开启校验,在yum.conf中已经定义它默认值为1 enabled=0 #是否开启这个源,enabled=0为关闭,enabled=1为开启 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 #如果开启yum源包校验,则需要导入RPM公钥。 [root@CentOS yum.repos.d]#
2、在/media/目录下新建CentOS目录, [root@CentOS media]# mkdir CentOS [root@CentOS media]# ls CentOS
3、挂在DVD光驱到/media/CentOS/目录,一定要选择和系统版本号一样的系统镜像。 [root@CentOS ~]# mount /dev/cdrom1 /media/CentOS/
4、编辑官方源文件 /etc/yum.repos.d/CentOS-Base.repo 编辑如下: ------------------------------------------------------------------------------------------------------- [root@CentOS yum.repos.d]# vi CentOS-Base.repo # 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.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/ http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/ #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os gpgcheck=1 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6 priority=1 #设置[base]源优先级为1 #released updates [updates] name=CentOS-$releasever - Updates - mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/ http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/ #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates gpgcheck=1 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6 priority=1 #设置[updates]源优先级为1 #additional packages that may be useful [extras] name=CentOS-$releasever - Extras - mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/ http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/ #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras gpgcheck=1 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6 priority=1 #设置[extras]源优先级为1 #additional packages that extend functionality of existing packages [centosplus] name=CentOS-$releasever - Plus - mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/ http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/ #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus gpgcheck=1 enabled=0 #如果想开启这个源将enabled=0改为enabled=1 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6 priority=2 #设置[centosplus]源优先级为2 #contrib - packages by Centos Users [contrib] name=CentOS-$releasever - Contrib - mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/$releasever/contrib/$basearch/ http://mirrors.aliyuncs.com/centos/$releasever/contrib/$basearch/ #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib gpgcheck=1 enabled=0 #如果想开启这个源将enabled=0改为enabled=1 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6 priority=2 #设置[contrib]源优先级为2 [root@CentOS yum.repos.d]# ---------------------------------------------------------------------------------------------------------- 5、编辑[epel]第三方源优先级 ---------------------------------------------------------------------------------------------------------- [root@CentOS yum.repos.d]# vi epel.repo
[epel] name=Extra Packages for Enterprise Linux 6 - $basearch baseurl=http://mirrors.aliyun.com/epel/6/$basearch http://mirrors.aliyuncs.com/epel/6/$basearch #mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch failovermethod=priority enabled=1 gpgcheck=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 gpgcheck=11 #设置[epel]第三方源优先级为11 [epel-debuginfo] name=Extra Packages for Enterprise Linux 6 - $basearch - Debug baseurl=http://mirrors.aliyun.com/epel/6/$basearch/debug http://mirrors.aliyuncs.com/epel/6/$basearch/debug #mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-6&arch=$basearch failovermethod=priority enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 gpgcheck=0 [epel-source] name=Extra Packages for Enterprise Linux 6 - $basearch - Source baseurl=http://mirrors.aliyun.com/epel/6/SRPMS http://mirrors.aliyuncs.com/epel/6/SRPMS #mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-source-6&arch=$basearch failovermethod=priority enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 gpgcheck=0 [root@CentOS yum.repos.d]# -------------------------------------------------------------------------------------------------------------- 6、其他第三方源的优先级设置这里就不介绍了,/etc/yum.repos.d/目录下文件名后缀为.repo的文件都是源文件,里面对应的源都需要设置,最好不要添加太多源 官方源和EPEL源就够了,如果这里没有想要的软件在进行其他源的添加,添加过多的源维护起来麻烦,还容易造成软件源的冲突。 7、特殊情况:在不同优先级的源中都含有同一个包时,它的行为可能就不是我们所需要的。例如,在官方源中有个包:bck.1.11.x86_64.rpm,官方源是最高优先级。在其他的多个源中也有bck这个包的不同版本,比如bck的版本为bck.1.21.x86_64.rpm,通过命令安装bck.1.21.x86_64.rpm yum install bck.1.21.x86_64.rpm 就会出现下面的提示 xx packages excluded due to repository priority protections 并且找不到所需要的包,这是因为在高优先级源中存在的包,会将其他低优先级中的包屏蔽掉,因此无法从低优先级的源中安装所需要的包。