Friday, 5 July 2013

Setup Local YUM Server in Centos

Yellowdog updater, Modified (Yum) is a software package manager that installs, updates and removes packages on RPM-based Linux distributions. Yum uses an online repository by default, but you can also configure it to use a local repository of packages.
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:

[root@ns2 Packages]# mount /dev/cdrom /mnt/
mount: block device /dev/sr0 is write-protected, mounting read-only

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.

[root@ns2 Packages]# rpm -ivh createrepo-0.9.8-4.el6.noarch.rpm
error: Failed dependencies:
    deltarpm is needed by createrepo-0.9.8-4.el6.noarch
    python-deltarpm is needed by createrepo-0.9.8-4.el6.noarch

It shows us the dependency problem. Let us the install missing dependencies first:

[root@ns2 Packages]# rpm -ivh deltarpm-3.5-0.5.20090913git.el6.x86_64.rpm
Preparing...                ########################################### [100%]
   1:deltarpm               ########################################### [100%]
[root@ns2 Packages]# rpm -ivh python-deltarpm-3.5-0.5.20090913git.el6.x86_64.rpm
Preparing...                ########################################### [100%]
   1:python-deltarpm        ########################################### [100%]

Now install the createrepo package:
[root@ns2 Packages]# rpm -ivh createrepo-0.9.8-4.el6.noarch.rpm
Preparing...                ########################################### [100%]
   1:createrepo             ########################################### [100%]


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:

[root@ns2 Packages]# mkdir /var/ftp/pub/localyumserver
[root@ns2 Packages]# cp -ar *.* /var/ftp/pub/localyumserver/

After all packages are copied, create a repo file called localyumserver.repo in /etc/yum.repos.d/ directory.

[root@ns2 Packages]# vi /etc/yum.repos.d/localyumserver.repo

and Type the following entries and save the file

[localyumserver]
name="local yum repository"
baseurl=file:///var/ftp/pub/localyumserver
gpgcheck=0
enabled=1

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:

[root@ns2 Packages]# createrepo -v /var/ftp/pub/localyumserver

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

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:

[localyumserver]
name="local yum repository"
baseurl=ftp://<IP>/pub/localyumserver
gpgcheck=0
enabled=1

No comments:

Post a Comment