1. 程式人生 > >網路yum源製作

網路yum源製作

思路:在網路上準備一個主機,在其中安裝一個web伺服器軟體(比如apache),然後建立一個目錄,在這個目錄中準備上yum倉庫的全部資源,如果使用者可以通過網路訪問到該主機的這個目錄,那麼這個目錄就成為網路yum倉庫

實現過程
第一步:配置yum源主機

1)安裝配置apache

[[email protected]66 ~]# yum install httpd -y

2)配置yum倉庫相關資源

1. 建立一個目錄,作為儲存yum資源的目錄,此次目錄為mysource

(此目錄需要建立在apache的根目錄下,由於安裝方式不相同,根目錄位置也不相同

採用編譯安裝的apache根目錄在/usr/local/apache/htdocs下,yum安裝的apache根目錄在/var/www/html下)

在apache根目錄中建立yum資源的目錄

[[email protected]66~]# mkdir /var/www/html/mysource
[[email protected] ~]# cd /var/www/html/
[[email protected] html]# ls
mysource

3). 掛載光碟(本次使用系統自帶的光碟中的源,自己也可以到國內映象網站下載源)

[[email protected] ~]# mount /dev/sr0 /mnt
mount: /dev/sr0 is write-protected, mounting read-only

 4). 將光碟中的資源複製到前面所建立的目錄下

[[email protected]67 ~]# cp /mnt/* /var/www/html/mysource/ -rvf

5).檢視

[[email protected]67~]# ls /var/www/html/mysource/
CentOS_BuildTag  EULA  images    LiveOS    repodata              RPM-GPG-KEY-CentOS-Testing-7
EFI              GPL   isolinux  Packages  RPM
-GPG-KEY-CentOS-7 TRANS.TBL

6). 用瀏覽器訪問一下yum倉庫,檢查是否可以看到相關檔案

此次實驗主機ip10.220.5.67,在瀏覽器輸入10.220.5.67.mysource

 

說明部署成功

 第二步:配置客戶端主機 用於測試(10.220.5.63)

修改yum配置檔案

1)備份原有的配置檔案

[[email protected]63 ~]# mkdir bak
[[email protected]63 ~]# mv /etc/yum.repos.d/*.repo bak
[[email protected]63 ~]# cd /etc/yum.repos.d/
[[email protected]63 yum.repos.d]#
[[email protected]63 yum.repos.d]# vim mysource.repo
[mysource]
name=mysource
enabled=1
gpgcheck=0
baseurl=http://10.220.5.66/mysource <<<所指定的位置為repodata所的路徑
                               

清除快取

[[email protected]63 yum.repos.d]# yum clean all

 檢視yum倉庫的資訊

[[email protected]63 yum.repos.d]# yum repolist
Loaded plugins: fastestmirror
Determining fastest mirrors
mysource                                                                                | 3.6 kB  00:00:00     
(1/2): mysource/group_gz                                                                | 166 kB  00:00:00     
(2/2): mysource/primary_db                                                              | 3.1 MB  00:00:00     
repo id                                             repo name                                            status
mysource                                            mysource                                             3,971
repolist: 3,971  <<<有3791個包說明網路yum可用

安裝ipvsadm (lvs)

[[email protected]63 yum.repos.d]# yum install ipvsadm -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package ipvsadm.x86_64 0:1.27-7.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================
 Package                  Arch                    Version                      Repository                 Size
===============================================================================================================
Installing:
 ipvsadm                  x86_64                  1.27-7.el7                   mysource                   45 k

Transaction Summary
===============================================================================================================
Install  1 Package

Total download size: 45 k
Installed size: 75 k
Downloading packages:
ipvsadm-1.27-7.el7.x86_64.rpm                                                           |  45 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : ipvsadm-1.27-7.el7.x86_64                                                                   1/1 
  Verifying  : ipvsadm-1.27-7.el7.x86_64                                                                   1/1 

Installed:
  ipvsadm.x86_64 0:1.27-7.el7                                                                                  

Complete!

測試成功