24. 文件系统——制作本地的yum源

之前使用的yum仓库,是直接将baseurl设置为官方镜像,或者是安装光盘。本节内容将介绍如何将互联网上下载到本地的rpm包制作成本地的yum源。定制yum源的命令是 createrepo:

[[email protected] ~]# createrepo

-bash: createrepo: command not found
# 该命令尚未安装,可以使用yum安装

[[email protected] ~]# yum -y install createrepo

Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package createrepo.noarch 0:0.9.9-18.el6 will be installed
--> Processing Dependency: python-deltarpm for package: createrepo-0.9.9-18.el6.noarch
--> Running transaction check
---> Package python-deltarpm.x86_64 0:3.5-0.5.20090913git.el6 will be installed
--> Processing Dependency: deltarpm = 3.5-0.5.20090913git.el6 for package: python-deltarpm-3.5-0.5.20090913git.el6.x86_64
--> Running transaction check
---> Package deltarpm.x86_64 0:3.5-0.5.20090913git.el6 will be installed
--> Finished Dependency Resolution
 
Dependencies Resolved
 
=================================================================================
 Package                 Arch           Version                            Repository             Size
==============================================================================
Installing:
 createrepo              noarch         0.9.9-18.el6                       cdrom-centos6          94 k
Installing for dependencies:
 deltarpm                x86_64         3.5-0.5.20090913git.el6            cdrom-centos6          71 k
 python-deltarpm         x86_64         3.5-0.5.20090913git.el6            cdrom-centos6          27 k
 
Transaction Summary
=================================================================================
Install       3 Package(s)
 
Total download size: 192 k
Installed size: 518 k
Downloading Packages:
---------------------------------------------------------------------------------
Total                                                                  1.9 MB/s | 192 kB     00:00     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : deltarpm-3.5-0.5.20090913git.el6.x86_64                                             1/3 
  Installing : python-deltarpm-3.5-0.5.20090913git.el6.x86_64                                      2/3 
  Installing : createrepo-0.9.9-18.el6.noarch                                                      3/3 
  Verifying  : createrepo-0.9.9-18.el6.noarch                                                      1/3 
  Verifying  : python-deltarpm-3.5-0.5.20090913git.el6.x86_64                                      2/3 
  Verifying  : deltarpm-3.5-0.5.20090913git.el6.x86_64                                             3/3 
 
Installed:
  createrepo.noarch 0:0.9.9-18.el6                                                                     
 
Dependency Installed:
  deltarpm.x86_64 0:3.5-0.5.20090913git.el6      python-deltarpm.x86_64 0:3.5-0.5.20090913git.el6     
 
Complete!

一、 制作本地的yum源

现在到官方站点上下载几个rpm包到本地(可以使用ftp工具FileZilla将本机上下载的文件传输到虚拟机中):

[[email protected] ~]# ls

anaconda-ks.cfg                          if_exist.sh         Templates
axis-1.2.1-7.5.el6_5.noarch.rpm          install.log         Videos
axis-javadoc-1.2.1-7.5.el6_5.noarch.rpm  install.log.syslog  
xen-4.4.1-5.el6.x86_64.rpm  axis-manual-1.2.1-7.5.el6_5.noarch.rpm   
mkscript     zsh-4.3.10-7.el6.x86_64.rpm Desktop        Music    
zsh-html-4.3.10-7.el6.x86_64.rpm 
Documents         Pictures  Downloads                Public
# 下载了很多rpm包

[[email protected] ~]# mkdir /yum

[[email protected]ocalhost ~]# mkdir /yum/package

[[email protected] ~]# mv *.rpm /yum/package/

[[email protected] ~]# ls /yum/package/

axis-1.2.1-7.5.el6_5.noarch.rpm          xen-4.4.1-5.el6.x86_64.rpm
axis-javadoc-1.2.1-7.5.el6_5.noarch.rpm  zsh-4.3.10-7.el6.x86_64.rpm
axis-manual-1.2.1-7.5.el6_5.noarch.rpm   zsh-html-4.3.10-7.el6.x86_64.rpm

