天天看點

使用發行版CD光牒搭建本地yum源

在Linux主機中使用YUM工具線上安裝、更新軟體時,往往會因網速不穩定或者中途網絡中斷而導緻無法正常更新或安裝軟體,而搭建本地YUM源就無需為此而苦惱,因為其資源就存放在本地,而不受Internet的網絡限制,進而可以提升區域網路内更新軟體的效率

一、首先挂在CD光牒鏡像

<code>[root@1inux /]# </code><code>mkdir</code> <code>/mnt/cdrom</code>

<code>[root@1inux /]# mount -r /dev/cdrom /mnt/cdrom</code>

<code>[root@1inux /]# mount</code>

<code>/dev/mapper/vg0-root on / type ext4 (rw)</code>

<code>proc on /proc type proc (rw)</code>

<code>sysfs on /sys type sysfs (rw)</code>

<code>devpts on /dev/pts type devpts (rw,gid=5,mode=620)</code>

<code>tmpfs on /dev/shm type tmpfs (rw)</code>

<code>/dev/sda1 on /boot type ext4 (rw)</code>

<code>/dev/mapper/vg0-usr on /usr type ext4 (rw)</code>

<code>/dev/mapper/vg0-</code><code>var</code> <code>on /</code><code>var</code> <code>type ext4 (rw)</code>

<code>none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)</code>

<code>/dev/sr0 on /mnt/cdrom type iso9660 (ro)</code>

<code>[root@1inux /]#</code>

二、建立本地目錄/yum ,然後将CD光牒内的檔案複制到此目錄

<code>[root@1inux /]# </code><code>mkdir</code> <code>/yum</code>

<code>[root@1inux /]# cp -R /mnt/cdrom/* /yum</code>

<code>[root@1inux yum]# ls /yum</code>

<code>CentOS_BuildTag  isolinux                  RPM-GPG-KEY-CentOS-Debug-6</code>

<code>EFI              Packages                  RPM-GPG-KEY-CentOS-Security-6</code>

<code>EULA             RELEASE-NOTES-en-US.html  RPM-GPG-KEY-CentOS-Testing-6</code>

<code>GPL              repodata                  TRANS.TBL</code>

<code>images           RPM-GPG-KEY-CentOS-6</code>

三、建立yum repo配置檔案

---------repo檔案詳解---------------------------

[repositoryid]

# 對于目前系統的yum來講,此repositoryid用于惟一辨別此repository指向,是以,其必須惟一;

name= 

# 目前倉庫描述資訊;

baseurl=url://path/to/repository/

# 指明repository的通路路徑;通常為一個檔案伺服器上輸出的某repository;

url:

ftp服務

ftp://SERVER/PATH/TO/REPOSITORY

http服務

http://SERVER/PATH/TO/REPOSITORY

本地目錄:

file:///PATH/TO/REPOSTIROY

enabled={1|0}

此倉庫是否可被使用

gpgcheck={1|0}

是否對程式包做校驗

gpgkey=url://path/to/keyfile

指明gpgkey檔案路徑;

cost=#

指明目前repository的通路開銷,預設為1000;

-------------------------------------

<code>[root@1inux /]# vim /etc/yum.repos.d/CD-Local.repo</code>

<code>[CD-Local]</code>

<code>name=CentOS 6.6 X86_64 on dvd1</code>

<code>baseurl=file:</code><code>///yum</code>

<code>gpgcheck=0</code>

<code>enabled=1</code>

<code>~</code>

四、清除并删除記錄,然後檢視 yum 源的配置

清除記錄

<code>[root@1inux /]# yum clean all</code>

<code>Loaded plugins: fastestmirror, refresh-packagekit, security</code>

<code>Cleaning repos: CD-Local</code>

<code>Cleaning up Everything</code>

<code>Cleaning up list of fastest mirrors</code>

删除就記錄

<code>[root@1inux /]# rm -rf /</code><code>var</code><code>/cache/yum/*</code>

檢視yum 配置

<code>[root@1inux yum]# yum repolist</code>

<code>Loading mirror speeds from cached hostfile</code>

<code>repo id                                                    repo name                                                                    status</code>

<code>CD-Local                                                   CentOS 6.6 X86_64 on dvd1                                                    6,518</code>

<code>repolist: 6,518</code>

至此 我們的本地yum源已經搭建完畢,

五、為了驗證我們使用發行CD光牒制作的yum源可用,接下來我們使用我們本地搭建的yum 源安裝zsh軟體

1、首先我們檢視本機是否已經安裝了zsh軟體

<code>[root@1inux /]# rpm -qa zsh</code>

發現并沒有安裝

2、使用本地搭建的yum源安裝zsh

<code>[root@1inux /]# yum install zsh</code>

<code>Setting up Install Process</code>

<code>Resolving Dependencies</code>

<code>--&gt; Running transaction check</code>

<code>---&gt; Package zsh.x86_64 0:4.3.10-7.el6 will be installed</code>

<code>--&gt; Finished Dependency Resolution</code>

<code>Dependencies Resolved</code>

<code>====================================================================================================================================</code>

<code> </code><code>Package                    Arch                          Version                             Repository                       Size</code>

<code>Installing:</code>

<code> </code><code>zsh                        x86_64                        4.3.10-7.el6                        CD-Local                        2.1 M</code>

<code>Transaction Summary</code>

<code>Install       1 Package(s)</code>

<code>Total download size: 2.1 M</code>

<code>Installed size: 4.8 M</code>

<code>Is this ok [y/N]: y    </code><code>//輸入Y 确認安裝</code>

<code>Downloading Packages:</code>

<code>Running rpm_check_debug</code>

<code>Running Transaction Test</code>

<code>Transaction Test Succeeded</code>

<code>Running Transaction</code>

<code>  </code><code>Installing : zsh-4.3.10-7.el6.x86_64                                                                                          1/1 </code>

<code>  </code><code>Verifying  : zsh-4.3.10-7.el6.x86_64                                                                                          1/1 </code>

<code>Installed:</code>

<code>  </code><code>zsh.x86_64 0:4.3.10-7.el6                                                                                                         </code>

<code>Complete!</code>

顯示已将安裝完畢

驗證是否安裝完畢:

<code>[root@1inux yum]# cat /etc/shells </code>

<code>/bin/sh</code>

<code>/bin/bash</code>

<code>/sbin/nologin</code>

<code>/bin/dash</code>

<code>/bin/tcsh</code>

<code>/bin/csh</code>

<code>/bin/zsh</code>

<code>zsh-4.3.10-7.el6.x86_64</code>

OK  至此 我們使用發行CD光牒建立的本地yum源已經搭建完畢

本文轉自 1inux 51CTO部落格,原文連結:http://blog.51cto.com/1inux/1630801

繼續閱讀