Linux Repository Management using mrepo

Description:

mrepo is used for  managing  YUM and APT  (creating and updating) repositories from ISO image and it also downloads updates and extra packages from third party repositories. This utility also can be used for  network Linux installation.

 

Used path for mrepo:

prefix = /usr
sysconfdir = /etc
bindir = /usr/bin
sbindir = /usr/sbin
libdir = /usr/lib
datadir = /usr/share
mandir = /usr/share/man
localstatedir = /var
httpddir = $(sysconfdir)/httpd/conf.d
initrddir = $(sysconfdir)/rc.d/init.d
cachedir = /var/cache/mrepo
htmldir = /usr/share/mrepo/html
srcdir = /var/mrepo
wwwdir = /var/www/mrepo

1. Creating CentOS-6 repository:

PRE-REQUISITIES:

1.Edit /etc/hosts and /etc/sysconfig/network
Vi /etc/hosts
192.168.0.33 mrepo.unixadmin.in mrepo

Vi /etc/sysconfig/network
HOSTNAME=mrepo.uinxadmin.in

2.Stop iptables and network manager

# Chkconfig iptables off
# Chkconfig NetworkManager off

3.Disable selinux: edit the selinux configuration file as
Vi /etc/selinux/config
Selinux =disabled
(Change enforcing to disabled)

Depending on what repositories you want to generate, you can install
a combination of these packages:

tool package provides
"""" """"""" """"""""
genbasedir apt provides apt support
yum-arch yum provides yum support
createrepo createrepo provides repomd support (new yum, new apt)

Depending on what kind of sources you want to mirror, you can install a combination of these packages:

tool provides
"""" """"""""
rsync provides rsync:// access
mirrordir provides ftp:// and mc:// access
lftp provides ftp://, http://, sftp:// fish://
up2date provides rhn:// and rhns:// access

 Installation & configuration :

1. Before installing the mrepo , install epel packages and lftp required for the mrepo installation using the following command

# rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
# yum –y install lftp

2. Next, Install mrepo

# yum -y install mrepo

3. Edit the mrepo configuration file as

vi /etc/mrepo.conf
[main]
srcdir = /var/mrepo
wwwdir = /var/www/mrepo
confdir = /etc/mrepo.conf.d
arch = i386 x86_64 (modified from i386 to i386 x86_64 )
mailto = root@localhost
smtp-server = localhost

And then save the changes.

4. Create directory in /var/mrepo as,
# Cd /var/mrepo
# mkdir /var/mrepo/Cent6Server-x86_64

Then create sub directories under /var/mrepo/Cent6Server-x86_64

# mkdir /var/mrepo/Cent6Server-x86_64/updates
# mkdir /var/mrepo/Cent6Server-x86_64/extras
# mkdir /var/mrepo/Cent6Server-x86_64/epel

5. Copy the ISO CentOS-6.8-x86_64-bin-DVD1.iso under the directory Cent6Server-x86_64

6. Create mrepo config file in /etc/mrepo.conf.d as
# Cd /etc/mrepo.conf.d/
Then , edit config file using
# Vi centos6.conf

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

### ISO images
iso = CentOS-6.8-x86_64-bin-DVD1.iso
### Additional repositories
epel = http://epel.excellmedia.net/6/x86_64/
extras = http://mirror.centos.org/centos-6/6.10/extras/x86_64/Packages/
updates = http://mirror.centos.org/centos-6/6.10/updates/x86_64/Packages/

Then, Save and exit

7. Now, run mrepo with no actions to see if the ISO files are mounted and all your configuration options have been used:
mrepo -vv

8. Then, start the mrepo service using command
# service mrepo start

9.Then run mrepo to update the repositories:

mrepo -uvv

Then, generate the mrepo repositories by doing:

mrepo -g -u -vvv Cent6Server

2.Creating CentOS 7 repository:

Configuration :

1.Create directory under /var/mrepo as,
# Cd /var/mrepo
# mkdir /var/mrepo/Cent7Server-x86_64
Then create sub directories under /var/mrepo/Cent6Server-x86_64

# mkdir /var/mrepo/Cent7Server-x86_64/updates
# mkdir /var/mrepo/Cent7Server-x86_64/extras
# mkdir /var/mrepo/Cent7Server-x86_64/epel

2. Copy the ISO CentOS-7-x86_64-DVD-1804.iso under the directory Cent7Server-x86_64

3. Create mrepo config file in /etc/mrepo.conf.d as
# Cd /etc/mrepo.conf.d/
Then , edit config file using
# Vi centos7.conf
[Cent7Server]
name = CentOS Server $release ($arch)
release = 7
arch = x86_64
metadata = repomd yum repoview
### ISO images
iso = CentOS-7-x86_64-DVD-1804.iso
### Additional repositories
epel = http://epel.excellmedia.net/7/x86_64/
extras=http://mirror.centos.org/centos7/7.5.1804/extras/x86_64/Packages/
updates=http://mirror.centos.org/centos7/7.5.1804/updates/x86_64/Packages/

then, Save and exit.

4. Now, run mrepo with no actions to see if the ISO files are mounted and all your configuration options have been used:
mrepo -vv

5. Then, start the mrepo service using command
# service mrepo start

6.Then run mrepo to update the repositories:

mrepo -uvv

Then, generate the mrepo repositories by doing:

mrepo -g -u -vvv Cent7Server

3. Creating Puppet repo

CentOS-6:

1. Create a directory under /var /mrepo
# mkdir /var/mrepo/puppet6Server-x86_64

2. Create a file under /etc/mrepo.conf.d/ and add the following ,
Vi /etc/mrepo.conf.d/puppet6.conf
[puppet6Server]
name = CentOS Server $release ($arch)
release = 6
arch = x86_64
metadata = repomd yum repoview
### URL
Baseurl = http://yum.puppetlabs.com/el/6/products/x86_64/

