createrepo 是一个对rpm 文件进行索引建立的工具。
大体功能就是对指定目录下的rpm文件进行检索,把每个rpm文件的信息存储到指定的索引文件中,这样方便远程yum命令在安装更新时进行检索。
看下createrepo支持的几个参数:
-u --baseurl

                Optional base url location for all files. (not used by any clientsat this time) -o --outputdir <url> Optional output directory (useful for read only media). -x --exclude <package> File globs to exclude, can be specified multiple times. -i --pkglist <filename> specify a text file which contains the complete list of filesto  include  in  the  repository from  the  set  found  in  the directory. File format is onepackage per line, no wildcards or globs. -q --quiet Run quietly. -g --groupfile <groupfile> A precreated xml filename to point to for group information. See examples section below for further explanation. -v --verbose Run verbosely.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
-c --cachedir
Specify a directory to use as a cachedir. This allows createrepo tocreate a cache of check-
sums of packages in the repository. In consecutive runs ofcreaterepo over the same repository
of files that do not have a complete change out of all packagesthis decreases the processing
time dramatically.

    --update If  metadata  already  exists in the outputdir and an rpmis unchanged (based on file size and mtime) since the metadata was generated, reuse the existingmetadata rather than recalculating it.  In  the caseof a large repository with only a few new or modified rpms this cansignifi- cantly reduce I/O and processing time. -C --checkts Don’t generate repo metadata, if theirtimestamps  are  newer  than  its  rpms.    This  option decreases  the  processing  time  drastically  again, if you happen to run iton an unmodified repo, but it is (currently) mutual exclusive with the --splitoption. --split Run in split media mode. Rather than pass a single directory, takea set of directories corre- sponding to different volumes in a media set.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
-p --pretty
Output xml files in pretty format.

    -V --version Output version. -h --help Show help menu. -d --database Generate sqlite databases for use with yum.

1
2
3
4
5
6
7
8
createrepo生成四个文件:
repodata/filelists.xml.gz
repodata/other.xml.gz
repodata/primary.xml.gz
repodata/repomd.xml
关于这几个文件的描述是:
repomd.xml this is the file that describes theother metadata files. It is like an index file to point to theother files. It contains timestamps and checksums for the otherfiles. This lets a client download this one, small file and know ifanything else has changed. This also means that cryptographically(ex: gpg) signing this one file can ensure repositoryintegrity.
primary.xml.[gz] this file stores the primarymetadata information. This includes information such as:
name, epoch, version, release, architecture
file size, file location, description, summary, format,checksums header byte-ranges, etc.
dependencies, provides, conflicts, obsoletes, suggests,recommends
file lists for the package for CERTAIN files - specificallyfiles matching: /etc*, bin/, /usr/lib/sendmail [1]
filelists.xml.[gz] this file stores thecomplete file and directory listings for the packages. The packageis identified by: name, epoch, version, release, architecture andpackage checksum id.
other.xml.[gz] this file currently onlystores the changelog data from packages. However, this file couldbe used for any other additional metadata that could be useful forclients.
groups.xml.[gz] this file is tentativelydescribed. The intention is for a common package-groupsspecification as well. There is still some sections for this formatthat need to be fleshed out.
其实我们需要记住的就是primary.xml.gz存储的是包列表,而filelist.xml存储的是所有包的目录和文件列表。

也就是说如果createrepo成功创建索引后,包的信息和每个包的文件信息都会存储在这两个文件中。

当然,如果你在执行createrepo时添加了-d 参数的话,createrepo会对

filelist.xml.gz,primary.xml.gz和other.xml.gz各自生成一个sqlite的文件(或者压缩文件)。

其中用sqlite格式存储了对应xml文件中的信息。

然后当你在客户端执行 yum clean all ,yum list 之后,这些索引文件就会下载到客户端。

默认的cache目录是:/var/cache/yum,里面按照不同的repo再分目录了,比如 rhel,test等等。

createrepo默认会生成的文件有:

filelists.xml.gz other.xml.gz primary.xml.gz repomd.xml

经过索引下载后,在客户端的cache中会生成索引文件:

cachecookie primary.xml.gz primary.xml.gz.sqlite repomd.xml
如果采用了 -d 参数的话,createrepo会生成的文件有:

filelists.sqlite.bz2 filelists.xml.gz other.sqlite.bz2 other.xml.gz primary.sqlite.bz2 primary.xml.gz repomd.xml

客户端更新后,索引文件有:

