歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux技術 >> Redhat linux本地yum源的配置教程

Redhat linux本地yum源的配置教程

日期:2017/3/1 18:04:38   编辑:Linux技術

相信對RedHat Linux或CentOS比較熟悉的人,應該是比較了解yum源的,它比普通的rpm包安裝,要方便的多,為何呢?因為它能順利的解決rpm包之間的依賴關系。你要是根據rpm包之間的依賴關系,一個一個的安裝,我也是很佩服的,我實在難以做到,有時安裝安裝的軟件需要幾十個rpm包,實在是太煩了啊.......
而用原來的yum源是需要上網的,而且很浪費流量啊。對於我這個用校園的,而且是按流量計費的,下東西對於我是件奢侈的事啊。
現在個大家介紹一種比較好的方法:用光盤裡自帶的包,來安裝我們需要的軟件。也就是將光盤裡的包做成yum源來用。

首先給大家介紹常用的yum源命令
1.使用YUM查找軟件包
命令:yum search <keyword>
2.列出所有可安裝的軟件包
命令:yum list
3.列出所有可更新的軟件包
命令:yum list updates
4.列出所有已安裝的軟件包
命令:yum list installed
5.列出所有已安裝但不在 Yum Repository 內的軟件包
命令:yum list extras
6.列出所指定的軟件包
命令:yum list <package_name>
7.使用YUM獲取軟件包信息
命令:yum info <package_name>
8.列出所有軟件包的信息
命令:yum info
9.列出所有可更新的軟件包信息
命令:yum info updates
10.列出所有已安裝的軟件包信息
命令:yum info installed
11.列出所有已安裝但不在 Yum Repository 內的軟件包信息
命令:yum info extras
12.列出軟件包提供哪些文件
命令:yum provides <package_name>

下面給大家介紹一下本地yum源的配置方法,非常簡單
拷貝系統安裝盤Server/目錄下的全部軟件到/RPMS
[root@localhost Server]# cp * /RPMS
......等的時間可能比較長。軟件數目比較多。
安裝createrespo創建軟件倉庫:

復制代碼代碼如下:
[root@localhost RPMS]# cd /RPMS/
[root@localhost RPMS]# 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%]
[root@localhost RPMS]# cp /mnt/cdrom /RPMS/
[root@localhost RPMS]# createrepo -p /RPMS/
2292/2292 - libXt-1.0.2-3.1.fc6.i386.rpm
Saving Primary metadata
Saving file lists metadata
Saving other metadata

配置rhel-debuginfo.repo

復制代碼代碼如下:
[root@localhost /]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ls
rhel-debuginfo.repo
[root@localhost yum.repos.d]#


復制代碼代碼如下:
[rhel-debuginfo]
name=Red Hat Enterprise Linux $releasever - $basearch - Debug
baseurl=ftp://ftp.redhat.com/pub/redhat/linux/enterprise/$releasever/en/os/$basearch/Debuginfo/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release


復制代碼代碼如下:
[rhel-debuginfo]
name=Red Hat Enterprise Linux $releasever - $basearch - Debug
baseurl=file:///RPMS/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

更新軟件包

復制代碼代碼如下:
[root@localhost RPMS]# yum update
Loaded plugins: rhnplugin, security
This system is not registered with RHN.
RHN support will be disabled.
rhel-debuginfo | 951 B 00:00
rhel-debuginfo/primary | 829 kB 00:00
rhel-debuginfo 2292/2292
Skipping security plugin, no data
Setting up Update Process
No Packages marked for Update
[root@localhost RPMS]#

這樣應該就可以了,你可以檢驗一下[以gcc為例]:

復制代碼代碼如下:
[root@localhost RPMS]# yum install gcc
Loaded plugins: rhnplugin, security
This system is not registered with RHN.
RHN support will be disabled.
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package gcc.i386 0:4.1.2-46.el5 set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
==============================================================================================
Package Arch Version Repository Size
==============================================================================================
Installing:
gcc i386 4.1.2-46.el5 rhel-debuginfo 5.2 M
Transaction Summary
==============================================================================================
Install 1 Package(s)
Update 0 Package(s)
Remove 0 Package(s)
Total download size: 5.2 M
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : gcc 1/1
Installed:
gcc.i386 0:4.1.2-46.el5
Complete!
[root@localhost RPMS]#

這樣基本上就解決了,RedHat Linux本地yum 源的配置了,不用再為文件之間的依賴關系而煩神了......哈哈。

Copyright © Linux教程網 All Rights Reserved