技术交流QQ群:①185473046   ②190706903   ③203744115   网站地图
登录

下次自动登录
现在的位置: 首页CentOS>正文
CentOS 6.2 使用第三方yum源安装更多rpm软件包
2012年01月29日 CentOS 评论数 2 ⁄ 被围观 35,182次+


引言:
      
CentOS自带的yum源中rpm包数量有限,很多时候找不到我们需的软件包,(例如:要安装网络连接查看软件iftop,默认设置下无法使用yum命令安装),
下面教大家在CentOS 6.2中(以32位系统为例,64位系统安装方法一样),使用第三方yum源来安装更多软件包。


一、安装CentOS yum源优先级插件yum-priorities

      yum install yum-priorities   #输入y安装
二、设置CentOS默认yum源的优先级为最高
系统运维  www.osyunwei.com  温馨提醒:qihang01原创内容©版权所有,转载请注明出处及原文链接
     cd  /etc/yum.repos.d/   #进入yum源目录
     vi CentOS-Base.repo    #在[base]、[updates]、[extras]组下面添加priority=1,在[centosplus]、[contrib]组下面添加priority=2
################################################################   
[base]
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
priority=1

[updates]
name=CentOS-$releasever - Updates
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
priority=1

[extras]
name=CentOS-$releasever - Extras
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
priority=1

[centosplus]
name=CentOS-$releasever - Plus
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
priority=2

[contrib]
name=CentOS-$releasever - Contrib
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
#baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
priority=2
###############################################################   
备注:priority的优先级为1到99,设置为1即优先级最高,1-10为系统保留,第三方yum源的优先级从11-99
三、安装epel yum源
    rpm -ivh  http://download.fedora.redhat.com/pub/epel/6/i386/epel-release-6-5.noarch.rpm
    rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
    vi /etc/yum.repos.d/epel.repo   #修改epel yum源优先级,priority=11
   
###############################################################
    [epel]
name=Extra Packages for Enterprise Linux 6 - $basearch
#baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
priority=11
#################################################################
四、安装rpmforge yum源
   wget http://apt.sw.be/redhat/el6/en/i386/rpmforge/RPMS/rpmforge-release-0.5.2-2.el6.rf.i686.rpm
   wget http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
   rpm --import RPM-GPG-KEY.dag.txt
   rpm -ivh rpmforge-release-0.5.2-2.el6.rf.i686.rpm
   vi  /etc/yum.repos.d/rpmforge.repo  #修改rpmforge yum源优先级,priority=12
  
#################################################################
[rpmforge]
name = RHEL $releasever - RPMforge.net - dag
baseurl = http://apt.sw.be/redhat/el6/en/$basearch/rpmforge
mirrorlist = http://apt.sw.be/redhat/el6/en/mirrors-rpmforge
#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
#################################################################
系统运维  www.osyunwei.com  温馨提醒:qihang01原创内容©版权所有,转载请注明出处及原文链接
五、安装rpmfusion yum源

   rpm -ivh http://download1.rpmfusion.org/free/el/updates/testing/6/i386/rpmfusion-free-release-6-0.1.noarch.rpm
   vi  /etc/yum.repos.d/rpmfusion-free-updates-testing.repo   #修改rpmfusion yum源优先级,priority=13
 
#################################################################
[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=$basearch
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmfusion-free-el-6
priority=13
系统运维  www.osyunwei.com  温馨提醒:qihang01原创内容©版权所有,转载请注明出处及原文链接
#################################################################
六、安装atomic yum源
    wget http://www.atomicorp.com/installers/atomic  #下载
    sh ./atomic   #安装
    vi  /etc/yum.repos.d/atomic.repo  #修改atomic yum源优先级,priority=14
##############################################################
[atomic]
name = CentOS / Red Hat Enterprise Linux $releasever - atomicrocketturtle.com
mirrorlist = http://www.atomicorp.com/mirrorlist/atomic/centos-6-$basearch
#mirrorlist = http://www.atomicorp.com/channels/atomic/centos/6/mirrors-atomic
enabled = 1
priority = 1
protect = 0
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY.art.txt
gpgcheck = 1
priority=14
##############################################################
七、更新yum软件包
       yum check-update
八、安装iftop
       yum install iftop
至此,CentOS 第三方yum源配置完成,现在你可以用yum命令安装自己需要的软件了!比如yum install nginx、yum update php等安装或者升级软件包。
备注:以下两个第三方yum源可以使用
rpm -Uvh http://mirrors.ustc.edu.cn/fedora/epel/6/i386/epel-release-6-8.noarch.rpm 
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
yum --enablerepo=remi install php
######################################################################################
   
   扩展阅读:

  
在使用yum update php命令升级php的同时,mysql也被升级到了最新版,升级好之后重启mysql,有可能会出现下面
   的错误信息,导致mysql启动失败。
   ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
   解决方法(切记,操作前,一定备份mysql数据库):
   rm -fr /var/lib/mysql/*      #删除目录
   rm /var/lock/subsys/mysqld   #删除目录
   killall mysqld   #结束mysql进程
   service mysqld start  #启动mysql
   /etc/rc.d/init.d/mysqld status   #查看mysql状态
   mysql_secure_installation  #重置Mysql数据库密码
#####################################################################################

     

  系统运维技术交流QQ群:①185473046 系统运维技术交流□Ⅰ ②190706903 系统运维技术交流™Ⅱ ③203744115 系统运维技术交流™Ⅲ

目前有 2 条留言 其中:访客:2 条, 博主:0 条

  1. silasyin : 2012年03月10日12:48:18  1楼

    详细的教程对初学者来说太有用了 :razz:

  2. lzhou : 2012年07月25日13:19:39  2楼

    楼主,你这个http://www.atomicorp.com/installers/atomic源好像有问题把,我按照你这篇文章配完第三方源后,然后再装LNMP,最后PHP依赖的那个php-common版本过低,好些php扩展的工具都装不了,我照着装了几次,都是那个原因。

给我留言

您必须 [ 登录 ] 才能发表留言!



Copyright© 2011-2024 系统运维 All rights reserved
版权声明:本站所有文章均为作者原创内容,如需转载,请注明出处及原文链接
陕ICP备11001040号-3