配置本地yum源的方法

Posted 遠離塵世の方舟

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了配置本地yum源的方法相关的知识,希望对你有一定的参考价值。

配置本地yum源的方法 

1.利用光驱挂载镜像配置 

1.1首先把光盘放在光驱中,若此时光驱已经挂载请用umount命令先把光驱umount掉 

1.2 建立相关目录,创建local.repo 文件  

[[email protected]]# mkdir /media/os_repo

[[email protected]]# mount /dev/cdrom /media/os_repo

[[email protected] os_repo]# pwd

/media/os_repo

[[email protected] os_repo]# ls

EFI      EULA_pt           README                    RELEASE-NOTES-it-IT.html  RELEASE-NOTES-ru-RU.html  RPM-GPG-KEY-redhat-release

EULA     EULA_zh           RELEASE-NOTES-as-IN.html  RELEASE-NOTES-ja-JP.html  RELEASE-NOTES-si-LK.html  ScalableFileSystem

EULA_de  GPL               RELEASE-NOTES-bn-IN.html  RELEASE-NOTES-kn-IN.html  RELEASE-NOTES-ta-IN.html  Server

EULA_en  HighAvailability  RELEASE-NOTES-de-DE.html  RELEASE-NOTES-ko-KR.html  RELEASE-NOTES-te-IN.html  TRANS.TBL

EULA_es  images            RELEASE-NOTES-en-US.html  RELEASE-NOTES-ml-IN.html  RELEASE-NOTES-zh-CN.html

EULA_fr  isolinux          RELEASE-NOTES-es-ES.html  RELEASE-NOTES-mr-IN.html  RELEASE-NOTES-zh-TW.html

EULA_it  LoadBalancer      RELEASE-NOTES-fr-FR.html  RELEASE-NOTES-or-IN.html  repodata

EULA_ja  media.repo        RELEASE-NOTES-gu-IN.html  RELEASE-NOTES-pa-IN.html  ResilientStorage

EULA_ko  Packages          RELEASE-NOTES-hi-IN.html  RELEASE-NOTES-pt-BR.html  RPM-GPG-KEY-redhat-beta

 

[[email protected] os_repo]# vi /etc/yum.repos.d/local.repo  --文件名字只能叫local.repo,把原来的配置文件改名或删除

[rhel6]

name=rhel6

baseurl=file:///media/os_repo/Server  --注意这里是Server目录,而不是Packages目录

enabled=1

gpgcheck=0

 

1.3 查看配置的yum源 

[[email protected] os_repo]# yum list

……

列出所有的软件包

[[email protected] os_repo]# yum install httpd  --使用yum命令安装apache

Loaded plugins: product-id, security, subscription-manager

This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

Setting up Install Process

Resolving Dependencies

--> Running transaction check

---> Package httpd.x86_64 0:2.2.15-29.el6_4 will be installed

--> Processing Dependency: httpd-tools = 2.2.15-29.el6_4 for package: httpd-2.2.15-29.el6_4.x86_64

--> Processing Dependency: apr-util-ldap for package: httpd-2.2.15-29.el6_4.x86_64

--> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.2.15-29.el6_4.x86_64

--> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.2.15-29.el6_4.x86_64

--> Running transaction check

---> Package apr.x86_64 0:1.3.9-5.el6_2 will be installed

---> Package apr-util.x86_64 0:1.3.9-3.el6_0.1 will be installed

……

这样 yum仓库就建好了 

============================

2.利用本地文件目录建立yum 仓库 

2.1把光盘放入光驱 

mount  /dev/hdc  /mnt 

[[email protected] ~]# mount /dev/hdc  /mnt/ 

mount: block device /dev/hdc is write-protected, mounting read-only 

 

注意:存放YUM源的目录必须有可写权限,不然在createrepo时会报错。 

2.2将光盘文件复制到YUM目录 

[[email protected] ~]# umount /dev/hdc 

[[email protected] ~]# mount /dev/hdc  /mnt/ 

mount: block device /dev/hdc is write-protected, mounting read-only 

 

[[email protected] ~]# cd /mnt/ 

[[email protected] mnt]# ls -ld Server/ 

dr-xr-xr-x 3 root root 217088 05-19 05:11 Server/ 

 

2.2 拷贝Server目录 

[[email protected] mnt]# cp -r Server/ /yum/ 

2.3创建本地源 

# createrepo  -g  /yum/Server/repodata/comps-rhel5-server-core.xml  /yum/Server 

[[email protected] ~]# vi /etc/yum.repos.d/local.repo  

[base] 

name=local 

baseurl=file:///yum/Server 

gpgcheck=0 

enabled=1 

第二种方法未做测试。

转自:http://blog.csdn.net/evils798/article/details/7581670

 

以上是关于配置本地yum源的方法的主要内容,如果未能解决你的问题,请参考以下文章

CentOS配置本地yum源/阿里云yum源/163yuan源,并配置yum源的优先级

配置本地光盘做yum源的问题,求教ing

yum源的三种安装配置方式,总有一款适合你

redhat 6 配置 yum 源的两种方法

本地yum源 阿里yum源163yum源的配置安装

Linux系列——yum源的安装和配置