Tuesday, May 14, 2013

Configure YUM Server in CentOS 6.x / RHEL 6.x Locally




Configure YUM Server in CentOS 6.x / RHEL 6.x Locally 

Yum uses an online repository by default, but you can also configure it to use a local repository of packages
Let us install a local yum server using CentOS 6.3. The steps provided here are tested in CentOS 6.3. But it will work fine in RHEL 6.x 
In this example the hostname of the server is yum.thelinuxwiki.in and IP Address is192.168.0.10.
Login to your system and Mount the contents of your CentOS 6.3 DVD in the /mnt directory or wherever you want. In the Terminal window, type the following command:
# mount /dev/cdrom1 /mnt/ (Here cdrom1 is my local cdrom device)
Install vsftpd package, so that we can use this as a FTP server to share our repository in the client systems.
Change to the directory where you mounted CentOS DVD. In our example we have mounted the CentOS DVD in /mnt directory.
# cd /mnt/Packages
# rpm -ivh vsftpd-2.2.2-11.el6.i686.rpm

Start the FTP Service:
# service vsftpd start
Install createrepo package if it is not installed. This is package is used to create our local repository.
# rpm -ivh createrepo-0.9.8-5.el6.noarch.rpm
Oops!! It shows us the dependency problem. Let us the install missing dependencies first:
# rpm -ivh deltarpm-3.5-0.5.20090913git.el6.i686.rpm
Then install the another one:
# rpm -ivh python-deltarpm-3.5-0.5.20090913git.el6.i686.rpm
Now install the createrepo package by rpm -ivh createrepo-0.9.8-5.el6.noarch.rpm
Create a folder called localyumserver (You can use your own) in /var/ftp/pub directory to save all the packages from the CentOS DVD. Copy all the files in the Packages folder from the DVD to/var/ftp/pub/localyumserver folder:
# mkdir /var/ftp/pub/localyumserver
# cp -ar *.* /var/ftp/pub/localyumserver
It will take a while to copy all the packages in the DVD. Please be patient. After all packages are copied, create a repo file called localyumserver.repo in /etc/yum.repos.d/ directory.
# vim /etc/yum.repos.d/localyumserver.repo


[localyumserver]
        name="My Local Repository"
        baseurl=file:///var/ftp/pub/localyumserver
       #baseurl=ftp://192.168.0.10/pub/localyumserver
        gpgcheck=0
        enabled=1


Type the following entries and save the file 
Where,
[localyumserver] ==> Name of the Local Repository.
comment ==> Information about the Repository.
baseurl ==> Path of the Repository (i.e where we had copied the contents from CentOS DVD)
gpgcheck ==> Authentication of the Repository, which is disabled in our case.
Now it is time to create our repository. Enter the following command in the Terminal:
# createrepo -v /var/ftp/pub/localyumserver
Now the local YUM repository creation process will begin.
Note: Delete or rename all the other repo files except the newly created repo file i.e in our example it is localyumserver.repo
Next update the repository:
  • yum clean all
  • yum update
You’re done now.
Client side configuration:
Create a repo file in your client system as mentioned above in the /etc/yum.repos.d/ directory and remove or rename the existing repositories. Then modify the baseurl as mentioned below:

# vim /etc/yum.repos.d/localyumserver.repo


[localyumserver]
        name="My Local Repository"
        baseurl=ftp://192.168.0.10/pub/localyumserver
        gpgcheck=0
        enabled=1


Thats it. Start using Yum. Enjoy!!


[root@localhost ~]# vi /etc/yum/pluginconf.d/fastestmirror.conf
 to enable=1 to change enable=0

NOTE:list all repositories set up on your system

You can list all repositories set up on your system by a  yum repolist all


enabled Either '1' or '0'. This tells yum whether or not use this repository.

gpgcheck Either '1' or '0'. This tells yum whether or not it should perform a GPG signature check on the packages gotten from this repository.