redhat5.4下yum服务器源配置

   上篇文章介绍了怎么使用磁盘或iso镜像来制作yum软件源,这篇则介绍,如何做一个yum服务器源,让更多的人可以通过网络来进行软件更新
1.     yum(yellow dog updater,modified)是基于rpm包管理,能够从指定的服务器自动下载rpm包并且安装,可以自动处理信赖性关系,并且一次安装所有信赖的软件包.
2.    本实验使用ftp为源服务器,首先在ip地址为192.168.1.106的一台redhat5.4主机上来安装vsftp,作为yum的ftp服务器,挂载光盘,进入server,安装vsftp
      [ root@localhost Server]# mount -o loop /dev/cdrom /mnt/cdrom
      [root@localhost Server]# rpm -ivh vsftpd-2.0.5-16.el5.i386.rpm
3. 拷贝光盘里面的全部文件(在拷贝文件夹的时候,文件夹里面的文件一定要全部拷贝完,否则实验中会出现错误)到/var/ftp/pub/下面
     [root@localhost Server]# cp -R * /var/ftp/pub/
4.现在以另一台redhat5.4的机器为客户端来进行实验服务器配置是否成功
  进入文件夹/etc/yum.repos.d/,复制文件rhel-debuginfo.repo 为 cdrom.repo
  cdrom.repo即为配置文件
    [root@localhost yum.repos.d]# cd /etc/yum.repos.d/
    [root@localhost yum.repos.d]# cp -p rhel-debuginfo.repo cdrom.repo
5.配置文件cdrom.repo
  [root@localhost yum.repos.d]# vi cdrom.repo
  打开之后把里面的内容修改为
   [ rhel-cdrom]
   name=Red Hat Enterprise Linux
   baseurl=ftp://192.168.1.106/pub/Server/
   enabled=1
   gpgcheck=1
   gpgkey=ftp://192.168.1.106/pub/RPM-GPG-KEY-redhat-release
各参数的定义
     [ ]仓库,这个名字不能和其他的文件名相同,否则会出现错误。
    Name:对仓库的描述文字
    baseurl:你使用的要作为yum 源的文件路径如baseurl=ftp://192.168.1.106/pub/Server/
这里使用的是ftp源,所以路径是ftp的路径,也可以使用其他类型的源,如本地源:file,www源:http
    enabled :指明是否使用这个源,所以要把0改为1,如果为0则不能使用这个源
    gpgcheck : 这个是说明是否使用gpg签名
    gpgkey: gpg签名的路径
6.客户端配置结束,测试客户端
   [root@localhost ~]# yum update
  在测试时会发现错误的提示,提示内容为
    Loaded plugins: rhnplugin, security
    This system is not registered with RHN.
   RHN support will be disabled.
   ftp://192.168.1.106/pub/Server/repodata/repomd.xml: [Errno 4] IOError: [Errno ftp error] (113, '\xe6\xb2\xa1\xe6\x9c\x89\xe5\x88\xb0\xe4\xb8\xbb\xe6\x9c\xba\xe7\x9a\x84\xe8\xb7\xaf\xe7\x94\xb1')
   Trying other mirror.
   Error: Cannot retrieve repository metadata (repomd.xml) for repository: rhel-cdrom. Please verify its path and try again
  之所以会出现这个错误是因为,yum服务器源还开启防火墙或者selinux的缘故,这时我们需要到服务器中关闭linux防火墙
  关闭方法:[root@localhost ~]# setup
   选择防火墙选项,禁用掉防火墙即可
   现在即可在客户端上再次测试
   rhel-cdrom                                               | 1.3 kB     00:00    
   rhel-cdrom/primary                                      | 732 kB     00:00    
   rhel-cdrom                                              2292/2292
   Skipping security plugin, no data
  现在测试成功.
   也可以使用yum list all来查看全部的软件
7. yum 服务器源上的增加软件
    1>把软件flasn-plugin复制到/var/ftp/pub/Server中,现在在客户端中重新更新一下软件源,在更新前首先应该先清空软件列表
    [root@localhost ~]# yum clean all
    Loaded plugins: rhnplugin, security
   Cleaning up Everything
  重新更新
     [root@localhost ~]# yum update
   查询能否找到软件flash-plugin
     [root@localhost ~]# yum list all |grep flash*
     This system is not registered with RHN.
     RHN support will be disabled.
     tvflash.i386                         0.9.0-2.el5                 cdrom
  可以看到没有我们要得到的软件
   2>  由上面的操作可以知道,新添加的软件,并没有被实际的应用,这是因为yum通用数据库没有改变,数据库中记录的软件没有我们新增加的软件,所以我们应该生成新的    yum通用数据库,使用的工具是createrepo
   3> createrepo的安装
     [root@localhost Server]# ll create*
     -r—r—r— 451 root root 60901 2008-04-21 createrepo-0.4.11-3.el5.noarch.rpm
     [root@localhost 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%]

  4> 开始生成yum 通用数据库
   因为软件比较多,所以会费一些时间
     [root@localhost Server]#createrepo -g /var/ftp/pub/Server/repodata  /comps-rhel5-server-core.xml  /var/ftp/pub/Server/
     1754/2293 - jakarta-commons-collections-testframework-javadoc-3.2-2jpp.3.i386.rp2293/2293 - iso-codes-0.53-1.noarch.rpm                                        
     Saving Primary metadata
    Saving file lists metadata
    Saving other metadata
   5> 现在再客户端上重新更新yum源
       [root@localhost ~]# yum clean all
       [root@localhost~]# yum update
   6> 查询flash
      [root@localhost ~]# yum list all | grep flash*
      This system is not registered with RHN.
      RHN support will be disabled.
     flash-plugin.i386           1.2.202.238-release        rhel-cdrom
     tvflash.i386                   0.9.0-2.el5                 rhel-cdrom
   7>由上可知,软件增加成功.