search
top

How To Create a CentOS Repository with mrepo

If you are a shop of any size and are building and maintaining CentOS servers, you know the need to maintain a repository with extras, updates and such. In this post we will cover how to build a repository on your network for building and maintaining CentOS.

Install mrepo

sudo yum -y install mrepo

Edit /etc/mrepo.conf and add set the directories

Create mrepo config file in /etc/mrepo.conf.d

### Configuration file for mrepo

### The [main] section allows to override mrepo’s default settings
### The mrepo-example.conf gives an overview of all the possible settings
[main]
srcdir = /var/mrepo
wwwdir = /var/www/mrepo
confdir = /etc/mrepo.conf.d
arch = i386 x86_64
mailto = root@localhost
smtp-server = localhost

### Any other section is considered a definition for a distribution
### You can put distribution sections in /etc/mrepo.conf.d/
### Examples can be found in the documentation at:
###     /usr/share/doc/mrepo-0.8.7/dists/.

Create directory in /var/mrepo
ex Cent6Server-x86_64

Copy the install iso’s to the new directory and create the sub-directories for the updates, epel and extras.

cd /var/mrepo/Cent6Server-x86_64

mkdir updates extras epel

Create the config in /etc/mrepo.conf.d/
ex: centos6.conf

vi centos6.conf

[Cent6Server]
name = CentOS Server $release ($arch)
release = 6
arch = x86_64
metadata = repomd yum repoview

### ISO images
#CentOS-6.6-x86_64-bin-DVD?.iso
iso = CentOS-$release.?-$arch-bin-DVD?.iso

### Additional repositories
epel = http://dl.fedoraproject.org/pub/epel/${release}Server/$arch
updates = http://mirror.centos.org/centos/$release/updates/$arch/Packages/
extras = http://mirror.centos.org/centos/$release/extras/$arch/Packages/

Save the changes and restart mrepo service so the iso gets mounted.

service mrepo restart

You should now see it mounted

Now run

mrepo -g -u -vvv Cent6Server

Add the new repo to the /etc/cron.daily task. In this case I created a script called updaterepos

cd /etc/cron.daily

vi updaterepos

#!/bin/bash
TZ=’America/New_York’
TIMEZONE=”America/New_York”
ZONE=”America/New_York”
export TZ
/bin/logger -t repo “Starting Cent6Server syncs”
/usr/bin/mrepo -fqug Cent6Server
/bin/logger -t repo “Ended Cent6Server syncs”

If you add additional repositories follow the steps above and after the files and config’s are done, execute the following.

mrepo –unmount
service mrepo restart

Check and see if the isos are mounted
mount

Run mrepo -g -u -vvv NewServer

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

top