Setting up a Local YUM Repository

Setting up the YUM Server

Setting up a local YUM repository provides many benefits in situations like where hosts in a network does not have access to Internet . Also , installing  a package from a local YUM repository is faster because of low latency as compared to Internet .  The YUM repository can have access to Internet so that the repository is always updated with latest software updates . Please find below steps to setup a local YUM repository. 

1. Create a directory to be used for setting up a repository

                                           # mkdir  /var/www/html/rhelimages                                                               

2.   Dump contents of RHEL DVD to the above created directory

                           # cp  -r  /media/cdrom/*    /var/www/html/rhelimages/                                                   

3. Install the createrepo package if not already installed 
                                           # rpm -q createrepo                                                                                     
                                           # yum install createrepo                                                                                
4.  Now , setup the repository . We can use the -g option to enable group listing with yum command. 

# createrepo -g                                                                                                                                           /var/www/html/rhelimages/repodata/8afad1febf2d8844a235a9ab1aa5f15c9cec1219b9d01060d4794435cf59dffe-comps-rhel6-Server.xml /var/www/html/rhelimages/Packages/                                                                  

With this we are done setting up a  local YUM Repository . To access this repository from other machines on Network , we need to setup either a Web Server or FTP Server. For our case , we will setup a web server using apache .

5. Install httpd package if not already installed and start the service

                                           # rpm -q httpd                                                                                              
                                           # yum install httpd                                                                                         
                                           # service httpd restart                                                                                    

Configuring client machines to access Local YUM Repository

1.  Open any yum repo file under /etc/yum.repos.d/  directory and add the following entry as shown below

$ cat /etc/yum.repos.d/redhat.repo
name=Red Hat Enterprise Linux $releasever Beta - $basearch - Source
#e.g baseurl=  < YUM Repository IP Address>/rhelimages 


2.  Now test whether access to the repository is working fine with YUM commands.

       $yum grouplist 
       $ yum install vim   

If the above commands are working fine , then we did a successfull setup of YUM repository. Start installing your packages now.


Popular posts from this blog

PSSH : Parallel SSH to execute commands on a number of hosts

How to add check_http as a service in Nagios Monitoring using NRPE

Configuring Nagios to monitor services using NRPE