cachecookie primary.sqlite repomd.xml
我们可以看到,如果采用sqlite的db来存储的话,yum会把filelist,primary和other文件的信息都存储到

Sqlite的db文件primary.sqlite中。

查看primary.sqlite文件:

sqlite3 /var/cache/yum/ops.5Server.x86_64/primary.sqlite

运行 ".table"命令,查看表列表:

sqlite> .table
conflicts db_info files obsoletes packages provides requires
可以看到包的所有信息都存储在这几个表当中了。

我们可以做个测试,查询下packages表中的信息:

select * from packages where name =‘tops-cmos’ and version =‘1.1.0’;

输出如下:

155|ece7d2540f36adec0b098c2202601f1d1c5021a6|tops-cmos|x86_64|1.1.0|20|101|Unifiedplatform of agent program for configuration managment by TAOBAOSA|Unified platform of agent program for configuration managment byTAOBAO SA||1337054204|1337054201|©2011 System AdministrationTools Licence|System Administration Department, TaobaoInc.|Tops|v132074.sqa.cm4.tbsite.net|tops-cmos-1.1.0-101.src.rpm|280|4315|SysAdminPackertaobao-sre-sys-sa@list.alibaba-inc.com|47174|119349|121752|tops-cmos-1.1.0-101.x86_64.rpm||sha

继续以packages表为例,能够看到这个表的字段有:

.schema packages

CREATE TABLE packages ( pkgKey INTEGERPRIMARY KEY, pkgIdTEXT, name TEXT, arch TEXT, versionTEXT, epoch TEXT, release TEXT, summaryTEXT, descriptionTEXT, url TEXT, time_file INTEGER, time_buildINTEGER, rpm_licenseTEXT, rpm_vendorTEXT, rpm_groupTEXT, rpm_buildhostTEXT, rpm_sourcerpmTEXT, rpm_header_startINTEGER, rpm_header_endINTEGER, rpm_packagerTEXT, size_packageINTEGER, size_installedINTEGER, size_archiveINTEGER, location_hrefTEXT, location_baseTEXT, checksum_type TEXT);

看到了这个表的所有字段,这些字段描述了一个rpm文件的主要信息。然后你就可以根据这些字段做条件查询了。

.schema files
CREATE TABLE files ( nameTEXT, type TEXT, pkgKey INTEGER);

也能够看到file与pkg的关联关系,有个外键是pkgKey.

.schema conflicts
CREATE TABLE conflicts ( nameTEXT, flags TEXT, epoch TEXT, versionTEXT, releaseTEXT, pkgKey INTEGER );

conflicts表的信息.

.schema obsoletes
CREATE TABLE obsoletes ( nameTEXT, flags TEXT, epoch TEXT, versionTEXT, releaseTEXT, pkgKey INTEGER );

包废除表的信息.

.schema provides
CREATE TABLE provides ( nameTEXT, flags TEXT, epoch TEXT, versionTEXT, releaseTEXT, pkgKey INTEGER );
CREATE INDEX pkgprovides on provides (pkgKey);
CREATE INDEX providesname ON provides (name);

provides表的信息。

.schema requires
CREATE TABLE requires ( nameTEXT, flags TEXT, epoch TEXT, versionTEXT, releaseTEXT, pkgKey INTEGER , pre BOOLEAN DEFAULTFALSE);
CREATE INDEX pkgrequires on requires (pkgKey);
CREATE INDEX requiresname ON requires (name);

requires表的信息。

其余这几个表都是以packages表为基础,来补充存储rpm包的信息,比如prides,require,obsolete等信息。

如果你做一个程序,能够生成同样的数据文件,基本上就实现了createrepo在带-d参数时的效果。

知道了这些信息,当你的yum服务出现问题时,比如包不能更新,版本不对等问题时,就能通过这些文件来查找问题的原因。

