linux yum源完全配置一、简介
yum主要功能是更方便的添加/删除/更新RPM包,自动解决包的依赖性问题,便于管理大量系统的更新问题.
其理念是使用一个中心仓库(repository)管理一部分甚至一个distribution的应用程序相互关系,根据计算出来的软件依赖关系进行相关的升级,安装, 删除等操作,减少了Linux用户一直头痛的dependencies的问题. 可以同时配置多个资源库(Repository),简洁的配置文件(/etc/yum.conf),自动解决增加或删除rpm包时遇到的依赖性问题,保持与RPM数据库的一致性. 参考:http://www.linuxdiyf.com/bbs/thread-423690-1-1.html
二、修改yum源
步骤如下:
执行如下命令,查看yum包
rpm -qa|grep yum
执行如下命令,卸载原有源
rpm -qa | grep yum | xargs rpm -e --nodeps
下载新的yum包
wget http://centos.ustc.edu.cn/centos/6/os/i386/Packages/yum-3.2.29-22.el6.centos.noarch.rpmwget http://centos.ustc.edu.cn/centos/6/os/i386/Packages/yum-metadata-parser-1.1.2-16.el6.i686.rpm wget http://centos.ustc.edu.cn/centos/6/os/i386/Packages/yum-plugin-fastestmirror-1.1.30-10.el6.noarch.rpm
执行如下命令,安装新的yum包
rpm -ivh yum-*
下载yum的配置源
wget http://docs.linuxtone.org/soft/lemp/CentOS-Base.repo
修改配置源,内容如下:
[base]name=CentOS-6 - Basebaseurl=http://centos.ustc.edu.cn/centos/6/os/$basearch/gpgcheck=1gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-6#released updates[update]name=CentOS-6 - Updatesbaseurl=http://centos.ustc.edu.cn/centos/6/updates/$basearch/gpgcheck=1gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6#packages used/PRoduced in the build but not released[cr]name=CentOS-6 - crbaseurl=http://centos.ustc.edu.cn/centos/6/cr/$basearch/gpgcheck=1gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6#additional packages that may be useful[extras]name=CentOS-6 - Extrasbaseurl=http://centos.ustc.edu.cn/centos/6/extras/$basearch/gpgcheck=1gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6#additional packages that extend functionality of existing packages[centosplus]name=CentOS-6 - Plusbaseurl=http://centos.ustc.edu.cn/centos/6/centosplus/$basearch/gpgcheck=1enabled=0gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6#contrib - packages by Centos Users[contrib]name=CentOS-6 - Contribbaseurl=http://centos.ustc.edu.cn/centos/6/contrib/$basearch/gpgcheck=1enabled=0gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6[fasttrack]name=CentOS-6 - fasttrackbaseurl=http://centos.ustc.edu.cn/centos/6/fasttrack/$basearch/gpgcheck=1enabled=0gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
在该目录下执行yum update进行统一更新
三、使用第三方软件库
CentOS/RHEL默认的yum软件仓库非常有限,仅仅限于发行版本那几张盘里面的常规包和一些软件包的更新,利用RpmForge,可以增加非常多的第三方rpm软件包. RpmForge库现在已经拥有超过10000种CentOS的软件包,被CentOS社区认为是最安全也是最稳定的一个第三方软件库.
步骤如下:
1、安装yum-priorities插件 这个插件是用来设置yum在调用软件源时的顺序的. 因为官方提供的软件源,都是比较稳定和被推荐使用的. 因此,官方源的顺序要高于第三方源的顺序. 如何保证这个顺序,就需要安装yum-priorities这插件了.
# yum -y install yum-priorities
2、安装完yum-priorities插件后,需要设置/etc/yum.repos.d/ 目录下的.repo相关文件(如CentOS-Base.repo),在这些文件中插入顺序指令:priority=N (N为1到99的正整数,数值越小越优先)一般配置[base],[addons],[updates],[extras]的priority=1,[CentOSplus],[contrib]的priority=2,其他第三的软件源为:priority=N (推荐N>10),以CentOS-Base.repo 为例:##############################################################[base]name=CentOS-$releasever - Base#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=osbaseurl=http://ftp.sjtu.edu.cn/centos/$releasever/os/$basearch/gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6priority=1##############################################################
3、adobe软件仓
1、添加adobe软件仓并导入密钥
# rpm -ivh http://linuxdownload.adobe.com/linux/i386/adobe-release-i386-1.0-1.noarch.rpm #32位# rpm -ivh http://linuxdownload.adobe.com/linux/x86_64/adobe-release-x86_64-1.0-1.noarch.rpm #64位# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-adobe-linux #导入密钥
2、设置/etc/yum.repos.d/中的adobe-linux-x86_64.repo中的priority=10
现在可以安装adobe的Flashplayer插件了
# yum install flash-plugin
4、atomic软件仓
1、安装atomic源
# wget http://www.atomicorp.com/installers/atomic #下载# sh ./atomic #安装
2、设置/etc/yum.repos.d/中的atomic.repo中的priority=11
##############################################################[atomic]name=CentOS / Red Hat Enterprise Linux $releasever - atomicrocketturtle.commirrorlist=http://www.atomicorp.com/mirrorlist/atomic/centos-6-$basearch#mirrorlist=http://www.atomicorp.com/channels/atomic/centos/6/mirrors-atomicenabled=1protect=0gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY.art.txtpriority=11##############################################################
5、epel软件仓
1、安装epel yum源
CentOS 532位系统:# rpm -ivh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
64位系统:# rpm -ivh http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
导入key: # rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-5CentOS 632位系统:# rpm -ivh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
64位系统:# rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
导入key: # rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
2、设置/etc/yum.repos.d/中的epel.repo中的priority=12
提示:如果用比较新的软件,用epel-test.repo这个文件就行了
###############################################################[epel]name=Extra Packages for Enterprise Linux 6 - $basearch#baseurl=http://download.fedoraproject.org/pub/epel/6/$basearchmirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearchfailovermethod=priorityenabled=1gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6priority=12#################################################################
6、rpmforge软件仓
1、安装rpmforge软件源
# wget http://apt.sw.be/redhat/el6/en/i386/rpmforge/RPMS/rpmforge-release-0.5.3-1.el6.rf.i686.rpm #32位# wget http://apt.sw.be/redhat/el6/en/x86_64/rpmforge/RPMS/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm #64位# rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt #2安装DAG的PGP Key# rpm --import /etc/pki/rpm-gpg/* #导入本地的key# rpm -K rpmforge-release-0.5.3-1.el6.rf.*.rpm #验证rpmforge的rpm文件包# rpm -i rpmforge-release-0.5.3-1.el6.rf.i386.rpm #安装rpmforge的rpm文件包
2、设置/etc/yum.repos.d/rpmforge.repo文件中源的级别,priority=13
########################################################### Name: RPMforge RPM Repository for RHEL 6 - dag### URL: http://rpmforge.net/[rpmforge]name=RHEL $releasever - RPMforge.net - dagbaseurl=http://apt.sw.be/redhat/el6/en/$basearch/rpmforgemirrorlist=http://apt.sw.be/redhat/el6/en/mirrors-rpmforge#mirrorlist=file:///etc/yum.repos.d/mirrors-rpmforgeenabled=1protect=0gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-daggpgcheck=1priority=13########################################################
7、rpmfusion软件仓
rpmfusion主要为桌面发行版提供大量rpm包,而EPEL则为服务器版本提供大量的rpm包,而且大多数rpm包在官方repository中是找不到的
1、安装rpmfusion yum源
32位# rpm -ivh http://download1.rpmfusion.org/free/el/updates/6/i386/rpmfusion-free-release-6-1.noarch.rpm
# rpm -ivh http://download1.rpmfusion.org/nonfree/el/updates/6/i386/rpmfusion-nonfree-release-6-1.noarch.rpm
64位# rpm -ivh http://download1.rpmfusion.org/free/el/updates/6/x86_64/rpmfusion-free-release-6-1.noarch.rpm
# rpm -ivh http://download1.rpmfusion.org/nonfree/el/updates/6/x86_64/rpmfusion-nonfree-release-6-1.noarch.rpm
2、设置/etc/yum.repos.d/rpmfusion-free-updates.repo文件中源的级别,priority=14
#################################################################[rpmfusion-free-updates-testing]name=RPM Fusion for EL 6 - Free - Test Updates#baseurl=http://download1.rpmfusion.org/free/el/updates/testing/6/$basearch/mirrorlist=http://mirrors.rpmfusion.org/mirrorlist?repo=free-el-updates-testing-6&arch=$basearchenabled=1gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmfusion-free-el-6priority=14#################################################################
8、Percona软件仓
1、安装Percona yum源
rpm –ivh http://www.percona.com/downloads/percona-release/percona-release-0.0-1.x86_64.rpmrpm --import http://www.percona.com/downloads/percona-release/RPM-GPG-KEY-percona
2、设置/etc/yum.repos.d/Percona .repo文件中源的级别,priority=15
[percona]name = CentOS $releasever - Perconabaseurl=http://repo.percona.com/centos/7/os/$basearch/ enabled = 1gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-perconagpgcheck = 1priority=15
9、安装完毕后执行如下命令,就可以使用新的yum源管理软件了。
# yum clean all# yum makecache
9、163软件仓
1、安装163 yum源
rpm -ivh http://mirrors.163.com/.help/CentOS6-Base-163.reporpm --import http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
2、设置/etc/yum.repos.d/CentOS6-Base-163.repo文件中源的级别,priority=16
[base]name=CentOS-$releasever - Base - 163.combaseurl=http://mirrors.163.com/centos/7/os/$basearch/#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=osgpgcheck=1gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-7priority=16
四、创建本地软件库
参考:http://www.cnblogs.com/xiaoluo501395377/archive/2013/05/21/3089970.html