感谢支持
我们一直在努力

Fedora8下架建自己的yum本地源与镜像

无法忍受Fedora8的yum库更新的速度了,决定自己做一个yum的本地源,这样安装和升级软件会非常的快捷。


Fedora Project的官方源列表可以点击查看:http://mirrors.fedoraproject.org/


我简单的用ping的方式测试了一下官方的yum的源的列表,发觉我这里速度最快的是linux.ntcu.net(台湾)大约80ms。当然ping的值并不是最理想的测试下载速度的工具,但ping工具可以测试整条链路的稳定性,速度的话最好一个一个用wget来测试,当然也多分几次时间点来测试。


搭建Fedora8的本地镜像源可以参考:How To Set Up A Local Yum Repository On Fedora 8。见http://www.linuxidc.com/Linux/2008-02/11255p2.htm


基本思路就是利用rsync来定时同步指定的官方源,我现在开始利用rsync来同步,估计要一周左右的时间才能将所有的包都下载下来。

How To Set Up A Local Yum Repository On Fedora 8
Version 1.0
Author: Falko Timme <ft [at] falkotimme [dot] com>
Last edited 12/18/2007


This tutorial shows how to create a Fedora 8 yum repository for your local network. Having a local Fedora mirror is good if you have to install multiple systems in your local network because then all needed packages can be downloaded over the fast LAN connection, thus saving your internet bandwidth.


I do not issue any guarantee that this will work for you!


1 Preliminary Note
In this tutorial I use the hostname server1.example.com with the IP address 192.168.0.100. These settings might differ for you, so you have to replace them where appropriate.


I want to make the yum repository accessible through http; Apache’s default document root on Fedora is /var/www/html, so I’ll create the repository in /var/www/html/yum. If you’re using a different vhost, you might have to adjust the paths.


2 Installing Apache
Let’s install Apache:


yum install httpd


Afterwards, we create the system startup links for Apache (so that Apache starts automatically when the system boots):


chkconfig –levels 235 httpd on


Then we start Apache:


/etc/init.d/httpd start 


3 Building The Repository
First we install the tool createrepo:


yum install createrepo


I want to place the Fedora 8 rpm packages for i386 in /var/www/html/yum/base/8/i386 and the update packages in /var/www/html/yum/updates/8/i386, so I create these directories now (adjust the paths if you want to create a repository for Fedora 7/6/… and/or x86_64):


mkdir -p /var/www/html/yum/base/8/i386
mkdir -p /var/www/html/yum/updates/8/i386


Now let’s fill the /var/www/html/yum/base/8/i386 directory. The easiest way is to insert your Fedora 8 DVD (which you can download from here: http://mirrors.fedoraproject.org/mirrorlists/publiclist/Fedora/8), mount it, and copy the rpm packages to /var/www/html/yum/base/8/i386:


mount /dev/cdrom /mnt
cd /mnt/Packages
cp -v * /var/www/html/yum/base/8/i386
cd /
umount /mnt


The DVD contains just a basic set of packages. If you’d like to have all available Fedora 8 packages in the /var/www/html/yum/base/8/i386 directory, you can download the packages (using rsync) from the Everything folder on a Fedora 8 mirror. Go to http://mirrors.fedoraproject.org/mirrorlists/publiclist/Fedora/8, find a mirror that offers rsync, and download the packages as follows (this can take a long time so be patient):


rsync -avrt rsync://ftp-stud.hs-esslingen.de/fedora/linux/releases/8/Everything/i386/os/Packages/ /var/www/html/yum/base/8/i386


(Please make sure you use all slashes (/) as shown above – it must be rsync://ftp-stud.hs-esslingen.de/fedora/linux/releases/8/Everything/i386/os/Packages/, not rsync://ftp-stud.hs-esslingen.de/fedora/linux/releases/8/Everything/i386/os/Packages!)


Afterwards, run the createrepo command:


createrepo /var/www/html/yum/base/8/i386


This will create a repodata directory in the /var/www/html/yum/base/8/i386 directory. Its contents should be as follows:


ls -l /var/www/html/yum/base/8/i386/repodata/


[root@server1 /]# ls -l /var/www/html/yum/base/8/i386/repodata/
total 9268
-rw-r–r– 1 root root 2227275 2007-12-18 21:11 filelists.xml.gz
-rw-r–r– 1 root root 6487453 2007-12-18 21:11 other.xml.gz
-rw-r–r– 1 root root  747714 2007-12-18 21:11 primary.xml.gz
-rw-r–r– 1 root root     951 2007-12-18 21:11 repomd.xml
[root@server1 /]#


Now let’s fill the updates directory /var/www/html/yum/updates/8/i386. Go to http://mirrors.fedoraproject.org/mirrorlists/publiclist/Fedora/8 again, find a mirror that offers rsync, and download the packages as follows:


rsync -avrt rsync://ftp-stud.hs-esslingen.de/fedora/linux/updates/8/i386/ –exclude=debug/ /var/www/html/yum/updates/8/i386


Again, make sure that you use the slashes (/) as shown above!


To make our local mirror download the latest updates automatically from now on, we can create a cron job. For example, to download the latest updates every second day at 04:23h, we create the following cron job:


crontab -e


23 4 */2 * * /usr/bin/rsync -avrt rsync://ftp-stud.hs-esslingen.de/fedora/linux/updates/8/i386/ –exclude=debug/ /var/www/html/yum/updates/8/i386


Our local yum mirror is now ready to be used.


 


4 Client Configuration
To make our Fedora 8 systems use the new local yum repository, we modify /etc/yum.conf on each Fedora 8 system (you can even do this on the mirror itself if it is a Fedora 8 system). Open /etc/yum.conf:


vi /etc/yum.conf


Find these two lines…


# PUT YOUR REPOS HERE OR IN separate files named file.repo
# in /etc/yum.repos.d


… and add the following stanzas below these lines:


[base-local]
name=Fedora $releasever – $basearch
failovermethod=priority
baseurl=http://192.168.0.100/yum/base/$releasever/$basearch
#mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=fedora-$releasever&arch=$basearch
enabled=1
gpgcheck=0


[updates-local]
name=Fedora $releasever – $basearch – Updates
failovermethod=priority
baseurl=http://192.168.0.100/yum/updates/$releasever/$basearch/
#mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=updates-released-f$releasever&arch=$basearch
enabled=1
gpgcheck=0


The complete file should look like this:


[main]
cachedir=/var/cache/yum
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
metadata_expire=1800
installonly_limit=2


# PUT YOUR REPOS HERE OR IN separate files named file.repo
# in /etc/yum.repos.d


[base-local]
name=Fedora $releasever – $basearch
failovermethod=priority
baseurl=http://192.168.0.100/yum/base/$releasever/$basearch
#mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=fedora-$releasever&arch=$basearch
enabled=1
gpgcheck=0


[updates-local]
name=Fedora $releasever – $basearch – Updates
failovermethod=priority
baseurl=http://192.168.0.100/yum/updates/$releasever/$basearch/
#mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=updates-released-f$releasever&arch=$basearch
enabled=1
gpgcheck=0


Now whenever you use yum and your local repository can serve the requested packages, the packages are downloaded and installed from the local yum repository.


 


5 Links
Fedora: http://fedoraproject.org

赞(0) 打赏
转载请注明出处:服务器评测 » Fedora8下架建自己的yum本地源与镜像
分享到: 更多 (0)

听说打赏我的人,都进福布斯排行榜啦!

支付宝扫一扫打赏

微信扫一扫打赏