初涉定制linux系统之——rpm相关安装包的准备

     在上一篇博客http://www.cnblogs.com/dengtr/p/5543820.html#3634582 中介绍了如何定制Centos系统镜像,但其中有个问题,就是服务所依赖的安装包不在原Centos系统镜像中,而是须要联网去epel等源那下载,对于一个不能联网的环境而言会很麻烦。html

全部,咱们须要能够在定制系统前,找出全部不在Centos镜像中的rpm包,封装到定制镜像中便可。本博客就给你们介绍若是获取咱们须要的rpm包python

 

一、首先,针对Centos6如下的版本,咱们须要安装一个插件yum-plugin-downloadonlyvim

 1 [root@192 ~]# yum install yum-plugin-downloadonly  ui

     安装完后,若是你机器上的python是2.7以上版本的话,就须要修改下yum配置,由于Centos6如下的系统版本须要使用python2.6,全部须要修改/usr/bin/yum文件,将头部的“#!/usr/bin/python” 修改成“#!/usr/bin/python2.6”。(注:须要你本机上有/usr/bin/python2.6这个版本)this

 1 [root@192 ~]# vim /usr/bin/yum
 2 #!/usr/bin/python2.6
 3 import sys
 4 try:
 5     import yum
 6 except ImportError:
 7     print >> sys.stderr, """\
 8 There was a problem importing one of the Python modules
 9 required to run yum. The error leading to this problem was:
10 
11    %s

 

二、这时候你就可使用--downloadonly命令来yum下载本身须要的rpm了,该命令的做用就是下载rpm包及全部的依赖关系包,可是都不会被安装。spa

 1 [root@192 ~]#  yum install --downloadonly epel*
 2 Loaded plugins: fastestmirror
 3 Setting up Install Process
 4 Loading mirror speeds from cached hostfile
 5  * base: mirrors.aliyun.com
 6  * extras: mirrors.aliyun.com
 7  * updates: mirrors.aliyun.com
 8 Resolving Dependencies
 9 --> Running transaction check
10 ---> Package epel-release.noarch 0:6-8 will be installed
11 --> Finished Dependency Resolution
12 
13 Dependencies Resolved
14 
15 =============================================================================================================================================================================================
16  Package                                           Arch                                        Version                                     Repository                                   Size
17 =============================================================================================================================================================================================
18 Installing:
19  epel-release                                      noarch                                      6-8                                         extras                                       14 k
20 
21 Transaction Summary
22 =============================================================================================================================================================================================
23 Install       1 Package(s)
24 
25 Total download size: 14 k
26 Installed size: 22 k
27 Is this ok [y/N]: y
28 Downloading Packages:
29 epel-release-6-8.noarch.rpm                                                                                                                                           |  14 kB     00:00     
30 exiting because --downloadonly specified

        能够看到yum只下载了epel包,可是并无进行安装,通常下载的rpm存放在/var/cache/yum/x86_64/6/[repository]/packages/目录下,标红的[repository]表示下载包的来源仓库的名称(例如:base、extras、epel)。如刚才下载的epel-release包就存放在系统下面的目录下插件

 1 /var/cache/yum/x86_64/6/extras/packages/epel-release-6-8.noarch.rpm code

 

三、以后你就能够视本身的需求将下载的rpm封装到定制镜像里,之后不再担忧部署环境没外网了,固然要是客户死活不用你的定制镜像,你能够参考下一篇移动镜像源的制做方法。恩,若是博主有时间写的话。。。。。htm

相关文章
相关标签/搜索