歡迎您光臨本站 註冊首頁

為Fedora11構建本地yum倉庫

←手機掃碼閱讀     火星人 @ 2014-03-09 , reply:0
Fedora11推出后,linux在桌面上的易用性大為提高,具備在辦公/開發環境部署的可能性.
但才發布幾天,yum update要下載的升級包竟然接近200M, 沒辦法,這是開源軟體無法避免的,補丁頻繁肯定.
為了避免內網機器重複下載相同文件,可以創建一個升級倉庫內網私用.
-
[服務端倉庫創建和配置]
1.安裝創建倉庫的工具
yum install createrepo

2.創建目錄結構
mkdir -p /xxxxxxx/repos/yum/fedora/base/11/i386
mkdir -p /xxxxxxx/repos/yum/fedora/updates/11/i386
註:/xxxxxxx/是任意選定的文件系統路徑

3.複製DVD的文件到到base目錄
mount -o loop,ro Fedora11-i386-DVD.iso /mnt/iso
cp -v /mnt/iso/Packages/* /xxxxxxx/repos/yum/fedora/base/11/i386
umount /mnt/iso

4.DVD光碟只包含基本的安裝包集合,如果需要所有安裝包,先執行下面:(不同鏡像任選其一)
rsync -avrt --progress rsync://ftp.jaist.ac.jp/pub/Linux/Fedora/releases/11/Everything/i386/os/Packages/ /xxxxxxx/repos/yum/fedora/base/11/i386
rsync -avrt --progress rsync://mirror.anl.gov/fedora/linux/releases/11/Everything/i386/os/Packages/ /xxxxxxx/repos/yum/fedora/base/11/i386
注1:rsync語法要求嚴格,目錄同步不能缺少源路徑最后的"/"
注2:請在http://mirrors.fedoraproject.org/publiclist/Fedora/11/頁面中中找一個合用的rsync鏡像

5.創建倉庫所需要的數據結構文件
createrepo /xxxxxxx/repos/yum/fedora/base/11/i386
會生成/xxxxxxx/repos/yum/fedora/base/11/i386/repodata目錄,裡面包含若干xml和gz文件


6.同步updates目錄
rsync -avrt --progress rsync://ftp.jaist.ac.jp/pub/Linux/Fedora/updates/11/i386/ --exclude=debug/ /xxxxxxx/repos/yum/fedora/updates/11/i386

7.生成cron任務定期自動更新updates


crontab -e (每天晚上2時40分更新)
40 2 * * * /usr/bin/rsync -avrt rsync://mirror.anl.gov/fedora/linux/updates/8/i386/ --exclude=debug/ /xxxxxxx/repos/yum/fedora/updates/11/i386

8.配置httpd供訪問
基本上就是生成別名或命名虛擬主機方式進行訪問了
下面是基於名稱的虛擬主機的配置方式
cat 000-default
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "/var/www/html"
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory "/var/www/html">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

<VirtualHost *:80>
ServerAdmin admin@localdomain
DocumentRoot /xxxxx/repos
ServerName updates.domain.net
DirectoryIndex index.html
LogLevel debug
ErrorLog logs/updates.domain.net-error_log
CustomLog logs/updates.domain.net-access_log common

<location / >
Options Indexes
Order allow,deny
allow from all
</location>
</VirtualHost>




[客戶端配置]
touch /etc/yum.repos.d/local.repos
vi /etc/yum.repos.d/local.repos
內容如下:
[base-local]
name=Fedora $releasever - $basearch
failovermethod=priority
baseurl=http://updates.domain.net/yum/fedora/base/$releasever/$basearch
enabled=1
gpgcheck=0

[updates-local]
name=Fedora $releasever - $basearch - Updates
failovermethod=priority
baseurl=http://updates.domain.net/yum/fedora/updates/$releasever/$basearch/
enabled=1
gpgcheck=0

最后把原來的repos文件中base和updates有關的改為enabled=0



[火星人 ] 為Fedora11構建本地yum倉庫已經有554次圍觀

http://coctec.com/docs/linux/show-post-53591.html