[[email protected] ~]# createrepo /yum/package/

# 使用createrepo命令加上rpm包的路径即可
Spawning worker 0 with 6 pkgs
Workers Finished
Gathering worker results
 
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete

[[email protected] ~]# ls /yum/package/

axis-1.2.1-7.5.el6_5.noarch.rpm        zsh-html-4.3.10-7.el6.x86_64.rpm
axis-javadoc-1.2.1-7.5.el6_5.noarch.rpm  xen-4.4.1-5.el6.x86_64.rpm
axis-manual-1.2.1-7.5.el6_5.noarch.rpm   zsh-4.3.10-7.el6.x86_64.rpm
repodata
#会发现多了一个目录repodata

[[email protected] ~]# cd /yum//package/repodata/

[[email protected] repodata]# ls

# repodata中有很多新生成的文件
4aa67d3d6de3fb964dd96bc15e3849a95c0c26add8bdf871b584c42fafc6564d-other.sqlite.bz2
# 这是个小型的嵌入式数据库引擎
9501c262742c6024ec0bf8e0e0a876c1ab8c51c3c9f9e8b54205c03121c2274f-primary.xml.gz
af1104a240755c3d4cf5d8ead181afed54f3395d71f6eec76210bae9aeac6b5f-primary.sqlite.bz2
# 主配置文件,包含当前仓库内的所有rpm包,以及各rpm包之间的依赖关系
d8d9144e02ffe32302d157984b9fb84246e30e78a3ab440c32b74e73489de44e-filelists.sqlite.bz2
f501ede79b66c9f96117d7070cffae3c8aa621723f13f53999cd2a91b621cf1e-filelists.xml.gz
# 当前目录中所有rpm包的文件列表
 
repomd.xml
# 核心文件,用来保留下面六个文件的时间戳信息,当升级rpm包时,yum会将本地rpm包的缓存时间戳和该文件中的时间戳进行比较,如果一致,说明远程服务器的rpm包没有更新 (本地的缓存时间戳保存在/var/cache/yum)
 
832dc759e3507b97d6b92ce2d82aee1242d2b15839b0788ab7ec342fe059079f-other.xml.gz
# 其他信息,如rpm包的改变日志等(每次rpm包升级的变化),rpm -q --changelog会依赖这个文件

[[email protected] repodata]# rpm -q --changelog bash

* Tue Jul 09 2013 Roman Rakus <[email protected]> - 4.1.2-15
- Fixed a bug that caused trap handlers to be executed recursively,
  corrupting internal data structures.
  Resolves: #982610
 
* Wed Aug 29 2012 Roman Rakus <[email protected]> - 4.1.2-14
- Tweak a logout patch so it will not create backup file
  Resolves: #677439

[[email protected] repodata]# ls /var/cache/yum

timedhosts.txt  x86_64

二、使用本地的yum源

[[email protected] repodata]# vim /etc/yum.repos.d/localrepo.repo

 
[local-package]
name=Local x86_64
baseurl=file:///yum/package
gpgcheck=0
enabled=1

[[email protected] ~]# yum repolist

Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
local-package                                             | 2.9 kB     00:00 ... 
local-package/primary_db                                  | 7.0 kB     00:00 ... 
base                                                      | 4.0 kB     00:00 ... 
repo id                    repo name                                 status
cdrom-centos6              CentOS 6.4 x86_64                         6,367
local-package              Local x86_64                              6
# 可以看到本地yum源已经创建成功了
base                       CentOS 6.4 x86_64                         6,367
repolist: 12,740
 