And save the changes and exit.

3. Then run the command,
# mrepo –g –u –vvv puppet6Server
And then the packages starts downloading and hence repository will be created.

 CentOS-7:

1. Create a directory under /var /mrepo
# mkdir /var/mrepo/puppet7Server-x86_64

2. Create a file under /etc/mrepo.conf.d/ and add the following ,
Vi /etc/mrepo.conf.d/puppet7.conf
[puppet7Server]
name = CentOS Server $release ($arch)
release = 7
arch = x86_64
metadata = repomd yum repoview
### URL
Baseurl = http://yum.puppetlabs.com/el/7/products/x86_64/

And save the changes and exit.

8. Then, start the mrepo service using command
# service mrepo start

9.Then run mrepo to update the repositories:

mrepo -uvv

Then, generate the mrepo repositories by doing:

mrepo -g -u -vvv Puppet7Server

If you’re removing distributions from the mrepo.conf file and you want to remove the ISOs to gain diskspace. Remember that Linux will not release diskspace for files that are still accessed (like a loop-mounted ISO file). You’re best bet is to first unmount the ISOs:

mrepo -vv --umount

then remove or comment the distributions and mount again:

mrepo -vv

When you’re adding new distributions, it’s sufficient to just run mrepo again. It will automatically mount everything that is not already mounted. You can always remount/reset by doing:

mrepo -vv --remount

Additional information:

## Default architecture is i386
arch = i386

## The location of the example .shtml files
htmldir = /usr/share/mrepo/html

## The location of the ISO images and RPM files
srcdir = /var/mrepo

## The location of the generated repositories
wwwdir = /var/www/mrepo

## The location of the dist config files
confdir = /etc/mrepo.conf.d

## The location of the cachedir (used by yum)
cachedir = /var/cache/mrepo

## The location of the lockdir
lockdir = /var/cache/mrepo

## The location of the (latest) pxelinux bootcode
pxelinux = /usr/lib/syslinux/pxelinux.0

## The location of the Yam TFTP files
tftpdir = /tftpboot/mrepo

## The location of the logfile
logfile = /var/log/mrepo.log

## The location of the different executables
createrepocmd = /usr/bin/createrepo
genbasedircmd = /usr/bin/genbasedir
hardlinkcmd = /usr/sbin/hardlink
hardlinkpluscmd = /usr/bin/hardlink++
lftpcmd = /usr/bin/lftp
mirrordircmd = /usr/bin/mirrordir
mountcmd = /bin/mount
repoviewcmd = /usr/bin/repoview
rhngetcmd = /usr/bin/rhnget
rsynccmd = /usr/bin/rsync
umountcmd = /bin/umount
yumarchcmd = /usr/bin/yum-arch

## What repository metadata do you want to generate ?
#metadata = apt repomd yum
metadata = repomd

## Your username and password for RHN channel subscriptions
#rhnlogin = username:password
rhnlogin =

## Specify the required proxy settings
#no_proxy = localhost,mrepo,webserver
#ftp_proxy = http://10.1.2.3:8080
#http_proxy = http://10.1.2.3:8080
#https_proxy = http://10.1.2.3:8080
no_proxy =
ftp_proxy =
http_proxy =
https_proxy =

## You can have mrepo send out report mails
# mailto = user@domain.com user2@domain2.com
mailto =
mailfrom = mrepo@hostname
smtp-server = localhost

## Default output (put this to yes if you want mrepo to be silent by default)
quiet = no

## Hardlink files in the srcdir before ending Yam
hardlink = no

## Do you want to share the ISO files in wwwdir ?
shareiso = yes

## Limit the bandwidth used by lftp (in B/secs)
lftp-bandwidth-limit =

## Clean up packages that are not on the sending side ?
lftp-cleanup = yes

## Exclude debuginfo or source packages ?
lftp-exclude-debug = yes
lftp-exclude-srpm = yes

## Add extra options to lftp (eg. -d for debugging lftp)
lftp-options =

## Add extra commands to lftp (eg. set dns:fatal-timeout 5)
lftp-commands =

## Add extra options to lftp mirror command
lftp-mirror-options = -c -P

## Set the I/O timeout in seconds
lftp-timeout =

## Clean up packages that are not on the sending side ?
mirrordir-cleanup = yes

## Exclude debuginfo or source packages ?
mirrordir-exclude-debug = yes
mirrordir-exclude-srpm = yes

## Add extra options to mirrordir
mirrordir-options =

## Delete packages that are no longer in the repo
reposync-cleanup = yes

## Only download the latest packages
reposync-newest-only = no

## Add extra options to reposync
reposync-options =

## Set RHN login username:password
rhnlogin =

## Add extra options to rhnget
rhnget-options =

## Clean up packages that are not on the sending side ?
rhnget-cleanup = yes

## Download older versions of a certain package ?
rhnget-download-all = no

## Limit the bandwidth used by rsync in kilobytes per seconds
rsync-bandwidth-limit =

## Clean up packages that are not on the sending side ?
rsync-cleanup = yes

## Exclude debuginfo or source packages ?
rsync-exclude-debug = yes
rsync-exclude-srpm = yes

## Add extra options to rsync
rsync-options = -rtHL –partial

## Set the I/O timeout in seconds
rsync-timeout =

## Add extra options to createrepo
createrepo-options = -p

## Add extra options to repoview
repoview-options =

Cron: Schedule for auto update the repository.

### Enable this if you want mrepo to daily synchronize
### your distributions and repositories at 2:30am.
#30 2 * * * root /usr/bin/mrepo -q -ug

Be the first to comment on "Linux Repository Management using mrepo"

Leave a comment

Your email address will not be published.


*