由于单位的服务器均使用的是内网,而安装一些软件如Git,需要很多的依赖包,使用yum安装相对简单,由于不能联网故配置本地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
-rw-r--r--. root root Feb CentOS-Base.repo
-rw-r--r--. root root Feb CentOS-Debuginfo.repo
-rw-r--r--. root root Feb CentOS-Media.repo
-rw-r--r--. root root Feb 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-. 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.-.el6 @anaconda-CentOS-.x86_64/6.4
ConsoleKit-libs.x86_64 0.4.-.el6 @anaconda-CentOS-.x86_64/6.4
MAKEDEV.x86_64 3.24-.el6 @anaconda-CentOS-.x86_64/6.4
MySQL-python.x86_64 1.2.-0.3.c1..el6 @anaconda-CentOS-.x86_64/6.4
PyGreSQL.x86_64 3.8.-.el6 @anaconda-CentOS-.x86_64/6.4
SDL.x86_64 1.2.-.el6 @anaconda-CentOS-.x86_64/6.4
TurboGears2.noarch 2.0.-.el6 @anaconda-CentOS-.x86_64/6.4
abrt.x86_64 2.0.-.el6.centos @anaconda-CentOS-.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

可能由于没有使用光驱的缘故,以上设置后安装一直报nothing to do,所以选了另外一种方法重新安装:

1.将yum源放到/opt目录下,并复制系统安装包下的packages文件夹中所有的repo文件

[root@sl opt]# mkdir yumserver
[root@sl opt]# cp -rv /media/centos/Packages/* /opt/yumserver/

2.安装createrepo命令

[root@sl opt]# cd localserver/
[root@sl localserver]# rpm -ivh createrepo-0.9.-.el6.noarch.rpm
warning: createrepo-0.9.-.el6.noarch.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
error: Failed dependencies:
python-deltarpm is needed by createrepo-0.9.-.el6.noarch

以上提示安装失败,需要安装依赖包:python-deltarpm

[root@sl localserver]# rpm -ivh createrepo-0.9.-.el6.noarch.rpm python-deltarpm-3.5-0.5.20090913git.el6.x86_64.rpm deltarpm-3.5-0.5.20090913git.el6.x86_64.rpm
warning: createrepo-0.9.-.el6.noarch.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing... ########################################### [%]
:deltarpm ########################################### [ %]
:python-deltarpm ########################################### [ %]
:createrepo ########################################### [%]

createrepo安装成功

3.利用createrepo创建yum仓库,创建索引信息(需要等待一段时间)

[root@sl localserver]# createrepo -v ./

4.配置文件,将/etc/yum.repos.d/下现存文件都删除或重命名.bak,然后新建一个local.repo文件,并添加相应内容:

[root@sl yum.repos.d]# touch local.repo
[root@sl yum.repos.d]# vi local.repo  #repo后缀
#
# This repo can be used with mounted DVD media, verify the mount point for
# CentOS-. 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] [local]               #库名称
name=CentOS-local   #名称描述
baseurl=file:///opt/localserver/ #yum源目录,源地址
gpgcheck=           #检查GPG-KEY,0为不检查,1为检查
enabled=            #是否用该yum源,0为禁用,1为使用
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6  #gpgcheck=0时无需配置

5.安装成功后,测试:

[root@sl yum.repos.d]# yum clean all          #清除缓存
Loaded plugins: fastestmirror, security
Cleaning repos:
Cleaning up Everything
Cleaning up list of fastest mirrors [root@sl yum.repos.d]# yum makecache #重新建立缓存
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
local | 2.9 kB : ...
local/filelists_db | 3.9 MB : ...
local/other_db | 1.7 MB : ...
Metadata Cache Created

