关闭

[置顶] Centos6.6 本地 yum 配置

标签: yumrpmcentos
1994人阅读 评论(0) 收藏 举报
分类:

Centos6.6 本地yum源配置

1.首先将需要rpm库添加到系统中:
1).虚拟机中安装的linux操作系统:则只需将安装包ISO文件挂载到media下面(如无法挂载请参考http://www.cnblogs.com/shenliang123/p/3203278.html)
2).单独的服务器系统,则先在/media下新建centos(名字可以自定义,但与下面4中添加的目录相关),然后将ISO包里面的内容全部复制到该文件夹中

2. 进入到 /etc/yum.repos.d/  ,该目录下包含了四个文件:
[root@sl media]# ls -l /etc/yum.repos.d/
total 16
-rw-r--r--. 1 root root 1926 Feb 25  2013 CentOS-Base.repo
-rw-r--r--. 1 root root  638 Feb 25  2013 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root  630 Feb 25  2013 CentOS-Media.repo
-rw-r--r--. 1 root root 3664 Feb 25  2013 CentOS-Vault.repo

3. 将 CentOS-Base.repo和CentOS-Debuginfo.repo两个文件改名,绕过网络安装:
[root@sl yum.repos.d]# mv CentOS-Base.repo CentOS-Base.repose_bak
[root@sl yum.repos.d]# mv CentOS-Debuginfo.repo CentOS-Debuginfo.repo_bak

4. 编辑文件CentOS-Media.repo:(也可以自己新增一个repo文件,more用于查看,使用vi进行编辑)
[root@sl yum.repos.d]# more CentOS-Media.repo  #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/     #yum源目录,源地址
gpgcheck=1                #检查GPG-KEY,0为不检查,1为检查
enabled=1               #是否用该yum源,0为禁用,1为使用
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6  #gpgcheck=0时无需配置

5. 测试yum是否配置成功:
[root@sl yum.repos.d]# yum list
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
Installed Packages
ConsoleKit.x86_64                        0.4.1-3.el6                          @anaconda-CentOS-201303020151.x86_64/6.4
ConsoleKit-libs.x86_64                   0.4.1-3.el6                          @anaconda-CentOS-201303020151.x86_64/6.4
MAKEDEV.x86_64                           3.24-6.el6                           @anaconda-CentOS-201303020151.x86_64/6.4
MySQL-python.x86_64                      1.2.3-0.3.c1.1.el6                   @anaconda-CentOS-201303020151.x86_64/6.4
PyGreSQL.x86_64                          3.8.1-2.el6                          @anaconda-CentOS-201303020151.x86_64/6.4
SDL.x86_64                               1.2.14-3.el6                         @anaconda-CentOS-201303020151.x86_64/6.4
TurboGears2.noarch                       2.0.3-4.el6                          @anaconda-CentOS-201303020151.x86_64/6.4
abrt.x86_64                              2.0.8-15.el6.centos                  @anaconda-CentOS-201303020151.x86_
more.........

6. 清除yum缓存:
[root@sl yum.repos.d]# yum clean all
Loaded plugins: fastestmirror, security
Cleaning repos:
Cleaning up Everything
Cleaning up list of fastest mirrors

7. 重新建立缓存
[root@sl yum.repos.d]# yum makecache      
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
local                                                                                           | 2.9 kB     00:00 ...
local/filelists_db                                                                              | 3.9 MB     00:00 ...
local/other_db                                                                                  | 1.7 MB     00:00 ...
Metadata Cache Created


附:yum指令详解

1. 更新所有的RPM包
yum update

2. 更新指定的RPM包,如更新kernel包
yum update kernel

3. 安装RPM包,如lrzsz包
yum install lrzsz
yum install gcc*
注:可以在RPM包中使用匹配符,如安装所有以gcc开头的RPM包

4. 删除RPM包,包括与该包有依赖性的包
yum remove licq
同时会提示删除 licq-gnome,licq-qt,licq-text

5. 列出资源库中所有可以安装或更新的包
yum list
yum list gcc*


附:挂载CentOS_6.6 光驱

mkdir /media/"CentOS_6.6_Final"
mount -t iso9660 /dev/sr0 /media/"CentOS_6.6_Final"



0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    最新评论