1. download latest mrepo from Github since these have already the needed patches:
https://github.com/dagwieers/mrepo
2. Download rhpl from one of dag repo mirrors. rhpl was dropped in rhel6. Dag has made a feature request to mrepo on Aug 1st 2011 to remove rhpl from mrepo so that the extra pkg would no longer be needed. But until then you still need the rhpl
ftp://ftp.univie.ac.at/systems/linux/dag/redhat/el6/en/x86_64/dag/RPMS/rhpl-0.221-2.el6.rf.x86_64.rpm
3. Untar / unzip the latest mrepo and install it (you can also first build an rpm of it by running make rpm. But then you will need the necessary build rpms installed)
# tar xzf dagwieers-mrepo-736c07a.tar.gz
# cd dagwieers-mrepo-736c07a
# make install
install -Dp -m0755 gensystemid /usr/bin/gensystemid
install -Dp -m0755 mrepo /usr/bin/mrepo
...
install -Dp -m0644 config/mrepo.logrotate /etc/logrotate.d/mrepo
#
4. Generate the /etc/sysconfig/rhn/up2date-uuid file if you don't have one yet
# UUID=$(uuidgen)
# /bin/echo -e "uuid[comment]=Universally Unique ID for this server\nrhnuuid=$UUID" > /etc/sysconfig/rhn/up2date-uuid
5. Edit the /etc/mrepo file for your needs. Mine looks like this:
# cat /etc/mrepo.conf
[main]
srcdir = /export/mrepo
wwwdir = /export/mrepo
confdir = /etc/mrepo.conf.d
arch = x86_64
mailto = xxxxxxx
smtp-server = localhost
rhnlogin = xxx:xxx
6. Create a conf file for each rhel version you want to download in /etc/mrepo.conf.d/. I only need the rhel6 x86_64 updates. So this is how mine looks:
# cat /etc/mrepo.conf.d/rhel6-x86_64.conf
[rhel6-x86_64]
name = Red Hat Server ($arch)
release = 6
arch = x86_64
metadata = repomd yum repoview
updates = rhns:///rhel-$arch-server-$release
#fastrack = rhns:///rhel-$arch-server-fastrack-$release
#rhn-tools = rhns:///rhn-tools-rhel-$arch-server-$release
#optional = rhns:///rhel-$arch-server-optional-$release
supplementary = rhns:///rhel-$arch-server-supplementary-$release
7. Remember that for each repo you download, you need a systemid file in the mrepo folder for that repo. So my mrepo dir is /export/mrepo (mrepo.conf) and the server config is rhel6-x68_64 (rhel6-x86_64.conf). So the systemid file should go into the folder /export/mrepo/rhel6-x68_64.
# cp /etc/sysconfig/rhn/systemid /export/mrepo/rhel6-x86_64/
8. My system has a systemid file because it was already registered with rhn. If you want to download other version / arch repo's on the same system, you can use gensystemid to create one
# gensystemid -r 6Server -a i386 /export/mrepo/rhel6-i386
9. All done. Now run mrepo
# mrepo -uvv
Verbosity set to level 2
Using configfile /etc/mrepo.conf
Setting option confdir in section [main] to: /etc/mrepo.conf.d
Setting option srcdir in section [main] to: /export/mrepo
Setting option wwwdir in section [main] to: /export/mrepo
Setting option mailto in section [main] to: xxxxxx
Setting option smtp-server in section [main] to: localhost
Setting option arch in section [main] to: x86_64
Setting option rhnlogin in section [main] to: xxx:xxx
rhel6-x86_64: Updating Red Hat Server (x86_64)
rhel6-x86_64: Mirror packages from rhns:///rhel-x86_64-server-supplementary-6 to /export/mrepo/rhel6-x86_64/supplementary
rhel6-x86_64: Repository supplementary changed (new: 28, removed: 1)
rhel6-x86_64: Mirror packages from rhns:///rhel-x86_64-server-6 to /export/mrepo/rhel6-x86_64/updates
...
10. mrepo has of course more useful options then just to download the updates from rhn. Have a look at the documentataion if you want for example want to include iso files or want run createrepo after the repos have been downloaded or if you want to download other repos then those from rhn.
I hope this quick how-to helps in getting you started with mrepo on rhel6.