構建本地YUM源服務器

Red Hat Enterprise Linux 5中在安裝時沒有選擇所有軟件包,以後在使用過程中想再增加缺少的軟件包,通常情況可以通過兩種途徑完成。
一、是通過rpm手工安裝需要安裝的軟件包;
二、是通過註冊RHN,然後由yum通過internet連接到RHN站來新增軟件包。
這兩種情況都有其不便之外,第一種由於存在軟件包的依賴性關係,可能需要在安裝一個rpm包之前要安裝多個與之關聯的軟件包,而往往這些依賴的包的名稱我們無法正確定位。尤其經常提示缺乏某一動態函數庫時,我們就不容易方便查到所需軟件包的名稱。第二種方法雖然不存在上述情況,但顯而易見的問題是需要連接internet,而且安裝軟件包的速度會很慢。
爲了避免上述兩種情況的弊端,我們可以通過自己創建本地的repository(倉庫)的方法來實現軟件包的快速安裝。(此方法前提是你有Red Hat Enterprise Linux 5安裝介質盤)
1.        創建掛載點
mkdir /yum
2.        掛載安裝介質盤
mount /dev/cdrom /mnt
3.        複製光盤內容到/yum目錄中
cp /mnt/* /yum
4.        安裝創建repository的軟件包
   rpm -ivh createrepo-0.4.4-2.fc6.noarch.rpm
5.        /yum/repodate目錄下的所有內容移動到指定的位置/home/repodate
mv /yum/Server/repodata/*把系統原有的存放repository內容的目錄改名
6.        創建自己的repository(yum創建軟件庫)
  createrepo –g /home/repodate/comps-rhel5-server-core.xml /yum/Server/ repodate
7.        修改yumrepository配置文件,指定baseurl路徑爲本地file
cd /etc/yum.repos.d
vi rhel51-server.repo,修改的內容如下
[rhel51-server]
name=Red Hat Enterprise Linux $releasever - $basearch
baseurl=file:///yum/Server
enable=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
8.        如果還想實現更新庫的功能,只需要把從RHN下載的新的軟件包copyServer目錄下,再運行createrepo命令更新庫內容就可以了
9.        測試:安裝安裝vsftp軟件包
[root@localhost ftp]# yum install vsftpd
Failed to set locale, defaulting to C
Loading "installonlyn" plugin
Loading "rhnplugin" plugin
This system is not registered with RHN.
RHN support will be disabled.
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 vsftpd to pack into transaction set.
vsftpd-2.0.5-10.el5.i386. 100% |=========================|  17 kB    00:00     
---> Package vsftpd.i386 0:2.0.5-10.el5 set to be updated
--> Running transaction check

Dependencies Resolved

=============================================================================
Package                 Arch       Version          Repository        Size
=============================================================================
Installing:
vsftpd                  i386       2.0.5-10.el5     Server            137 k

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

Total download size: 137 k
Is this ok [y/N]: y
Downloading Packages:
Running Transaction Test
warning: vsftpd-2.0.5-10.el5: Header V3 DSA signature: NOKEY, key ID 37017186
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing: vsftpd                                                [1/1]warning: /etc/logrotate.d/vsftpd.log created as/etc/logrotate.d/vsftpd.log.rpmnew
  Installing: vsftpd                                                [1/1]warning: /etc/pam.d/vsftpd created as /etc/pam.d/vsftpd.rpmnew
  Installing: vsftpd                                                [1/1]warning: /etc/vsftpd/ftpusers created as/etc/vsftpd/ftpusers.rpmnew
  Installing: vsftpd                                                [1/1]warning: /etc/vsftpd/user_list created as/etc/vsftpd/user_list.rpmnew
  Installing: vsftpd                                                [1/1]warning: /etc/vsftpd/vsftpd.conf created as/etc/vsftpd/vsftpd.conf.rpmnew
  Installing: vsftpd                                                [1/1]warning: /etc/vsftpd/vsftpd_conf_migrate.sh created as/etc/vsftpd/vsftpd_conf_migrate.sh.rpmnew
  Installing: vsftpd                       ######################### [1/1]

Installed: vsftpd.i386 0:2.0.5-10.el5
Complete!
[root@localhost ftp]#
10.        測試:卸載vsftpd
[root@localhost ftp]# yum remove vsftpd
Failed to set locale, defaulting to C
Loading "installonlyn" plugin
Loading "rhnplugin" plugin
This system is not registered with RHN.
RHN support will be disabled.
Setting up Remove Process
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Package vsftpd.i386 0:2.0.5-10.el5 set to be erased
--> Running transaction check

Dependencies Resolved

=============================================================================
Package                 Arch       Version          Repository        Size
=============================================================================
Removing:
vsftpd                  i386       2.0.5-10.el5     installed         283 k

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

Is this ok [y/N]: y
Downloading Packages:
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Removing  : vsftpd                       ######################### [1/1]

Removed: vsftpd.i386 0:2.0.5-10.el5
Complete!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章