歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> 配置RHEL6.2的YUM源

配置RHEL6.2的YUM源

日期:2017/2/28 15:42:54   编辑:Linux教程
服務器端:
1、 由於yum安裝支持三種協議:file://、ftp://和http://,因此如果是使用本地文件作為源,則可直接使用file:\\協議,否則需要先准備好ftp或者http服務。這次測試的是ftp源,因此需要配置好ftp服務,並且要把ftp服務配置為可匿名登錄,並且要把rpm包都放在ftp匿名登錄的root目錄下面。Vsftp匿名登錄的配置為:
anonymous_enable=YES
anon_root=/share(這個為vsftp匿名登錄的root目錄,並且其屬性不能為/etc/vsftp/ftpusers,/etc/vsftp/user_list文件中所配置的用戶,否則不能匿名登錄)
如果不配置匿名登錄或者匿名登錄root目錄設置不對會出現如下錯誤:
[root@srcbdc yum.repos.d]# yum list
Loaded plugins: aliases, rhnplugin, security
This system is not registered with RHN.
RHN support will be disabled.
ftp://yumserver/RHEL/Server/repodata/repomd.xml: [Errno 4] IOError: [Errno ftp error] 550 Failed to change directory.
Trying other mirror.
Error: Cannot retrieve repository metadata (repomd.xml) for repository: RHEL-Server. Please verify its path and try again
2、 先檢查yum是否已安裝,如果沒有安裝可以從光盤裡面安裝
[root@srcbdc ~]# rpm -qa|grep yum
yum-security-1.1.16-13.el5
yum-rhn-plugin-0.5.4-13.el5
yum-metadata-parser-1.1.2-3.el5
yum-updatesd-0.9-2.el5
yum-aliases-1.1.16-13.el5
yum-3.2.22-20.el5
3、 安裝另一個用於yum的包createrepo
[root@srcbdc 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%]
這個工具主要是用來生產yum所需要用到的安裝包關系的數據庫。
4、 把系統盤中的Server目錄和VT目錄拷貝到新的目錄裡面,我的是從ISO文件裡面復制出來的
先掛載ISO文件
[root@srcbdc ~]# mount -o loop /instsvr/ISO/rhel-server-6.2-x86_64-dvd.iso /mnt
Copy文件
[root@srcbdc ~]# mkdir -p /instsvr/RHEL6.2/x64
[root@srcbdc ~]# cp -r /mnt/ /instsvr/RHEL6.2/x64
5、 創建rpm關系數據庫
[root@srcbdc ~]# createrepo -g /instsvr/RHEL6.2/x64/Server/repodata/*comps-rhel6-Server.xml -o /instsvr/RHEL6.2/x64/Server -i /instsvr/RHEL6.2/x64/Server/listing /instsvr/RHEL6.2/x64/Packages/
[root@srcbdc ~]# createrepo -g /instsvr/RHEL6.2/x64/HighAvailability/repodata/*comps-rhel6-HighAvailability.xml -o /instsvr/RHEL6.2/x64/HighAvailability -i /instsvr/RHEL6.2/x64/HighAvailability/listing /instsvr/RHEL6.2/x64/Packages/
[root@srcbdc ~]# createrepo -g /instsvr/RHEL6.2/x64/LoadBalancer/repodata/*comps-rhel6-LoadBalancer.xml -o /instsvr/RHEL6.2/x64/LoadBalancer -i /instsvr/RHEL6.2/x64/LoadBalancer/listing /instsvr/RHEL6.2/x64/Packages/
[root@srcbdc ~]# createrepo -g /instsvr/RHEL6.2/x64/ResilientStorage/repodata/*comps-rhel6-ResilientStorage.xml -o /instsvr/RHEL6.2/x64/ResilientStorage -i /instsvr/RHEL6.2/x64/ResilientStorage/listing /instsvr/RHEL6.2/x64/Packages/
[root@srcbdc ~]# createrepo -g /instsvr/RHEL6.2/x64/ScalableFileSystem/repodata/*comps-rhel6-ScalableFileSystem.xml -o /instsvr/RHEL6.2/x64/ScalableFileSystem -i /instsvr/RHEL6.2/x64/ScalableFileSystem/listing /instsvr/RHEL6.2/x64/Packages/

創建rpm包的link文件:

