linux配置yum

       YUM是Yellow dog Updater, Modified的缩写,是由Duke University所发起的计划,目的就是为了解决RPM的依赖关系的问题,方便使用者进行软件的安装、升级等等工作。在此在特别说明的是,YUM只是为了解决RPM的依赖关系的问题,而不是一种其它的软件安装模式。当然可以实现这样功能的除了YUM外,还有APT (Advanced Package Tool,是由debian所发展的一个软件管理工具)。

       YUM的工作原理,在每一个 RPM软件的头(header)里面都会纪录该软件的依赖关系,那么如果可以将该头的内容纪录下来并且进行分析,可以知道每个软件在安装之前需要额外安装哪些基础软件。也就是说,在服务器上面先以分析工具将所有的RPM档案进行分析,然后将该分析纪录下来,只要在进行安装或升级时先查询该纪录的文件,就可以知道所有相关联的软件。

 

所以YUM的基本工作流程如下:

       服务器端:在服务器上面存放了所有的RPM软件包,然后以相关的功能去分析每个RPM文件的依赖性关系,将这些数据记录成文件存放在服务器的某特定目录内。

       客户端:如果需要安装某个软件时,先下载服务器上面记录的依赖性关系文件(可通过WWW或FTP方式),通过对服务器端下载的纪录数据进行分析,然后取得所有相关的软件,一次全部下载下来进行安装。

 

       在这篇文章里,我们配置通过FTP的YUM服务器。 在RHEL的安装盘上有所有的YUM包。 我们只需要把这些YUM 软件放到硬盘上,并配置好FTP。 在客户端修改相关的YUM 参数就可以了。

 

 

. 服务器端配置

1.1  安装FTP 服务,并配置自启动

[root@centos Server]# rpm -ivh vsftpd-2.0.5-16.el5.i386.rpm

warning: vsftpd-2.0.5-16.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186

Preparing...                ########################################### [100%]

   1:vsftpd                 ########################################### [100%]

[root@centos Server]# chkconfig vsftpd on

[root@centos Server]# chkconfig vsftpd --list

vsftpd          0:off   1:off   2:on    3:on    4:on    5:on    6:off

[root@centos Server]# service vsftpd restart

Shutting down vsftpd:                                      [FAILED]

Starting vsftpd for vsftpd:                                [  OK  ]

[root@centos Server]#

 

linux FTP 的配置,在下篇文章里会做说明, 这篇只演示如何使用。

 

 

1.2 复制RPM

       将RHEL 5光盘中的Server、VT、Cluster、ClusterStorage四个目录复制到/var/ftp/pub下。

 

[root@centos RHEL_5.4 i386 DVD]# du -k

253     ./Cluster/repodata

69571   ./Cluster

143     ./ClusterStorage/repodata

10300   ./ClusterStorage

10546   ./Server/repodata

2626369 ./Server

182     ./VT/repodata

47724   ./VT

8512    ./images/pxeboot

8914    ./images/xen

166766  ./images

8646    ./isolinux

2934671 .

[root@centos RHEL_5.4 i386 DVD]# cp -rf Cluster /var/ftp/pub/

[root@centos RHEL_5.4 i386 DVD]# cp -rf ClusterStorage /var/ftp/pub/

[root@centos RHEL_5.4 i386 DVD]# cp -rf VT /var/ftp/pub/           

[root@centos RHEL_5.4 i386 DVD]# cp -rf Server/ /var/ftp/pub/

 

 

[root@centos pub]# pwd

/var/ftp/pub

[root@centos pub]# ls

Cluster  ClusterStorage  Server  VT

[root@centos pub]# du -k

276     ./Cluster/repodata

69816   ./Cluster

10584   ./Server/repodata

2638388 ./Server

160     ./ClusterStorage/repodata

10468   ./ClusterStorage

200     ./VT/repodata

47924   ./VT

2766600 .

[root@centos pub]#

 

1.3. 安装createrepo包,并重建包依赖关系

       createrepo包是用来生成RPM 依赖关系及分组信息的。 搭建YUM服务器,必须要重建着2个信息。

 

1.3.1 检查包安装情况

[root@centos Server]# rpm -q yum

yum-3.2.22-20.el5.centos

[root@centos Server]# rpm -q createrepo

package createrepo is not installed

[root@centos Server]# rpm -ivh createrepo-0.4.11-3.el5.noarch.rpm

