在RHEL6中部署YUM服务器,RHEL5作为客户机使用YUM工具时出现错误:

ftp://192.168.1.23/rhel5/repodata/primary.xml.gz: [Errno -3] Error performing checksum
Trying other mirror.
Error: failure: repodata/primary.xml.gz from test: [Errno 256] No more mirrors to try.

原因是RHEL6中的repomd.xml文件使用sha256作为hash算法,在rhel5中默认使用sha作为hash算法,所以在部署YUM时应指定hash算法为sha或md5

把RHEL5的镜像的内容拷贝到/var/ftp/rhel5目录中,cp  -rfp /mnt/*  /var/ftp/rhel5

挂载rhel6的镜像  mount /dev/cdrom  /mnt/

[root@localhost rhel5]# createrepo -s sha -g /mnt/repodata/repomd.xml ./
 

[root@rh ~]# cat /etc/yum.repos.d/local.repo
[rhel5]
name=rhel5
baseurl=ftp://192.168.7.1/rhel5
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
[root@rh ~]# 
 或者

[root@rh ~]# vi /etc/yum.repos.d/local.repo
[rhel5]
name=rhel5
baseurl=ftp://192.168.7.1/rhel5
enabled=1
gpgcheck=0

 

在客户机上如果按下面写在执行YUM命令时会出现:

[root@rh ~]# cat /etc/yum.repos.d/local.repo
[rhel5]
name=rhel5
baseurl=ftp://192.168.7.1/rhel5
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
[rhel6]
name=rhel6
baseurl=ftp://192.168.7.1/rhel6
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
[root@rh ~]#
[root@rh ~]# yum list vsftpd
Loading "rhnplugin" plugin
Loading "installonlyn" plugin
This system is not registered with RHN.
RHN support will be disabled.
Setting up repositories
Reading repository metadata in from local files
e677a30bfc993f5f0b66c0899 100% |=========================| 1.3 MB    00:00    
ftp://192.168.7.1/rhel6/repodata/e677a30bfc993f5f0b66c0899817fcaa268512e9c47a64d6d0e9f9d4b9bd7496-primary.xml.gz: [Errno -3] Error performing checksum
Trying other mirror.
Error: failure: repodata/e677a30bfc993f5f0b66c0899817fcaa268512e9c47a64d6d0e9f9d4b9bd7496-primary.xml.gz from rhel6: [Errno 256] No more mirrors to try.
因此在客户机上只指定与客户机相匹配的YUM软件仓库就可以了。