[root@srcbdc ~]# cd /instsvr/RHEL6.2/x64/Server
[root@srcbdc ScalableFileSystem]# for i in `cat listing`; do ln -s ../Packages/$i $i; done
[root@srcbdc ~]# cd /instsvr/RHEL6.2/x64/HighAvailability
[root@srcbdc ScalableFileSystem]# for i in `cat listing`; do ln -s ../Packages/$i $i; done
[root@srcbdc ~]# cd /instsvr/RHEL6.2/x64/LoadBalancer
[root@srcbdc ScalableFileSystem]# for i in `cat listing`; do ln -s ../Packages/$i $i; done
[root@srcbdc ~]# cd /instsvr/RHEL6.2/x64/ResilientStorage
[root@srcbdc ScalableFileSystem]# for i in `cat listing`; do ln -s ../Packages/$i $i; done
[root@srcbdc ~]# cd /instsvr/RHEL6.2/x64/ScalableFileSystem
[root@srcbdc ScalableFileSystem]# for i in `cat listing`; do ln -s ../Packages/$i $i; done


6、 清除yum緩存信息
[root@srcbdc yum.repos.d]# yum clean all
Loaded plugins: aliases, rhnplugin, security
Cleaning up Everything
7、 再使用yum list名稱查看rpm包,正常的話會列出所有的rpm包

客戶端:

客戶端就比較好配置了,只需要在/etc/yum.d.repo/目錄小添加本地yum源配置文件即可

[root@instsvr1 yum.repos.d]# cat rhel6.2-x64.repo
[RHEL6.2-Server-X64]
name=Red Hat Enterprise Linux Install Server
baseurl=ftp://192.168.220.46/RHEL6.2/x64/Server
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-RedHat-release
[RHEL6.2-HighAvailability-X64]
name=Red Hat Enterprise Linux Install Server
baseurl=ftp://192.168.220.46/RHEL6.2/x64/HighAvailability/
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
[RHEL6.2-LoadBalancer-X64]
name=Red Hat Enterprise Linux Install Server
baseurl=ftp://192.168.220.46/RHEL6.2/x64/LoadBalancer/
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
[RHEL6.2-ResilientStorage-X64]
name=Red Hat Enterprise Linux Install Server
baseurl=ftp://192.168.220.46/RHEL6.2/x64/ResilientStorage/
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
[RHEL6.2-ScalableFileSystem-X64]
name=Red Hat Enterprise Linux Install Server
baseurl=ftp://192.168.220.46/RHEL6.2/x64/ScalableFileSystem/
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
[RHEL-RPMS]
name=Red Hat Enterprise Linux Install Server
baseurl=ftp://192.168.220.46/rpms
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release


【網摘】
repodata 數據庫介紹
repodata 數據庫中的文件主要是 XML 格式,精確描述一個 rpm 包的詳細信息,如依賴關系,包含文件,校驗碼信息。目前,這個格式被 apt-rpm,smartpm,red carpet 和 yum 支持。

通常有以下幾個文件:
repomd.xml (md 意思是 metadata)
repomd.xml 是描述其他 metadata 文件的文件。相當於其他文件的索引。包含其他文件的時間戳和校驗值(checksums)。這樣客戶端只要下載這一個文件(通常很小,幾KB),就可以知道其他文件中哪些有“更新”。這也意味只,只要對這一個文件簽名,就可以達到對其他文件簽名的作用。
primary.xml.[gz]
這個文件存儲主要的 metadata 信息,這些信息包括:

  • repomd.xml this is the file that describes the other metadata files. It is like an index file to point to the other files. It contains timestamps and checksums for the other files. This lets a client download this one, small file and know if anything else has changed. This also means that cryptographically (ex: gpg) signing this one file can ensure repository integrity.
  • primary.xml.[gz] this file stores the primary metadata information. This includes information such as:
    • name, epoch, version, release, architecture
    • file size, file location, description, summary, format, checksums header byte-ranges, etc.
    • dependencies, provides, conflicts, obsoletes, suggests, recommends
    • file lists for the package for CERTAIN files - specifically files matching: /etc*, *bin/*, /usr/lib/sendmail [1]
  • filelists.xml.[gz] this file stores the complete file and directory listings for the packages. The package is identified by: name, epoch, version, release, architecture and package checksum id.
  • other.xml.[gz] this file currently only stores the changelog data from packages. However, this file could be used for any other additional metadata that could be useful for clients.
  • groups.xml.[gz] this file is tentatively described. The intention is for a common package-groups specification as well. There is still some sections for this format that need to be fleshed out.
Copyright © Linux教程網 All Rights Reserved