warning: createrepo-0.4.11-3.el5.noarch.rpm: Header V3 DSA signature: NOKEY, key ID 37017186

Preparing...                ########################################### [100%]

   1:createrepo             ########################################### [100%]

[root@centos Server]# rpm -q createrepo

createrepo-0.4.11-3.el5

[root@centos Server]#

 

1.3.2 重建分组及依赖关系

 

       在RHEL 5中每个目录下的repodata目录下都有一个repomd.xml,该文件中就记录了rpm包的依赖关系,还有一个comps-rhel5-*.xml文件,这个文件主要记录分组情况,建立yum仓库时,需要先重建该文件。

 

[root@centos repodata]# pwd

/var/ftp/pub/Server/repodata

[root@centos repodata]# ls

comps-rhel5-server-core.xml  filelists.xml.gz  other.xml.gz  primary.xml.gz  repomd.xml  TRANS.TBL

 

重建Server

[root@centos pub]# createrepo -g /var/ftp/pub/Server/repodata/comps-rhel5-server-core.xml /var/ftp/pub/Server/

2292/2292 - xorg-x11-xinit-1.0.2-15.el5.i386.rpm    --这里有2千多个包                          

Saving Primary metadata

Saving file lists metadata

Saving other metadata

[root@centos pub]#

 

重建VT

[root@centos pub]# createrepo -g /var/ftp/pub/VT/repodata/comps-rhel5-vt.xml /var/ftp/pub/VT/

36/36 - Virtualization-or-IN-5.2-11.noarch.rpm                                  

Saving Primary metadata

Saving file lists metadata

Saving other metadata

 

重建Cluster:

[root@centos pub]# createrepo -g /var/ftp/pub/Cluster/repodata/comps-rhel5-cluster.xml /var/ftp/pub/Cluster/

32/32 - Cluster_Administration-zh-TW-5.2-1.noarch.rpm                          

Saving Primary metadata

Saving file lists metadata

Saving other metadata

 

重建ClusterStorage

[root@centos pub]# createrepo -g /var/ftp/pub/ClusterStorage/repodata/comps-rhel5-cluster-st.xml /var/ftp/pub/ClusterStorage/

39/39 - Global_File_System-or-IN-5.2-1.noarch.rpm                              

Saving Primary metadata

Saving file lists metadata

Saving other metadata

[root@centos pub]#

 

