本地YUM源配置
这里讲述使用YUM仓库来配置本地YUM源。
操作系统版本:RHEL 6.5
[root@localhost ~]# uname -a
Linux localhost 2.6.32-431.el6.x86_64 #1 SMP Sun Nov 10 22:19:54 EST 2013 x86_64 x86_64 x86_64 GNU/Linux
[root@localhost ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 6.5 (Santiago)
rhel的yum在线更新是收费的,没有注册的话,需要将原有的yum卸载后重新安装配置其它yum源才能正常使用
1. 重新安装YUM软件包
删除原有YUM安装包
[root@localhost ~]# rpm -qa | grep yum
PackageKit-yum-0.5.8-21.el6.x86_64
yum-rhn-plugin-0.9.1-48.el6.noarch
yum-metadata-parser-1.1.2-16.el6.x86_64
yum-utils-1.1.30-14.el6.noarch
yum-plugin-security-1.1.30-14.el6.noarch
yum-3.2.29-40.el6.noarch
PackageKit-yum-plugin-0.5.8-21.el6.x86_64
[root@localhost ~]# rpm -qa | grep yum | xargs rpm -e --nodeps
[root@localhost ~]# rpm -qa | grep yum
[root@localhost ~]#
下载YUM软件包重新安装
[root@localhost ~]# rpm -ivh *.rpm
warning: yum-3.2.29-69.el6.centos.noarch.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing... ########################################### [100%]
1:yum-metadata-parser ########################################### [ 20%]
2:yum-plugin-fastestmirro########################################### [ 40%]
3:yum ########################################### [ 60%]
4:yum-plugin-security ########################################### [ 80%]
5:yum-utils ########################################### [100%]
[root@localhost ~]#
2. 使用DVD光盘制作YUM仓库
查看光驱设备信息
[root@localhost ~]# cat /proc/sys/dev/cdrom/info
CD-ROM information, Id: cdrom.c 3.20 2003/12/17
drive name: sr0
drive speed: 32
drive # of slots: 1
Can close tray: 1
Can open tray: 1
Can lock tray: 1
Can change speed: 1
Can select disk: 0
Can read multisession: 1
Can read MCN: 1
Reports media changed: 1
Can play audio: 1
Can write CD-R: 0
Can write CD-RW: 0
Can read DVD: 1
Can write DVD-R: 0
Can write DVD-RAM: 0
Can read MRW: 0
Can write MRW: 0
Can write RAM: 0
创建YUM下载目录,并拷贝光盘中rpm文件到YUM目录
[root@localhost ~]# mkdir /yum
[root@localhost ~]# mount /dev/sr0 /mnt
mount: block device /dev/sr0 is write-protected, mounting read-only
[root@localhost ~]# cd /mnt
[root@localhost mnt]# ls
EFI Packages RELEASE-NOTES-pa-IN.html
EULA README RELEASE-NOTES-pt-BR.html
EULA_de RELEASE-NOTES-as-IN.html RELEASE-NOTES-ru-RU.html
EULA_en RELEASE-NOTES-bn-IN.html RELEASE-NOTES-si-LK.html
EULA_es RELEASE-NOTES-de-DE.html RELEASE-NOTES-ta-IN.html
EULA_fr RELEASE-NOTES-en-US.html RELEASE-NOTES-te-IN.html
EULA_it RELEASE-NOTES-es-ES.html RELEASE-NOTES-zh-CN.html
EULA_ja RELEASE-NOTES-fr-FR.html RELEASE-NOTES-zh-TW.html
EULA_ko RELEASE-NOTES-gu-IN.html repodata
EULA_pt RELEASE-NOTES-hi-IN.html ResilientStorage
EULA_zh RELEASE-NOTES-it-IT.html RPM-GPG-KEY-redhat-beta
GPL RELEASE-NOTES-ja-JP.html RPM-GPG-KEY-redhat-release
HighAvailability RELEASE-NOTES-kn-IN.html ScalableFileSystem
images RELEASE-NOTES-ko-KR.html Server
isolinux RELEASE-NOTES-ml-IN.html TRANS.TBL
LoadBalancer RELEASE-NOTES-mr-IN.html
media.repo RELEASE-NOTES-or-IN.html
[root@localhost mnt]# cp Packages/* /yum/
[root@localhost mnt]#
3.配置YUM下载源
该步主要使用createrepo工具来创建YUM下载源数据目录,创建之后会在YUM下载源目录中生成一个名为repodata的目录,该目录即YUM下载源的数据目录,该目录用来存储由createrepo产生的数据文件。
① 检查并安装createrepo工具
[root@localhost mnt]# rpm -qa | grep createrepo
[root@localhost mnt]# rpm -ivh Packages/createrepo-0.9.9-18.el6.noarch.rpm
warning: Packages/createrepo-0.9.9-18.el6.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
error: Failed dependencies:
python-deltarpm is needed by createrepo-0.9.9-18.el6.noarch
[root@localhost mnt]# rpm -ivh Packages/createrepo-0.9.9-18.el6.noarch.rpm Packages/python-deltarpm-3.5-0.5.20090913git.el6.x86_64.rpm
warning: Packages/createrepo-0.9.9-18.el6.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
error: Failed dependencies:
deltarpm = 3.5-0.5.20090913git.el6 is needed by python-deltarpm-3.5-0.5.20090913git.el6.x86_64
[root@localhost mnt]# rpm -ivh Packages/createrepo-0.9.9-18.el6.noarch.rpm Packages/python-deltarpm-3.5-0.5.20090913git.el6.x86_64.rpm Packages/deltarpm-3.5-0.5.20090913git.el6.x86_64.rpm
warning: Packages/createrepo-0.9.9-18.el6.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Preparing... ########################################### [100%]
1:deltarpm ########################################### [ 33%]
2:python-deltarpm ########################################### [ 67%]
3:createrepo ########################################### [100%]
[root@localhost mnt]#
②创建YUM下载源数据文件
[root@localhost mnt]# createrepo /yum
Spawning worker 0 with 3763 pkgs
Workers Finished
Gathering worker results
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
root@localhost mnt]#
4.配置YUM
要使用YUM下载源,首先要对YUM进行配置,YUM配置有俩种,一种是YUM工具的配置文件(/etc/yum.conf),一种是YUM下载源的定义文件(/etc/yum.repos.d/目录中,该文件以.repo作为扩展名),这里介绍第二种方式。
[root@localhost mnt]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ls
packagekit-media.repo rhel-source.repo
[root@localhost yum.repos.d]# cp rhel-source.repo local_yum.repo
[root@localhost yum.repos.d]# vi local_yum.repo
配置如下:
[root@localhost yum.repos.d]# cat local_yum.repo
[rhel-source]
name=rhel local yum
baseurl=file:///yum
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
[root@localhost yum.repos.d]#
配置文件内容解析:
name=rhel local yum#定义YUM下载源的名字,随便起
baseurl=file:///yum#定义YUM下载源的url地址
baseurl是配置中最关键的部分,配置 正确才能使用YUM下载源
baseurl指向YUM下载源目录,即RPM包所在的目录,如果是使用官方下载ISO文件来直接挂载YUM源,在5.x和6.x、7.x所指向的目录会有所不同,这里需要注意,5.x中rpm文件在Server目录下,6.x、7.x中rpm文件在Server/Packages目录下,如果目录不对则YUM下载源就会报错:No such file or directory
url支持的协议包括http、ftp、file3种,我们这里使用本地配置,即file
enabled=1#表示repo中定义的源是启动的,0为禁用
gpgcheck=1#表示安装YUM下载源中的RPM包之前要校验数字签名
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release#定义用于校验的gpg密钥
5.验证
yum clean all#清除yum缓存
yum makecache#缓存本地yum源中软件包信息
[root@localhost yum]# yum clean all
已加载插件:fastestmirror, product-id, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Repository rhel-source is listed more than once in the configuration
Cleaning repos: InstallMedia rhel-source
清理一切
[root@localhost yum]# yum makecache
已加载插件:fastestmirror, product-id, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Repository rhel-source is listed more than once in the configuration
Determining fastest mirrors
rhel-source | 2.9 kB 00:00 ...
rhel-source/filelists_db | 3.9 MB 00:00 ...
rhel-source/primary_db | 3.2 MB 00:00 ...
rhel-source/other_db | 1.7 MB 00:00 ...
元数据缓存已建立
yum list | grep httpd#列出apache安装软件包
yum install httpd#安装apache
[root@localhost yum]# yum -y install httpd
已加载插件:fastestmirror, product-id, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Repository rhel-source is listed more than once in the configuration
设置安装进程
Loading mirror speeds from cached hostfile
解决依赖关系
--> 执行事务检查
---> Package httpd.x86_64 0:2.2.15-29.el6_4 will be 安装
--> 完成依赖关系计算
依赖关系解决
================================================================================
软件包 架构 版本 仓库 大小
================================================================================
正在安装:
httpd x86_64 2.2.15-29.el6_4 rhel-source 821 k
事务概要
================================================================================
Install 1 Package(s)
总下载量:821 k
Installed size: 2.9 M
下载软件包:
warning: rpmts_HdrFromFdno: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
Importing GPG key 0xFD431D51:
Userid : Red Hat, Inc. (release key 2) <security@redhat.com>
Package: redhat-release-server-6Server-6.5.0.1.el6.x86_64 (@anaconda-RedHatEnterpriseLinux-201311111358.x86_64/6.5)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
Importing GPG key 0x2FA658E0:
Userid : Red Hat, Inc. (auxiliary key) <security@redhat.com>
Package: redhat-release-server-6Server-6.5.0.1.el6.x86_64 (@anaconda-RedHatEnterpriseLinux-201311111358.x86_64/6.5)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
运行 rpm_check_debug
执行事务测试
事务测试成功
执行事务
正在安装 : httpd-2.2.15-29.el6_4.x86_64 1/1
Verifying : httpd-2.2.15-29.el6_4.x86_64 1/1
已安装:
httpd.x86_64 0:2.2.15-29.el6_4
完毕!
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/26537027/viewspace-1825039/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/26537027/viewspace-1825039/