Search This Blog

Friday, January 8, 2016

RHEL6 - Creating Your Own Repository

1) Mount the CD or ISO Image to Directory.
# mkdir /mnt
# mount -o loop /path/to/linux.iso /mnt


# mkdir /repo                                           To Create an directory, that can be used for repostory

 Copy all the Packages to Path /repo

# cp $MOUNTPATH/Packages/* /repo/

2. Run ‘createrepo’ against “/repo”- creates subdirectory “repodata”and various DB files to serve packages to ‘yum’clients.

Install createrepo---
# yum install -y createrepo                       # To Make sure the createrepo RPM PAckage is installed.

Configure RHEL Server for Package Repository. (query all packages and generates a SQline DB and ancillary file beneath: “repodata”dir.
# createrepo /repo

[root@server2 /]# createrepo /repo
Spawning worker 0 with 3819 pkgs
Workers Finished
Gathering worker results
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete

[root@server2 repo]# ls -l|grep repodata
drwxr-xr-x. 2 root root     4096 Jan  5 15:49 repodata

[root@server2 repodata]# ls -lrt
total 16300
-rw-r--r--. 1 root root 1845250 Jan  5 15:49 3b4f8b463bc7c0d384625a3364af70dc09986debce44d5716e8f0a8f72a936c3-primary.xml.gz
-rw-r--r--. 1 root root 3597907 Jan  5 15:49 3029240afdf8f069da417237c414806ec4ad5448e27dc03ca0f6156115bf2ba2-filelists.xml.gz
-rw-r--r--. 1 root root 1919345 Jan  5 15:49 278dd3d68f830da5ae077a04ad211a7e464ad19947676276a7f612c7bac754f3-other.xml.gz
-rw-r--r--. 1 root root 1783488 Jan  5 15:49 09e30422a6e99e25e106343f7bfbb77dbcf503dc38d82c0757a0cb41c15e3bda-other.sqlite.bz2
-rw-r--r--. 1 root root 4114796 Jan  5 15:49 a87efc0008a72bb63230df95d31d6198e391a9f97fff2caa3f82d51e68d8d7e0-filelists.sqlite.bz2
-rw-r--r--. 1 root root 3414128 Jan  5 15:49 42de40a2866031f9b08a1690dc1f1b571065b17fa8191b7bd1c4aa243cf255a8-primary.sqlite.bz2
-rw-r--r--. 1 root root    3017 Jan  5 15:49 repomd.xml

3. Configure Yum Client Configuration:
Main Configuraiton file is /etc/yum.conf
[root@server2 /]# cat /etc/yum.conf
[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=3

#  This is the default, if you make this bigger yum won't see if the metadata
# is newer on the remote and so you'll "gain" the bandwidth of not having to
# download the new metadata and "pay" for it by yum not having correct
# information.
#  It is esp. important, to have correct metadata, for distributions like
# Fedora which don't keep old packages around. If you don't like this checking
# interupting your command line usage, it's much better to have something
# manually check the metadata once an hour (yum-updatesd will do this).
# metadata_expire=90m

# PUT YOUR REPOS HERE OR IN separate files named file.repo
# in /etc/yum.repos.d

# vim /etc/yum.repos.d/myrepo.repo
[myrepo]
name=myrepo
baseurl=file:///repo
gpgcheck=0

[root@server2 /]# yum repolist
Loaded plugins: product-id, refresh-packagekit, rhnplugin, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
This system is not registered with RHN Classic or RHN Satellite.
You can use rhn_register to register.
RHN Satellite or RHN Classic support will be disabled.
repo id                              repo name                    status
myrepo                               myrepo                       3,819
repolist: 3,819


No comments:

Post a Comment