24. 文件系統——製做本地的yum源

以前使用的yum倉庫,是直接將baseurl設置爲官方鏡像,或者是安裝光盤。本節內容將介紹如何將互聯網上下載到本地的rpm包製做成本地的yum源。定製yum源的命令是 createrepohtml

 

[root@localhost ~]# createrepojava

-bash: createrepo: command not found
# 該命令還沒有安裝,能夠使用yum安裝

 

[root@localhost ~]# yum -y install createrepopython

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!

 

1、 製做本地的yumgit

如今到官方站點上下載幾個rpm包到本地(能夠使用ftp工具FileZilla將本機上下載的文件傳輸到虛擬機中):sql

[root@localhost ~]# 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包

 

[root@localhost ~]# mkdir /yumvim

[root@localhost ~]# mkdir /yum/package centos

[root@localhost ~]# mv *.rpm /yum/package/ api

[root@localhost ~]# 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

 

[root@localhost ~]# 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

 

[root@localhost ~]# 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

 

[root@localhost ~]# cd /yum//package/repodata/

[root@localhost 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會依賴這個文件


[root@localhost repodata]# rpm -q --changelog bash

* Tue Jul 09 2013 Roman Rakus <rrakus@redhat.com> - 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 <rrakus@redhat.com> - 4.1.2-14
- Tweak a logout patch so it will not create backup file
  Resolves: #677439


[root@localhost repodata]# ls /var/cache/yum

timedhosts.txt  x86_64


2、使用本地的yum

 

[root@localhost repodata]# vim /etc/yum.repos.d/localrepo.repo

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


 

[root@localhost ~]# 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
 
[root@localhost ~]# 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]:
相關文章
相關標籤/搜索