Redhat6.4下配置本地yum

时间:2023-11-28 20:45:32

一、准备工作
1. Linux安装盘插入光驱

2. 挂载光驱

[root@localhost ~]# mount /dev/cdrom /mnt/
 mount: block device /dev/sr0 is write-protected, mounting read-only

3. 安装createrepo软件包 ---> 这是一个解决依赖性的工具

[root@localhost ~]# cd /mnt/Packages/
[root@localhost Packages]# rpm -ivh deltarpm-3.5-0.5.20090913git.el6.x86_64.rpm
 warning: deltarpm-3.5-0.5.20090913git.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
 Preparing...                ########################################### [100%]
 1:deltarpm              ########################################### [100%]
 [root@localhost Packages]# rpm -ivh python-deltarpm-3.5-0.5.20090913git.el6.x86_64.rpm
 warning: python-deltarpm-3.5-0.5.20090913git.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
 Preparing...                ########################################### [100%]
 1:python-deltarpm        ########################################### [100%]
 [root@localhost Packages]# rpm -ivh createrepo-0.9.9-17.el6.noarch.rpm
 warning: createrepo-0.9.9-17.el6.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
 Preparing...                ########################################### [100%]
 1:createrepo            ########################################### [100%]
 [root@localhost Packages]#

4. 拷贝光驱中的rpm包到本系统中,并创建对应的目录

[root@localhost Packages]# mkdir -pv /var/ftp/pub
 mkdir: created directory `/var/ftp'
 mkdir: created directory `/var/ftp/pub'
 [root@localhost Packages]# cp -R /mnt/Packages /var/ftp/pub/

二、 开始搭建yum
1. 生成依赖关系

[root@localhost Packages]# createrepo -g /mnt/repodata/cda5429be6f36ce1348e8f897f4fc96aa00d5727c75e9e5a0b5dc40d22a51116-comps-rhel6-Server.xml /var/ftp/pub/Packages/
 Spawning worker 0 with 3720 pkgs
 Workers Finished
 Gathering worker results
 Saving Primary metadata
 Saving file lists metadata
 Saving other metadata
 Generating sqlite DBs
 Sqlite DBs complete

2. 编辑yum仓库配置文件

[root@localhost ~]# cd /etc/yum.repos.d/
 [root@localhost yum.repos.d]# ls
 rhel-source.repo
 [root@localhost yum.repos.d]# cp rhel-source.repo rhel-source.repo.bak
 [root@localhost yum.repos.d]# vim rhel-source.repo
 [myyum]
 name=RedHat Myyum
 baseurl=file:///var/ftp/pub/Packages/
 enabled=1
 gpgcheck=1
 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

3. 至此6.4版本的本地yum安装完毕,测试下是否能够正常使用

[root@localhost yum.repos.d]# yum grouplist
 Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
 This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
 Setting up Group Process
 myyum                                                    | 3.8 kB    00:00 ...
 myyum/primary_db                                 | 3.1 MB    00:00 ...
 myyum/group_gz                                    | 204 kB    00:00 ...
 Installed Groups:
 Additional Development
 Base
 Debugging Tools
 Desktop
 Desktop Debugging and Performance Tools
 Desktop Platform
 Dial-up Networking Support
 Directory Client
 Network file system client
 Assamese Support [as]
 Available Language Groups:
 Afrikaans Support [af]
 Albanian Support [sq]
 Amazigh Support [ber]
 Azerbaijani Support [az]
 Ukrainian Support [uk]
 Upper Sorbian Support [hsb]
 Uzbek Support [uz]
 Vietnamese Support [vi]
 Walloon Support [wa]
 Welsh Support [cy]
 Xhosa Support [xh]
 Zulu Support [zu]
 Done
 [root@localhost yum.repos.d]#

OK !

作者:zys467754239