[[email protected] ~]# yum install axis
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package axis.noarch 0:1.2.1-7.5.el6_5 will be installed
--> Processing Dependency: wsdl4j for package: axis-1.2.1-7.5.el6_5.noarch
--> Processing Dependency: log4j for package: axis-1.2.1-7.5.el6_5.noarch
--> Processing Dependency: jaxp_parser_impl for package: axis-1.2.1-7.5.el6_5.noarch
local-package/filelists_db                                                      |  21 kB     00:00 ... 
--> Processing Dependency: javamail for package: axis-1.2.1-7.5.el6_5.noarch
--> Processing Dependency: jakarta-commons-logging for package: axis-1.2.1-7.5.el6_5.noarch
--> Processing Dependency: jakarta-commons-httpclient for package: axis-1.2.1-7.5.el6_5.noarch
--> Processing Dependency: jakarta-commons-discovery for package: axis-1.2.1-7.5.el6_5.noarch
--> Processing Dependency: jaf for package: axis-1.2.1-7.5.el6_5.noarch
--> Running transaction check
---> Package classpathx-jaf.x86_64 0:1.0-15.4.el6 will be installed
---> Package classpathx-mail.noarch 0:1.1.1-9.4.el6 will be installed
---> Package jakarta-commons-discovery.noarch 1:0.4-5.4.el6 will be installed
---> Package jakarta-commons-httpclient.x86_64 1:3.1-0.7.el6_3 will be installed
---> Package jakarta-commons-logging.noarch 0:1.0.4-10.el6 will be installed
---> Package java-1.5.0-gcj.x86_64 0:1.5.0.0-29.1.el6 will be installed
--> Processing Dependency: sinjdoc for package: java-1.5.0-gcj-1.5.0.0-29.1.el6.x86_64
---> Package log4j.x86_64 0:1.2.14-6.4.el6 will be installed
--> Processing Dependency: xml-commons-apis for package: log4j-1.2.14-6.4.el6.x86_64
---> Package wsdl4j.noarch 0:1.5.2-7.8.el6 will be installed
--> Running transaction check
---> Package sinjdoc.x86_64 0:0.5-9.1.el6 will be installed
--> Processing Dependency: java_cup >= 0.10 for package: sinjdoc-0.5-9.1.el6.x86_64
---> Package xml-commons-apis.x86_64 0:1.3.04-3.6.el6 will be installed
--> Running transaction check
---> Package java_cup.x86_64 1:0.10k-5.el6 will be installed
--> Finished Dependency Resolution
 
Dependencies Resolved
 
=================================================================================
 Package            Arch      Version             Repository            Size
=================================================================================
Installing:
 axis                              noarch        1.2.1-7.5.el6_5            local-package        1.5 M
# 可以看到该rpm包来源于本地的repository,而相关的依赖关系来源于光盘yum源
 
Installing for dependencies:
 classpathx-jaf                    x86_64        1.0-15.4.el6               cdrom-centos6        100 k
 classpathx-mail                   noarch        1.1.1-9.4.el6              cdrom-centos6        479 k
 jakarta-commons-discovery         noarch        1:0.4-5.4.el6              cdrom-centos6         73 k
 jakarta-commons-httpclient        x86_64        1:3.1-0.7.el6_3            cdrom-centos6        587 k
 jakarta-commons-logging           noarch        1.0.4-10.el6               cdrom-centos6         52 k
 java-1.5.0-gcj                    x86_64        1.5.0.0-29.1.el6           cdrom-centos6        139 k
 java_cup                          x86_64        1:0.10k-5.el6              cdrom-centos6        197 k
 log4j                             x86_64        1.2.14-6.4.el6             cdrom-centos6        679 k
 sinjdoc                           x86_64        0.5-9.1.el6                cdrom-centos6        705 k
 wsdl4j                            noarch        1.5.2-7.8.el6              cdrom-centos6        157 k
 xml-commons-apis                  x86_64        1.3.04-3.6.el6             cdrom-centos6        439 k
 
Transaction Summary
================================================================================
Install      12 Package(s)
 
Total download size: 5.0 M
Installed size: 11 M
Is this ok [y/N]:
时间: 2024-10-13 21:24:25

24. 文件系统——制作本地的yum源的相关文章

linux:网络yum源和制作本地光盘yum源

linux:存放yum源的位置:/etc/yum.repos.d/,该目录下全是一些yum源 一.网络yum源: 如图:下面全部都是yum源,后缀是".repo"都是合法的yum源,默认的是启动的CentOS-Base.repo这个yum源(网络yum源) [[email protected] yum.repos.d]# ls -l total 28 -rw-r--r--. 1 root root 1664 Dec 9 2015 CentOS-Base.repo --- 网络yum源

