How To Set Up A Local Yum Repository On Fedora 9

Thứ ba - 29/07/2008 07:32
This tutorial shows how to create a Fedora 9 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.100.10 and port 9090. 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 9 rpm packages for i386 in /var/www/html/yum/base/9/i386 and the update packages in /var/www/html/yum/updates/9/i386, so I create these directories now (adjust the paths if you want to create a repository for Fedora 8/7/... and/or x86_64):

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


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

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


The DVD contains just a basic set of packages. If you'd like to have all available Fedora 9 packages in the /var/www/html/yum/base/9/i386 directory, you can download the packages (using rsync) from the Everything folder on a Fedora 9 mirror. Go to http://mirrors.fedoraproject.org/mirrorlists/publiclist/Fedora/9, 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/9/Everything/i386/os/Packages/ /var/www/html/yum/base/9/i386

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

Afterwards, run the createrepo command:

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

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

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

[root@server1 /]# ls -l /var/www/html/yum/base/9/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/9/i386. Go to http://mirrors.fedoraproject.org/mirrorlists/publiclist/Fedora/9 again, find a mirror that offers rsync, and download the packages as follows:

rsync -avrt rsync://mirror.internode.on.net/fedora-enchilada/linux/updates/9/i386/ --exclude=debug/ /var/www/html/yum/updates/9/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://mirror.internode.on.net/fedora-enchilada/linux/updates/9/i386/ --exclude=debug/ /var/www/html/yum/updates/9/i386


Our local yum mirror is now ready to be used.

4. Client Configuration


To make our Fedora 9 systems use the new local yum repository, we modify /etc/yum.conf on each Fedora 9 system (you can even do this on the mirror itself if it is a Fedora 9 system). Create new file /etc/yum.repos.d/local.repo with these lines:

[base-local]
name=Fedora $releasever - $basearch
failovermethod=priority
baseurl=http://mirror.iwayvietnam.com:9090/yum/base/$releasever/$basearch
enabled=1
gpgcheck=0


[updates-newley-local]
name=Fedora $releasever - $basearch - Updates Newkey
failovermethod=priority
baseurl=http://mirror.iwayvietnam.com:9090/yum/updates/$releasever/$basearch.newkey/
enabled=1
gpgcheck=0


And finally, disable the existing fedora-updates-newkey by this command:

mv /etc/yum.repos.d/fedora-updates-newkey.repo /etc/yum.repos.d/fedora-updates-newkey.repo.bak

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


Tổng số điểm của bài viết là: 0 trong 0 đánh giá

Click để đánh giá bài viết

  Ý kiến bạn đọc

Bạn cần trở thành thành viên của nhóm để có thể bình luận bài viết này. Nhấn vào đây để đăng ký làm thành viên nhóm!
Giới thiệu

Cộng đồng Fedora Việt Nam

Sứ mệnh của dự án Fedora là tập hợp, dẫn dắt các tiến bộ của phần mềm và nội dung tự do nguồn mở trong một cộng đồng hợp tác, thông qua việc: Không ngừng phấn đấu để luôn đi đầu Không ngừng tìm tòi, sáng tạo, vươn lên và truyền bá phần mềm và nội dung tự do Chia sẻ thành công với toàn thể cộng...

Đăng nhập thành viên
Hãy đăng nhập thành viên để trải nghiệm đầy đủ các tiện ích trên site
Thống kê truy cập
  • Đang truy cập33
  • Hôm nay416
  • Tháng hiện tại99,671
  • Tổng lượt truy cập2,527,126
Fedora Project

Fedora is always free for anyone to use, modify, and distribute. It is built and used by people across the globe who work together as a community: the Fedora Project.

freedom
friends
features
first
Bạn đã không sử dụng Site, Bấm vào đây để duy trì trạng thái đăng nhập. Thời gian chờ: 60 giây