{"id":69,"date":"2008-07-29T14:32:21","date_gmt":"2008-07-29T07:32:21","guid":{"rendered":"http:\/\/blog.iwayvietnam.com\/tuanta\/2008\/07\/29\/how-to-set-up-a-local-yum-repository-on-fedora-9\/"},"modified":"2008-09-29T16:44:09","modified_gmt":"2008-09-29T09:44:09","slug":"how-to-set-up-a-local-yum-repository-on-fedora-9","status":"publish","type":"post","link":"https:\/\/blog.iwayvietnam.com\/tuanta\/2008\/07\/how-to-set-up-a-local-yum-repository-on-fedora-9\/","title":{"rendered":"How To Set Up A Local Yum Repository On Fedora 9"},"content":{"rendered":"<p>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.<\/p>\n<p>I do not issue any guarantee that this will work for you!<\/p>\n<h3>1. Preliminary Note<\/h3>\n<p>In this tutorial I use the hostname <code>server1.example.com<\/code> with the IP address <code>192.168.100.10<\/code> and port <code>9090<\/code>. These settings might differ for you, so you have to replace them where appropriate.<\/p>\n<p>I want to make the yum repository accessible through http; Apache&#8217;s default document root on Fedora is <code>\/var\/www\/html<\/code>, so I&#8217;ll create the repository in <code>\/var\/www\/html\/yum<\/code>. If you&#8217;re using a different vhost, you might have to adjust the paths.<\/p>\n<h3>2. Installing Apache<\/h3>\n<p>Let&#8217;s install Apache:<\/p>\n<p><code>yum install httpd<\/code><\/p>\n<p>Afterwards, we create the system startup links for Apache (so that Apache starts automatically when the system boots):<\/p>\n<p><code>chkconfig --levels 235 httpd on<\/code><\/p>\n<p>Then we start Apache:<\/p>\n<p><code>\/etc\/init.d\/httpd start<\/code><\/p>\n<h3>3. Building The Repository<\/h3>\n<p>First we install the tool createrepo:<\/p>\n<p><code>yum install createrepo<\/code><\/p>\n<p>I want to place the Fedora 9 rpm packages for i386 in <code>\/var\/www\/html\/yum\/base\/9\/i386<\/code> and the update packages in <code>\/var\/www\/html\/yum\/updates\/9\/i386<\/code>, so I create these directories now (adjust the paths if you want to create a repository for Fedora 8\/7\/&#8230; and\/or x86_64):<\/p>\n<p><code>mkdir -p \/var\/www\/html\/yum\/base\/9\/i386<br \/>\nmkdir -p \/var\/www\/html\/yum\/updates\/9\/i386<\/code><\/p>\n<p>Now let&#8217;s fill the <code>\/var\/www\/html\/yum\/base\/9\/i386<\/code> directory. The easiest way is to insert your Fedora 9 DVD (which you can download from here: <a href=\"http:\/\/mirrors.fedoraproject.org\/mirrorlists\/publiclist\/Fedora\/9\">http:\/\/mirrors.fedoraproject.org\/mirrorlists\/publiclist\/Fedora\/9<\/a>), mount it, and copy the rpm packages to <code>\/var\/www\/html\/yum\/base\/9\/i386<\/code>:<\/p>\n<p><code>mount \/dev\/cdrom \/mnt<br \/>\ncd \/mnt\/Packages<br \/>\ncp -v * \/var\/www\/html\/yum\/base\/9\/i386<br \/>\ncd \/<br \/>\numount \/mnt<\/code><\/p>\n<p>The DVD contains just a basic set of packages. If you&#8217;d like to have all available Fedora 9 packages in the <code>\/var\/www\/html\/yum\/base\/9\/i386<\/code> directory, you can download the packages (using rsync) from the Everything folder on a Fedora 9 mirror. Go to <a href=\"http:\/\/mirrors.fedoraproject.org\/mirrorlists\/publiclist\/Fedora\/9\">http:\/\/mirrors.fedoraproject.org\/mirrorlists\/publiclist\/Fedora\/9<\/a>, find a mirror that offers rsync, and download the packages as follows (this can take a long time so be patient):<\/p>\n<p><code>rsync -avrt rsync:\/\/ftp-stud.hs-esslingen.de\/fedora\/linux\/releases\/9\/Everything\/i386\/os\/Packages\/ \/var\/www\/html\/yum\/base\/9\/i386<\/code><\/p>\n<p>(Please make sure you use all slashes as shown above &#8211; it must be <code>rsync:\/\/ftp-stud.hs-esslingen.de\/fedora\/linux\/releases\/9\/Everything\/i386\/os\/Packages\/<\/code>, not <code>rsync:\/\/ftp-stud.hs-esslingen.de\/fedora\/linux\/releases\/9\/Everything\/i386\/os\/Packages<\/code>!)<\/p>\n<p>Afterwards, run the createrepo command:<\/p>\n<p><code>createrepo \/var\/www\/html\/yum\/base\/9\/i386<\/code><\/p>\n<p>This will create a <code>repodata<\/code> directory in the <code>\/var\/www\/html\/yum\/base\/9\/i386<\/code> directory. Its contents should be as follows:<\/p>\n<p><code>ls -l \/var\/www\/html\/yum\/base\/9\/i386\/repodata\/<\/code><\/p>\n<p><code>[root@server1 \/]# ls -l \/var\/www\/html\/yum\/base\/9\/i386\/repodata\/<br \/>\ntotal 9268<br \/>\n-rw-r--r-- 1 root root 2227275 2007-12-18 21:11 filelists.xml.gz<br \/>\n-rw-r--r-- 1 root root 6487453 2007-12-18 21:11 other.xml.gz<br \/>\n-rw-r--r-- 1 root root  747714 2007-12-18 21:11 primary.xml.gz<br \/>\n-rw-r--r-- 1 root root     951 2007-12-18 21:11 repomd.xml<br \/>\n[root@server1 \/]#<\/code><\/p>\n<p>Now let&#8217;s fill the updates directory <code>\/var\/www\/html\/yum\/updates\/9\/i386<\/code>. Go to <a href=\"http:\/\/mirrors.fedoraproject.org\/mirrorlists\/publiclist\/Fedora\/8\">http:\/\/mirrors.fedoraproject.org\/mirrorlists\/publiclist\/Fedora\/9<\/a> again, find a mirror that offers <code>rsync<\/code>, and download the packages as follows:<\/p>\n<p><code>rsync -avrt rsync:\/\/mirror.internode.on.net\/fedora-enchilada\/linux\/updates\/9\/i386\/ --exclude=debug\/ \/var\/www\/html\/yum\/updates\/9\/i386<br \/>\n<\/code><br \/>\nAgain, make sure that you use the slashes (\/) as shown above!<\/p>\n<p>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:<\/p>\n<p><code>crontab -e<br \/>\n23 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<\/code><\/p>\n<p>Our local yum mirror is now ready to be used.<\/p>\n<h3>4. Client Configuration<\/h3>\n<p>To make our Fedora 9 systems use the new local yum repository, we modify <code>\/etc\/yum.conf<\/code> on each Fedora 9 system (you can even do this on the mirror itself if it is a Fedora 9 system). Create new file <code>\/etc\/yum.repos.d\/local.repo<\/code> with these lines:<\/p>\n<p><code>[base-local]<br \/>\nname=Fedora $releasever - $basearch<br \/>\nfailovermethod=priority<br \/>\nbaseurl=http:\/\/mirror.iwayvietnam.com:9090\/yum\/base\/$releasever\/$basearch<br \/>\nenabled=1<br \/>\ngpgcheck=0<br \/>\n<\/code><\/p>\n<p><code>[updates-newley-local]<br \/>\nname=Fedora $releasever - $basearch - Updates Newkey<br \/>\nfailovermethod=priority<br \/>\nbaseurl=http:\/\/mirror.iwayvietnam.com:9090\/yum\/updates\/$releasever\/$basearch.newkey\/<br \/>\nenabled=1<br \/>\ngpgcheck=0<\/code><\/p>\n<p>And finally, disable the existing fedora-updates-newkey by this command:<\/p>\n<p><code>mv \/etc\/yum.repos.d\/fedora-updates-newkey.repo \/etc\/yum.repos.d\/fedora-updates-newkey.repo.bak<\/code><\/p>\n<p>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.<\/p>\n<h3>5. Links<\/h3>\n<ul>\n<li>Fedora: <a href=\"http:\/\/fedoraproject.org\/\">http:\/\/fedoraproject.org<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>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<a class=\"more-link\" href=\"https:\/\/blog.iwayvietnam.com\/tuanta\/2008\/07\/how-to-set-up-a-local-yum-repository-on-fedora-9\/\">Continue reading <span class=\"screen-reader-text\">&#8220;How To Set Up A Local Yum Repository On Fedora 9&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21],"tags":[],"class_list":["post-69","post","type-post","status-publish","format-standard","hentry","category-linux","entry"],"_links":{"self":[{"href":"https:\/\/blog.iwayvietnam.com\/tuanta\/wp-json\/wp\/v2\/posts\/69"}],"collection":[{"href":"https:\/\/blog.iwayvietnam.com\/tuanta\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.iwayvietnam.com\/tuanta\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.iwayvietnam.com\/tuanta\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.iwayvietnam.com\/tuanta\/wp-json\/wp\/v2\/comments?post=69"}],"version-history":[{"count":0,"href":"https:\/\/blog.iwayvietnam.com\/tuanta\/wp-json\/wp\/v2\/posts\/69\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.iwayvietnam.com\/tuanta\/wp-json\/wp\/v2\/media?parent=69"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.iwayvietnam.com\/tuanta\/wp-json\/wp\/v2\/categories?post=69"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.iwayvietnam.com\/tuanta\/wp-json\/wp\/v2\/tags?post=69"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}