1.4 修改YUM 配置文件

       在每个客户端使用YUM时,必须需要修改配置文件。

       我们先看文件: /etc/yum.repos.d/*.repo。 这个文件名称可以随便定义,但是扩展名必须是repo.

      

[root@centos pub]# cat /etc/yum.repos.d/CentOS-Base.repo

[base]

name=CentOS-$releasever - Base

mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os

#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

...

 

这个是我CentOS上的部分内容。 其他的类似。 这个文件其实是在使用yum安装的客户端使用的。 我们在服务器创建这个配置文件的原因是方便使用。 假如在公司里的Linux客户端非常多,我们不必去修改每个客户端的这个YUN配置文件。 只需要从服务器上将这个文件下载到本机就可以了。

 

YUM服务器上创建文件:

[root@centos pub]# cat /etc/yum.repos.d/rhel54.86.repo   

[rhel-base]

name= TianleSoftware Redhat Enterprise 5.4

baseurl=ftp://192.168.6.2/pub/Server

gpgcheck=0

enabled=1

 

[rhel-vt]

name= TianleSoftware Redhat Enterprise 5.4

baseurl=ftp://192.168.6.2/pub/VT

gpgcheck=0

enabled=1

 

[rhel-cluster]

name= TianleSoftware Redhat Enterprise 5.4

baseurl=ftp://192.168.6.2/pub/Cluster

gpgcheck=0

enabled=1

 

[rhel-ClusterStorage]

name= TianleSoftware Redhat Enterprise 5.4

baseurl=ftp://192.168.6.2/pub/ClusterStorage

gpgcheck=0

enabled=1

 

       说明:这里提供的只是一个FTP地址,所以可以使用其他的方式来实现FTP。 不一定非要像第一步里说明的,使用LINUX的FTP。

 

相关参数说明:

       [ ]内的是仓库的名字,不重复即可。

       name仓库的描述.

       baseurl: YUM源地址, 这里配置的是FTP,还可以是HTTP,FILE等。

       enabled 是否启用这个仓库,1为起用,0为禁用
       gpgcheck :是否检查GPG签名(验证要安装的包是不是REDHAT官方的)。

 

. 客户端配置

 

 

[root@singledb yum.repos.d]# cd /etc/yum.repos.d/                    

[root@singledb yum.repos.d]# wget ftp://192.168.6.2/pub/rhel54.86.repo

--2011-01-03 11:39:53--  ftp://192.168.6.2/pub/rhel54.86.repo

           => `rhel54.86.repo.1'

Connecting to 192.168.6.2:21... connected.

Logging in as anonymous ... Logged in!

==> SYST ... done.    ==> PWD ... done.

==> TYPE I ... done.  ==> CWD /pub ... done.

==> SIZE rhel54.86.repo ... 471

==> PASV ... done.    ==> RETR rhel54.86.repo ... done.

Length: 471

 

100%[==========================================================>] 471         --.-K/s   in 0s     

 

2011-01-03 11:39:53 (23.6 MB/s) - `rhel54.86.repo.1' saved [471]

 

[root@singledb yum.repos.d]# yum update

Loaded plugins: rhnplugin, security

This system is not registered with RHN.

RHN support will be disabled.

rhel-ClusterStorage                                                          | 1.1 kB     00:00    

rhel-ClusterStorage/primary                                                  | 8.3 kB     00:00    

rhel-ClusterStorage                                                                           39/39

rhel-base                                                                    | 1.1 kB     00:00    

rhel-base/primary                                                            | 806 kB     00:00    

rhel-base                                                                                 2292/2292

rhel-cluster                                                                 | 1.1 kB     00:00    

rhel-cluster/primary                                                         | 5.9 kB     00:00    

rhel-cluster                                                                                  32/32

rhel-vt                                                                      | 1.1 kB     00:00    

rhel-vt/primary                                                              | 9.0 kB     00:00    

rhel-vt                                                                                       36/36

Skipping security plugin, no data

Setting up Update Process

No Packages marked for Update

 

yum 安装 ant

[root@singledb yum.repos.d]# yum -y install ant

Loaded plugins: rhnplugin, security

This system is not registered with RHN.

RHN support will be disabled.

Setting up Install Process

Resolving Dependencies

--> Running transaction check

---> Package ant.i386 0:1.6.5-2jpp.2 set to be updated

--> Processing Dependency: xml-commons-apis for package: ant

--> Running transaction check

---> Package xml-commons-apis.i386 0:1.3.02-0.b2.7jpp.10 set to be updated

--> Processing Dependency: xml-commons = 1.3.02-0.b2.7jpp.10 for package: xml-commons-apis

--> Running transaction check

---> Package xml-commons.i386 0:1.3.02-0.b2.7jpp.10 set to be updated

--> Finished Dependency Resolution

 

Dependencies Resolved

 

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

 Package                    Arch           Version                        Repository           Size

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

Installing:

 ant                        i386           1.6.5-2jpp.2                   rhel-base           2.0 M

Installing for dependencies:

 xml-commons                i386           1.3.02-0.b2.7jpp.10            rhel-base            19 k

 xml-commons-apis           i386           1.3.02-0.b2.7jpp.10            rhel-base           335 k

 

Transaction Summary

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

Install      3 Package(s)        

Update       0 Package(s)        

Remove       0 Package(s)        

 

Total download size: 2.4 M

Downloading Packages:

(1/3): xml-commons-1.3.02-0.b2.7jpp.10.i386.rpm                              |  19 kB     00:00    

(2/3): xml-commons-apis-1.3.02-0.b2.7jpp.10.i386.rpm                         | 335 kB     00:00    

(3/3): ant-1.6.5-2jpp.2.i386.rpm                                             | 2.0 MB     00:00    

----------------------------------------------------------------------------------------------------

Total                                                               3.3 MB/s | 2.4 MB     00:00    

Running rpm_check_debug

Running Transaction Test

Finished Transaction Test

Transaction Test Succeeded

Running Transaction

  Installing     : xml-commons                                                                  1/3

  Installing     : xml-commons-apis                                                             2/3

  Installing     : ant                                                                          3/3

 

Installed:

  ant.i386 0:1.6.5-2jpp.2                                                                          

 

Dependency Installed:

  xml-commons.i386 0:1.3.02-0.b2.7jpp.10         xml-commons-apis.i386 0:1.3.02-0.b2.7jpp.10       

 

Complete!

[root@singledb yum.repos.d]#


  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值