centos制作本地光盘yum源

centos将本地光盘做为yum源,方便解决依赖包问题: 1./etc/yum.repos.d目录下有两个文件:CentOS-Base.repo(联网yum安装).CentOS-Media.repo(本地yum源) vi   CentOS-Media.repo [c5-media] name=CentOS-$releasever - Media baseurl=file:///media/ 此处为挂载目录(挂载点) gpgcheck=1 #enabled=0 这个我注释掉了,不知道没有注释可以用

redhat制作本地光盘yum源

养成好习惯,先备份一下 /etc/yum.repos.d/下面的repo文件 1.挂载光盘mount /dev/cdrom /media/ 2.新建本地yun源的配置文件vi /etc/yum.repos.d/local.repo加入以下信息:[Local]name=Localbaseurl=file:///media/enable=1gpgcheck=0 3.完成,进行使用先清缓存   yum  clean  all再更新缓存 yum  makecache安装软件 yum  install 

RHEL 7.0 本地配置yum源

RHEL 7.0 本地配置yum源  yum简介  yum = Yellow dog Updater, Modified 主要功能是更方便的添加/删除/更新RPM包. 它能自动解决包的倚赖性问题. 它能便于管理大量系统的更新问题 当前linux版本 rhel7.0 前提mount DVD光盘到/mnt   因为配置时候路径名里面不能有空格,否则不能识别 首先设置IP地址.网关DNS 说明:RHEL 7.0默认安装好之后是没有自动开启网络连接的! cd  /etc/sysconfig/networ

本地光盘yum源的搭建

有时候由于网络等其他原因的限制,不能随时使用yum到网上去获取rpm包,这样我们可以配置本地光盘yum源. 下面简要介绍一下本地光盘yum源的搭建 1.挂载本地iso镜像文件mount /dev/sr0 /media/cdrom 2.修改yum源配置文件vim /etc/yum.repos.d/rhel-source.repo 修改内容如下[rhel-source]name=Red Hat Enterprise Linuxbaseurl=file:///media/cdrom      前两个/

本地搭建yum源方法【二】

1. 搭建本地光盘YUM源 [[email protected] ~]# mkdir /mnt/cdrom/  ------>创建光盘挂载目录 [[email protected] ~]# mount /dev/cdrom /mnt/cdrom/  -------->挂在光盘 [[email protected] ~]# cd /etc/yum.repos.d/    -------->切换到YUM配置目录 [[email protected] yum.repos.d]# tar czf

centos6配置本地光盘yum源、rhel7修改网卡名称为eth0

VMware安装好centos/rhel后要配置的几点(配置本地光盘yum源.修改网卡名称为eth0等) [[email protected] ~]# setenforce 0 [[email protected] ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config [[email protected] ~]# tar zcvf /root/redhat.repo.tgz /etc/yum.repos.d/

挂载系统光盘作为本地的yum源

问题:不小心删除了lvm这个包,,郁闷,系统启动失败,怎么办? 思路:没有本地yum源服务器的话,通过挂载DVD作为本地的yum源来安装lvm,然后重启即可. 系统启动时,进入修复模式,重新挂载/分区: # mount -o remount,rw / 挂载dvd到/media目录下 # mount /dev/scd0 /media mount: block device /dev/sr0 is write-protected, mounting read-only 建立一个repo文件: # c

CentOS 6.* 配置本地网络 yum源

CentOS 6.* 配置本地网络yum源 一台服务时只需要配一个本地的yum源即可:当需要配置多台服务器时,只需要配置1到2台vsftpd的yum源,其它服务器通过ftp连接yum源: 1 基于本地文件的yum源 1.1 下载镜像源 wget -b https://mirrors.aliyun.com/centos/6.10/isos/x86_64/CentOS-6.10-x86_64-bin-DVD1.iso tail -100f wget-log 1.2 挂载iso镜像文件 ll /mnt