yum(针对rhel6.2)

  1. 云栖社区>
  2. 博客>
  3. 正文

yum(针对rhel6.2)

长烟慢慢 2013-10-11 19:48:49 浏览727
展开阅读全文
yum是Linux平台(Redhat系列平台)一个软件包管理工具,非常有效地解决包括了安装rpm包时的软件依赖关系。当我们使用rpm(Redhat package Management)在linux下安装rpm软件包时,经常会提示由于安装包的依赖关系而而导致安装失败。使用yum安装工具,将完美地解决rpm包的依赖问题。

  YUM包括两个部分:

YUM软件包仓库——存放着RPM软件包,及记录这些RPM软件包的依赖关系的文件(一个XML文件);

YUM安装程序——yum。YUM软件包仓库可以是一个ftp server,一个web server,也可以是本地的某个目录,或者光盘。


  yum安装支持三种协议:file://、ftp://和http://,因此如果是使用本地文件作为源,则可直接使用、file:\\协议,否则需要先准备好ftp或者http服务。


1、测试配置局域网内ftp源的yum


1、配置ftp服务

这次测试的是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


本篇文章来源于 Linux公社网站(www.linuxidc.com)  原文链接:http://www.linuxidc.com/Linux/2012-08/68482.htm


【网摘】:
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.


2、配置本地文件的yum源


一.挂载本地光盘到系统:rhel6.2安装光盘放入光驱,在终端命令行下操作
mkdir /media/rhel               #新建挂载目录
mount /dev/cdrom /media/rhel   #
挂载光盘到/media/rhel目录下
cd /media/rhel                  #
进入挂载目录
ls                             #
查看挂载目录,光盘挂载成功


. 配置本地yum
cd /etc/yum.repos.d/ #进入yum配置目录
touch rhel-media.repo #
建立yum配置文件
vi rhel-media.repo #
编辑配置文件,添加以下内容

 [rhel-media]
 name=Red Hat Enterprise Linux 6.2 #自定义名称
 baseurl=file:///media/rhel #本地光盘挂载路径
 enabled=1 #启用yum源,0为不启用,1为启用
 gpgcheck=1 #检查GPG-KEY,0为不检查,1为检查
 gpgkey=file:///media/rhel/RPM-GPG-KEY-redhat-release #GPG-KEY路径 


三.清除yum缓存,使用yum install自动安装软件

yum clean all #清除yum缓存

至此,RHEL 6.2配置已经完成,现在可以使用yum install命令安装软件了。


3、配置连接到网络远程yum源






网友评论

登录后评论
0/500
评论