天天看點

搭建本地yum伺服器

在内網環境下,伺服器通常不聯網,這時候如果要下載下傳什麼軟體,搭建本地yum伺服器的話就很友善了。

建立挂載目錄:

[root@Herry ~]# mkdir -p /local/yum         

2.挂載你的CD光牒或者U盤到指定目錄下,這裡的/dev/cdrom可以是你的U盤,具體看你用什麼了[root@Herry ~]# mount /dev/cdrom /local/yum

3.copy源yum的目錄檔案,我做實驗需要還原的,這個不是必須

[root@Herry ~]# cp -r /etc/yum.repos.d /etc/yum.repos.d.aak

4.删除源Yum目錄下的所有檔案,這個不是必須

[root@Herry ~]# rm -f /etc/yum.repos.d/*

5.修改配置檔案,你也可以直接在/etc/yum.repos.d/CentOS-Base.repo下增加以下配置,不過在使用yum的時候,它會從上往下比對,比較耗時,是以這裡我就直接删除源yum檔案了,新增了以下local_yum.repo:

[root@Herry ~]# vim /etc/yum.repos.d/local_yum.repo

[local_yum]

name=this is local yum

baseurl=file:///local/yum

enabled=1 (是否啟用該yum源,0為禁用)

gpgcheck=0 (是否檢查gpgkey,0為不檢查)

#gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6(gpgcheck=0時無需配置)

6.測試:解除安裝vim

[root@Herry ~]# yum remove -y vim

Loaded plugins: fastestmirror

Setting up Remove Process

Resolving Dependencies

There are unfinished transactions remaining. You might consider running yum-complete-transaction first to finish them.

The program yum-complete-transaction is found in the yum-utils package.

--> Running transaction check

---> Package vim-enhanced.x86_64 2:7.2.411-1.8.el6 will be erased

--> Finished Dependency Resolution

local_yum                                                                                          | 4.0 kB     00:00 ...

local_yum/primary_db                                                                               | 4.4 MB     00:00 ...

Dependencies Resolved

==========================================================================================================================

 Package               Arch            Version                    Repository                                         Size

Removing:

 vim-enhanced          x86_64          2:7.2.411-1.8.el6          @anaconda-CentOS-201311272149.x86_64/6.5          1.8 M

Transaction Summary

Remove        1 Package(s)

Installed size: 1.8 M

Downloading Packages:

Running rpm_check_debug

Running Transaction Test

Transaction Test Succeeded

Running Transaction

  Erasing    : 2:vim-enhanced-7.2.411-1.8.el6.x86_64                                                                  1/1

  Verifying  : 2:vim-enhanced-7.2.411-1.8.el6.x86_64                                                                  1/1

Removed:

  vim-enhanced.x86_64 2:7.2.411-1.8.el6

7.指令vim無法使用了:

[root@Herry ~]# !v

vim /etc/yum.repos.d/local_yum.repo

-bash: /usr/bin/vim: 沒有那個檔案或目錄

8.安裝回來vim:

[root@Herry ~]# yum install -y vim                 

Determining fastest mirrors

Setting up Install Process

---> Package vim-enhanced.x86_64 2:7.2.411-1.8.el6 will be installed

 Package                      Arch                   Version                              Repository                 Size

Installing:

 vim-enhanced                 x86_64                 2:7.2.411-1.8.el6                    local_yum                 892 k

Install       1 Package(s)

Total download size: 892 k

  Installing : 2:vim-enhanced-7.2.411-1.8.el6.x86_64                                                                  1/1

Installed:

9.可以使用vim了 :

enabled=1

gpgcheck=0

至此本地yum搭建完成。

本文轉自飛奔的小GUI部落格51CTO部落格,原文連結http://blog.51cto.com/9237101/1913071如需轉載請自行聯系原作者

ziwenzhou