Centos6.4 本地yum源配置的更多相关文章

  1. CentOS6.5本地yum源配置

    1. 建立本地源目录及挂载临时目录 2. 挂载光盘 3. 进入/etc/yum.repos.d/目录,将 CentOS-Base.repo CentOS-Debuginfo.repo CentOS-V ...

  2. centos6.7 本地yum源配置

    [BEGIN] 2016/11/9 21:47:31[root@11g ~]# mount /dev/cdrom /mediamount: block device /dev/sr0 is write ...

  3. RedHat和CentOS使用本地yum源配置

    2013-04-01 11:38:30 标签:本地yum源 版权声明:原创作品,谢绝转载!否则将追究法律责任. 使用yum命令安装所需的软件,如果设备网络状况很好,当然也没必要去配置本地yum源,直接 ...

  4. CentOS7利用本地yum源配置NBD

    一:CentOS7.0创建本地YUM源 (物理机:直接将刻录的CentOS7光盘利用光驱插入物理机上) (虚拟机: CD/DVD>>连接本地ISO) 针对物理机192.168.9.112进 ...

  5. CENTOS 6-7的本地YUM源配置

    本文档适合CENTOS 6-7的本地YUM源配置 cd /media cd CentOS_6.8_Final/ cd Packages 创建目录拷贝文件 mkdir /yum cp * /yum 配置 ...

  6. CentOS本地yum源配置

    现有一台处在局域网的linux服务器,无法ping通外网,本文是关于本地yum源的配置 环境 : CentOS 6.5 一 .挂载CentOS镜像文件 (1) 创建挂载文件夹,若此文件夹已存在可忽略 ...

  7. 企业级本地yum源配置方案详解

    因目前企业生产网络禁止联网,对于使用Linux的我们来说,非常不方便,想要使用yum源都很困难,挂dvd又不能完全满足要求,所以自建一个企业级的yum源,定时从公网同步到本地,然后生产网络直接配置在本 ...

  8. CentOS 6.x 本地yum源配置与使用

    系统默认已经安装了可使用yum的软件包,所以可以直接配置: # mount  /dev/cdrom  /mnt                                挂载镜像,可以写到配置文件 ...

  9. Linux本地yum源配置以及使用yum源安装gcc编译环境

    本文档是图文安装本地yum源的教程,以安装gcc编译环境为例. 适用范围:所有的cetos,红帽,fedroa版本 适用人群:有一点linux基础的小白 范例系统版本:CentOS Linux rel ...

随机推荐

  1. javascript关于继承

    上一篇已介绍了组合继承,现在讲讲剩余的几种继承. 原型式继承 调用一个函数,接收这个函数返回来的对象,这个对象的原型就是传入函数的参数对象. 如: function personObject(o){ ...

  2. CSS3媒体查询使用小结

    首先我们在使用Media的时候需要先设置下面这段代码,来兼容移动设备的展示效果: 准备工作1:设置Meta标签 <meta name="viewport" content=& ...

  3. JS如何禁止别人查看网站源码

    四种查看路径: 查看效果:猛戳 1.直接按F12 2.Ctrl+Shift+I查看 3.鼠标点击右键查看 4.Ctrl+u=view-source:+url 把以上三种状态都屏蔽掉就可以了,docum ...

  4. Java基础知识点复习知识点(一)变量,流程控制,数组

  5. Sap SE16n 修改表数据

    SAP中直接修改表.视图的Tcode有SE16N和SM30. 其中使用SE16N修改表需要先输入命令&SAP_EDIT, 回车左下角显示激活SAP编辑功能后,就可以对相应的表进行新增.删除.修 ...

  6. SharePoint 2013 状态机工作流之扩展自定义状态

    当我们使用SharePoint 2013的状态机工作流时,发现一个非常不爽的事情,就是SharePoint 所有的工作流状态,都是固定的那些,没办法显示我们自定义的状态,后来经过Google发现,原来 ...

  7. 基础理解1:JSONP

    首先要确认三点: 1.不要被名字误导,返回的格式是随意的string,int等 2.JSONP用的是Script标签跨域的特性 3.回调函数名字和请求参数问题,不要被众多文章中的callback误导, ...

  8. Linux0.11内核--进程调度分析之2.调度

    [版权所有,转载请注明出处.出处:http://www.cnblogs.com/joey-hua/p/5596830.html ] 上一篇说到进程调度归根结底是调用timer_interrupt函数, ...

  9. LruCache缓存

    LruCache通常用于实现内存缓存,采用的缓存算法是LRU(Least Recently Used)即近期最少使用算法,其核心思想是:当缓存满的时候,会优先淘汰那些近期最少使用的缓存对象. 1.Lr ...

  10. SSIS 通过添加脚本组件 自定义转换数据

    问题:从mysql导入到sql的汉字都是乱码或者干脆导入不成功,报”截断字符串“错误,错在mysql当时建立的都是使用的默认编码latin1;搞不明白,又不是瑞典人,你用这个干毛.导致现在遇到n多问题 ...