createrepo 是一个对rpm 文件进行索引建立的工具相关推荐

  1. lucene: 索引建立完后无法查看索引文件中的数据

    索引建立时 1.对原有索引文件进行建立,是可以访问索引文件中的数据的 2.建立新索引文件,必须等建立完毕后,才可以访问,新建立的文件如果没有建立完是不可以被访问的 如果想建立200w的数据的索引又想立 ...

  2. SQL索引建立原则和使用

    之前在网上看到过很多关于mysql联合索引最左前缀匹配的文章,自以为就了解了其原理,发现遗漏了些东西,这里自己整理一下这方面的内容. 1 前言 SQL索引有两种,聚集索引和非聚集索引   聚集索引存储 ...

  3. 操作系统原理,文件系统的概念与实现,概念,需求,文件分类,逻辑结构,数据结构,文件控制块和文件目录,基本文件操作,多级目录,文件物理结构,Unix的文件多级索引结构

    操作系统原理,文件系统的概念与实现,概念,需求,文件分类,逻辑结构,数据结构,文件控制块和文件目录,基本文件操作,多级目录,文件物理结构,Unix的文件多级索引结构 基本概念 一.文件概念: 1.文件 ...

  4. CentOS6.5通过jdk8.rpm文件安装JDK8

    1. 下载jdk8.rpm 1.1 到oracle官网下载页下载jdk8.rpm,如下图. 1.2 然后将该jdk8.rpm文件放入CentOS系统的任意目录中,我这边放在 /usr/local 目录 ...

  5. mongodb 索引建立问题

    mongodb  索引建立问题 1.主从库索引建立不是同步建立: MONGODB 2.6.6 版本,索引建立并不是同步的,而是主库建立完成后,从库接着建立索引.     不知是3.0版本是否也一样,以 ...

  6. SQL Server,Oracle,DB2索引建立语句的对比

    http://database.51cto.com/art/201108/284540.htm SQL Server,Oracle,DB2索引建立语句的对比 2011-08-17 20:48 henr ...

  7. mongodb 索引建立问题

    mongodb  索引建立问题 1.主从库索引建立不是同步建立: MONGODB 2.6.6 版本,索引建立并不是同步的,而是主库建立完成后,从库接着建立索引.     不知是3.0版本是否也一样,以 ...

  8. 定时创建oracle索引,oracle数据库关于索引建立及使用的详细介绍

    索引的说明 索引是与表相关的一个可选结构,在逻辑上和物理上都独立于表的数据,索引能优化查询,不能优化DML操作,Oracle自动维护索引,频繁的DML操作反而会引起大量的索引维护. 如果SQL语句仅访 ...

  9. linux打包启动这着的文件,linux – 打开一个RPM文件并重新打包它

    修改您没有源的RPM的最佳方式是按照以下步骤操作: >使用rpm2cpio命令将rpm解压缩到目录中 >在该子目录内进行必要的更改 制作一个"虚拟"规范文件并构建它. ...

最新文章

  1. 数据挖掘(Data Mining)| 数据分析建模理论基础
  2. Spark在不同集群中的运行架构
  3. C++ boost 实例学习
  4. 判断js变量是否定义,
  5. Web前端好不好学?Web前端要学些什么呢?
  6. Linux/U-Boot Git Repo
  7. SubSonic中RecordBaseT.Load(IDataReader dataReader)与LoadAndCloseReader(IDataReader dataReader)的使用区别...
  8. hashmap 从头到尾_如何从头到尾设计一个简单的复古徽标
  9. [剑指offer][JAVA]面试题第[10-1]题[斐波那契数列][动态规划][记忆化递归]
  10. 2021年一月文章导读
  11. python怎么安装requests模块_python安装requests第三方模块
  12. 升级tomcat遇到的坑
  13. CentOS安装Nvidia驱动和CUDA
  14. 错误码应该如何设计?
  15. Matlab求整数规划
  16. Win7如何简单的关闭445端口及445端口入侵详解
  17. 制作u盘winpe启动盘_Ventoy启动盘制作工具,Win、Linux、PE多系统镜像装进同1个U盘...
  18. android实战:密码箱一
  19. 解决“Error: Too many re-renders. React limits the number of renders to prevent an infinite loop.”
  20. a16z合伙人Chris Dixon:DeFi和NFT之后的下一波区块链应用浪潮

热门文章

  1. python getsize函数,Python getsize函数
  2. 怎样才能在网上卖东西,手把手教你闲鱼卖货!
  3. 虚拟主机mysql数据库大小,香港虚拟主机的网站数据库空间不够怎么办
  4. [再寄小读者之数学篇](2014-05-30 对数不等式)
  5. Cesium实时目标跟踪最新特效教程系列1—实时发亮直线跟踪移动目标
  6. android开发中遇到的技术难题,android开发过程中遇到的问题以及解决办法
  7. 优化vue打包chunk-vendors.js 过大
  8. tflearn的VocabularyProcessor用法:建立中文词汇表和把文本转为词ID序列
  9. elasticsearch集群管理插件之cerebro安装配置
  10. python学习 -女神或者男神把微信消息撤回后好慌,有了这个妈妈再也不担心你看不到女神或者男神撤回的消息了(超详解)...