{"id":115,"date":"2012-01-25T21:46:36","date_gmt":"2012-01-25T21:46:36","guid":{"rendered":"http:\/\/liniks.com\/?p=115"},"modified":"2012-01-25T21:46:36","modified_gmt":"2012-01-25T21:46:36","slug":"how-to-configure-mrepo-to-mirror-red-hats-repositories-for-multiple-versions-and-architectures","status":"publish","type":"post","link":"https:\/\/liniks.com\/?p=115","title":{"rendered":"How to configure mrepo to mirror Red Hat&#8217;s repositories for multiple versions and architectures!"},"content":{"rendered":"<p>Have you ever needed\/wanted to set up a single Red Hat Enterprise Linux server to sync all you servers to for package updates? 32 and 64 bit machines pointing to the same server? Different distros on the same server? Here&#8217;s how&#8230;<\/p>\n<p>This tutorial is for setting up mrepo only. It&#8217;s the first part of setting up a Spacewalk instance to mirror RHN. If you&#8217;ve already completed this, go on to Part Two&#8230;(coming soon)<\/p>\n<p>&nbsp;<\/p>\n<p>Part One: Setting up a mrepo server to mirror RHN\u2019s Satellite repositories.<\/p>\n<p><!--more-->\ufeff\ufeffBase &#8211;<\/p>\n<p>The repo server should be running RHEL\/CentOS 5.X. RHEL 6\/CentOS6 is not compatible with these instructions, as they have changes the way the RHPL scripts work in 6, and thus breaks Spacewalk on 6. This may be fixed in the future, but as of early 2012, it\u2019s not yet a practical option.<\/p>\n<p>You\u2019ll need a modest server, probably something with at least a 2Ghz processor and 2Gb RAM. My setup uses a (Virtual) Xeon X5650 @ 2.67GHz and 4GB RAM on a VMWare instance. Honestly, it\u2019s probably overkill, but it\u2019s good enough. Depending on how many different distros and versions you plan on mirroring, space could be a problem. Plan on 6Gb per version, 10Gb if you plan on hosting the DVD ISOs as well. If you have 32 and 64 bit versions of RHEL 3,4,5 and 6, that\u2019s ~50Gb, and ~75Gb if you want DVDs. If you want separate CentOS repos, add more. (But Centos can be configured to pull RHEL repos, as well\u2026so it\u2019s not necessary. Suse\/Debian\/Fedora will need their own repos though.)<\/p>\n<p>In my setup, I have lvm\u2019d disks totaling 80GB (lvm makes it easier to add space later by adding disk slices to the Volume Group\/Logical Volume.) I have that 80GB mounted to \/var\/www- which is where I will keep the served repo cache and sources.<\/p>\n<p>Configuration \u2013<\/p>\n<p>I am assuming you have your server configured to run apache, and have any security questions addressed as your policy dictates. IPTables\/other firewall configured to allow traffic, network connectivity, SELinux configured to taste. I can\u2019t offer help configuring those, as those settings are all highly dependent on you particular environment and installation.<\/p>\n<p>You\u2019ll need to attach to the RHN or CentOS repos and install the following packages:<\/p>\n<p>Createrepo-0.4.5 or better. Current RH-sanctioned release is createrepo-0.4.11-3.el5<\/p>\n<p>Mrepo-0.8 or better. Current RH-sanctioned version is mrepo-0.8.7-1.el5.rf.<\/p>\n<p>Spacewalk. Current RH-sanctioned version is 1.6, but it is not available in the normal RHEL channels- it is available in a repository on RH\u2019s servers, though- <a href=\"http:\/\/spacewalk.redhat.com\/yum\/\">http:\/\/spacewalk.redhat.com\/yum\/<\/a><\/p>\n<p>(You\u2019ll need to add it to your current repos. An install guide is available at <a href=\"https:\/\/fedorahosted.org\/spacewalk\/wiki\/HowToInstall\">https:\/\/fedorahosted.org\/spacewalk\/wiki\/HowToInstall<\/a> )<\/p>\n<p>You\u2019ll also need a database. Spacewalk supports Oracle(10g, 11g, or the free XE) or PostgreSQL. \u00a0It\u2019s your call on which to use.\u00a0 Oracle costs real money; Oracle XE is free, but severely restricted, which makes a production repo less practical, but not impossible; and PostgreSQL is free, but mildly limited in capabilities. RH warns that monitoring is not likely to work in Spacewalk with Postgre, there may be other functions that don\u2019t work perfectly, too, but if your goal is just a production package repository, it\u2019s a good free alternative to Oracle. (I may provide another post just to discuss these differences\u2026)<\/p>\n<p>&nbsp;<\/p>\n<p>Procedure for setting up repositories and sync \u2013<\/p>\n<p>Here\u2019s where you\u2019re going to have to think this through. You\u2019re going to need to change and create a few files.<\/p>\n<p>Files to edit:<\/p>\n<p>\/etc\/mrepo.conf\u00a0\u00a0 (First step)<\/p>\n<p>\/etc\/httpd\/conf\/httpd.conf (Second step)<\/p>\n<p>&nbsp;<\/p>\n<p>Files to create:<\/p>\n<p>Source Directory (Third step)<\/p>\n<p>Repodata Directory (Third step)<\/p>\n<p>SystemIDs and UUID (Fourth step)<\/p>\n<p>Mrepo.conf.d \u00a0config files (Fifth step)<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><em><strong>1.)<\/strong><\/em> Let us assume, for the sake of this exercise, you are going to host 4 repos- 32 and 64 bit versions of RHEL4 and RHEL5. There will be one mrepo.conf file, two mrepo.cond.d files (one for each\u00a0 distro- RHEL4 and RHEL5), and four each for repodata and source directories (2 RHEL4\u2019s and 2 RHEL5\u2019s, 32 and 64bit versions, respectively). For every different distro, you\u2019ll need one conf.d file, and for each architecture, you\u2019ll need one repo and src directory. So for a set up with 3 distros (RHEL4,5 &amp; 6) and 3 Archs (386,x64, and Alpha), your 1,2,and 4 each becomes 1,3,and 9 each, capisce? First thing is to edit the \/etc\/mrepo.conf file.<\/p>\n<p>Here\u2019s mine:<\/p>\n<h5><em>[main]<\/em><\/h5>\n<h5><em>srcdir = \/var\/www\/mrepo_sources<\/em><\/h5>\n<h5><em>wwwdir = \/var\/www\/mrepo<\/em><\/h5>\n<h5><em>confdir = \/etc\/mrepo.conf.d<\/em><\/h5>\n<h5><em>arch = i386 x86_64<\/em><\/h5>\n<h5><em>rhnlogin = RHNUsername:RHNPassword<\/em><\/h5>\n<p>&nbsp;<\/p>\n<p>Note the location of the src and www dirs. You can call these anything you want, and put them anywhere, so long as you have space and remember what you called them. Note next the arch= line. I have my server set to sync to i386 and x86_64. There is a pretty wide assortment of options here if you have interesting architectures.<\/p>\n<p>Config other options as fits you network, but this is all the info that\u2019s necessary. Adding an email addy to the mailto line is a good idea, too.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>2.)<\/strong> Next we need to edit 3 lines in the \/etc\/httpd\/conf\/httpd.conf file.<\/p>\n<h5><em>#<\/em><\/h5>\n<h5><em># ServerName gives the name and port that the server uses to identify itself.<\/em><\/h5>\n<h5><em># This can often be determined automatically, but we recommend you specify<\/em><\/h5>\n<h5><em># it explicitly to prevent problems during startup.<\/em><\/h5>\n<h5><em>#<\/em><\/h5>\n<h5><em># If this is not set to valid DNS name for your host, server-generated<\/em><\/h5>\n<h5><em># redirections will not work.\u00a0 See also the UseCanonicalName directive.<\/em><\/h5>\n<h5><em>#<\/em><\/h5>\n<h5><em># If your host doesn&#8217;t have a registered DNS name, enter its IP address here.<\/em><\/h5>\n<h5><em># You will have to access it by its address anyway, and this will make<\/em><\/h5>\n<h5><em># redirections work in a sensible way.<\/em><\/h5>\n<h5><em>#<\/em><\/h5>\n<h5><em>ServerName <span style=\"text-decoration: line-through;\">hostname.domain.com<\/span>:80<\/em> <span style=\"color: #000000;\"><strong>&lt;&lt;THIS LINE, make it your FQDN, so apache starts cleanly<\/strong><\/span><\/h5>\n<h5>\u2026couple lines below\u2026<\/h5>\n<h5><em># DocumentRoot: The directory out of which you will serve your<\/em><\/h5>\n<h5><em># documents. By default, all requests are taken from this directory, but<\/em><\/h5>\n<h5><em># symbolic links and aliases may be used to point to other locations.<\/em><\/h5>\n<h5><em>#<\/em><\/h5>\n<h5><em>DocumentRoot &#8220;\/var\/www\/mrepo&#8221; <\/em><strong>&lt;&lt;THIS LINE, make it match your wwwdir in mrepo.conf <\/strong><\/h5>\n<h5>\u2026couple lines below\u2026<\/h5>\n<h5><em>#<\/em><\/h5>\n<h5><em># This should be changed to whatever you set DocumentRoot to.<\/em><\/h5>\n<h5><em>#<\/em><\/h5>\n<h5><em>&lt;Directory &#8220;\/var\/www\/mrepo&#8221;&gt; <\/em> <strong>&lt;&lt;THIS LINE, make it match your wwwdir in mrepo.conf<\/strong><\/h5>\n<p><em> <\/em><\/p>\n<p><em> <\/em><\/p>\n<p>&nbsp;<\/p>\n<p><strong><em>3.)<\/em> <\/strong> Next we need to set up our repo and source directories. The naming on these is important. The directories and mrepo.conf.d files (that we\u2019ll create later) have to match. In our case we have four of each. In my case I\u2019ve named them:<\/p>\n<p>rhel4es-i386<\/p>\n<p>rhel4es-x86_64<\/p>\n<p>rhel5s-i386<\/p>\n<p>rhel5s-x86_64<\/p>\n<p>These are empty directories. In the case of our example her, you need each of those four in A.)the srcdir in the first line of your mrepo.conf, and B.) in the wwwdir of said file.<\/p>\n<p>&nbsp;<\/p>\n<p>Redhat requires a UUID on your machine to sync up, and you\u2019ll need to generate one.<\/p>\n<p>&nbsp;<\/p>\n<h5><em>[root@hostname]# uuidgen<\/em><\/h5>\n<h5><em>12345678-123a-1abc-a123-1ab2c34567d8<\/em><\/h5>\n<h5><em>[root@hostname]#<\/em><\/h5>\n<p>&nbsp;<\/p>\n<h5>Now create \/etc\/sysconfig\/rhn\/up2date-uuid (yes, that\u2019s up2date\u2026.its a legacy file. Don\u2019t worry about it)<\/h5>\n<h5><em>[root@hostname]# vi \/etc\/sysconfig\/rhn\/up2date-uuid<\/em><\/h5>\n<h5><em>[root@hostname]# cat \/etc\/sysconfig\/rhn\/up2date-uuid<\/em><\/h5>\n<h5><em>uuid[comment]=Universally Unique ID for this server<\/em><\/h5>\n<h5><em>rhnuuid=12345678-123a-1abc-a123-1ab2c34567d8 <\/em><strong>&lt;&lt;This needs to match the uuidgen output above&#8230; <\/strong><\/h5>\n<p><em> <\/em><\/p>\n<p><strong><em>4.) <\/em><\/strong> Now we need to generate a RHN systemid for each of these directories we just made, so that Red Hat can sync each directory to a separate repo. Note the release names are specific to Red Hat naming conventions\u2026and that each line is either 32 or 64 in arch and in folder name.<\/p>\n<p>&nbsp;<\/p>\n<h5><em>gensystemid -u NAME -p PASS &#8211;release=4ES &#8211;arch=i386 \/var\/www\/mrepo\/rhel4es-i386\/<\/em><\/h5>\n<h5><em>gensystemid -u NAME -p PASS &#8211;release=4ES &#8211;arch=x86_64 \/var\/www\/mrepo\/rhel4es-x86_64\/<\/em><\/h5>\n<h5><em>gensystemid -u NAME -p PASS &#8211;release=5Server &#8211;arch=x86_64 \/var\/www\/mrepo\/rhel5s-x86_64\/<\/em><\/h5>\n<h5><em>gensystemid -u NAME -p PASS &#8211;release=5Server &#8211;arch=i386 \/var\/www\/mrepo\/rhel5s-i386<\/em><\/h5>\n<p>&nbsp;<\/p>\n<p>And we need to copy those system id\u2019s to the source dir, as well. You can modify and run this block\u2026 (make sure you are in the wwwdir to run this, in this case \/var\/www\/mrepo\u2026)<\/p>\n<h5><em>for i in rhel4es-i386 rhel5s-i386 rhel4es-x86_64 rhel5s_x86-64; do cp \/var\/www\/mrepo\/$i\/systemid \/var\/www\/mrepo_sources\/$i\/.; done<\/em><\/h5>\n<p>&nbsp;<\/p>\n<p><strong><em>5.)<\/em><\/strong> Lastly, we need to set up the \/etc\/mrepo.conf.d\/conf files.<\/p>\n<h5><em>for i in rhel4es rhel5s; do touch \/etc\/mrepo.conf.d\/$i.conf; done<\/em><\/h5>\n<p>Next, to populate those files. You can find samples in \/usr\/share\/doc\/mrepo*\/dists\/. You\u2019ll need to set your architecture here- you can have multiple archs on the same line, separated by a space.<\/p>\n<p>Example:<\/p>\n<h5><em>[root@hostname]#cat \/etc\/mrepo.conf.d\/rhel5s.conf<\/em><\/h5>\n<h5><em>[rhel5s]<\/em><\/h5>\n<h5><em>name = Red Hat Enterprise Server $release ($arch)<\/em><\/h5>\n<h5><em>release = 5<\/em><\/h5>\n<h5><em>#arch = i386 x86_64 ia64 ppc s390 s390x<\/em><\/h5>\n<h5><em>arch = i386 x86_64<\/em><\/h5>\n<h5><em>metadata = repomd repoview<\/em><\/h5>\n<h5><em>### Additional repositories<\/em><\/h5>\n<h5><em>updates = rhns:\/\/\/rhel-$arch-server-5<\/em><\/h5>\n<h5><em>vt = rhns:\/\/\/rhel-$arch-server-$repo-5<\/em><\/h5>\n<h5><em>supplementary = rhns:\/\/\/rhel-$arch-server-$repo-5<\/em><\/h5>\n<h5><em>fastrack = rhns:\/\/\/rhel-$arch-server-$repo-5<\/em><\/h5>\n<h5><em>hts = rhns:\/\/\/rhel-$arch-server-$repo-5<\/em><\/h5>\n<h5><em>rhn-tools = rhns:\/\/\/$repo-rhel-$arch-server-5<\/em><\/h5>\n<h5><em>### RPMforge repository<\/em><\/h5>\n<h5><em>rpmforge = rsync:\/\/apt.sw.be\/pub\/freshrpms\/pub\/dag\/redhat\/el$release\/en\/$arch\/RPMS.dag\/<\/em><\/h5>\n<h5><em>rpmforge = ftp:\/\/apt.sw.be\/pub\/dag\/pub\/redhat\/el$release\/en\/$arch\/RPMS.dag\/<\/em><\/h5>\n<h5><em>rpmforge = http:\/\/apt.sw.be\/redhat\/el$release\/en\/$arch\/RPMS.dag\/<\/em><\/h5>\n<p>Here is where you can add additional repos, if you want to add aftermarket ones.<\/p>\n<p>&nbsp;<\/p>\n<p>6.)\u00a0\u00a0\u00a0\u00a0 Now it\u2019s time to turn it up and sync. Start apache and mrepo, and set them to automatically start, then sync. This will take a very long time. If you\u2019re doing this from a VM, you might be best to log into the console, and start the sync from there, so you can still use the machine. If you\u2019re using a terminal, you can backgroub the process by appending a \u201c&amp;\u201d to the end of the sync command (an `fg` command brings it back to the front if you need it.)<\/p>\n<p>&nbsp;<\/p>\n<h5><em>service httpd start<\/em><\/h5>\n<h5><em>service mrepo start<\/em><\/h5>\n<h5><em>chkconfig httpd on<\/em><\/h5>\n<h5><em>chkconfig mrepo on<\/em><\/h5>\n<h5><em>mrepo \u2013guvv<\/em><\/h5>\n<p>Now your repo is complete! On to Spacewalk Setup\u2026<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Have you ever needed\/wanted to set up a single Red Hat Enterprise Linux server to sync all you servers to for package updates? 32 and 64 bit machines pointing to the same server? Different distros on the same server? Here&#8217;s how&#8230; This tutorial is for setting up mrepo only. It&#8217;s the first part of setting &hellip; <a href=\"https:\/\/liniks.com\/?p=115\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">How to configure mrepo to mirror Red Hat&#8217;s repositories for multiple versions and architectures!<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,5],"tags":[15,16,14,17,13,12,18],"class_list":["post-115","post","type-post","status-publish","format-standard","hentry","category-linux","category-tech","tag-32bit","tag-64bit","tag-mrepo","tag-red-hat","tag-repo","tag-repositories","tag-rhel"],"_links":{"self":[{"href":"https:\/\/liniks.com\/index.php?rest_route=\/wp\/v2\/posts\/115","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/liniks.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/liniks.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/liniks.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/liniks.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=115"}],"version-history":[{"count":5,"href":"https:\/\/liniks.com\/index.php?rest_route=\/wp\/v2\/posts\/115\/revisions"}],"predecessor-version":[{"id":146,"href":"https:\/\/liniks.com\/index.php?rest_route=\/wp\/v2\/posts\/115\/revisions\/146"}],"wp:attachment":[{"href":"https:\/\/liniks.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=115"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/liniks.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=115"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/liniks.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=115"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}