centos使用光碟片作為本地的yum源

來源:互聯網
上載者:User

 摘:http://qubaoquan.blog.51cto.com/1246748/292516

 

 

建立檔案夾

[root@localhost CentOS]# mkdir /media/CentOS

把光碟片載入到本地

[root@localhost CentOS]# mount /dev/cdrom /media/CentOS

在/etc/yum.repos.d/目錄下,有兩個檔案

CentOS-Base.repo和CentOS-Media.repo

其中CentOS-Base.repo記錄著網路上的yum源的地址和路徑資訊等

CentOS-Media.repo記錄著可以從本地作為yum源的介質和路徑。其中還有這樣一個說明:

# CentOS-Media.repo
#
# This repo is used to mount the default locations for a CDROM / DVD on
# CentOS-5. You can use this repo and yum to install items directly off the
# DVD ISO that we release.
#
# To use this repo, put in your DVD and use it with the other repos too:
# yum --enablerepo=c5-media [command]
#
# or for ONLY the media repo, do this:
#
# yum --disablerepo=\* --enablerepo=c5-media [command]

[c5-media]
name=CentOS-$releasever - Media
baseurl=file:///media/ CentOS
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-beta

我們只需編輯下bashurl ,將自己的光碟片路徑寫入就可以了。

覺得自己的光碟片的源足夠用了。不需要網路源,或者沒有網路。

可以使用yum --disablerepo=\* --enablerepo=c5-media [command]

yum命令允許使用本地media介質的源而已。正確的命令如下(更新gcc為例):

[root@centos cdrom]# yum --disablerepo =* --enablerepo=c5-media install gcc

Loading " installonlyn " plugin
Setting up Update Process
Setting up repositories
c5 - media                   100 % |=========================| 1.1 kB     00 : 00
Reading repository metadata in from local files
primary.xml.gz             100 % |=========================| 834 kB     00 : 00
################################################## 2400 / 2400
No Packages marked for Update / Obsoletion

比如安裝gdb

[root@centos cdrom]# yum --disablerepo =* --enablerepo=c5-media install gdb
Loading " installonlyn " plugin
Setting up Install Process
Setting up repositories
Reading repository metadata in from local files
Parsing package install arguments
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for gdb to pack into transaction set .
gdb - 6.5 - 25 .el5.i386.rpm    100 % |=========================| 56 kB     00 : 00
---> Package gdb.i386 0 : 6.5 - 25 .el5 set to be updated
--> Running transaction check

Dependencies Resolved

=============================================================================
Package                  Arch        Version           Repository         Size
=============================================================================
Installing:
gdb                      i386        6.5 - 25 .el5        c5 - media           3.1 M

Transaction Summary
=============================================================================
Install       1 Package(s)         
Update        0 Package(s)         
Remove        0 Package(s)         

Total download size: 3.1 M
Is this ok [y / N]: y
Downloading Packages:
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
   Installing: gdb                           ######################### [ 1 / 1 ]

Installed: gdb.i386 0 : 6.5 - 25 .el5
Complete !
[root@centos cdrom]#

在使用yum進行install時,經常會出現下面的錯誤
warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID 1ac70ce6
導致安裝不能進行。解決方案如下:
[root@localhost CentOS]# rpm --import   /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
[root@localhost CentOS]# rpm --import   /etc/pki/rpm-gpg/RPM-GPG-KEY-beta

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.