- YUM (Yellowdog Updater Modifier) is a utility used for installing packages in Linux distros such as Red-hat, Fedora, and CenOS.
Please find the step by step procedure to create Yum repository and the use of it.
1) RPM utility can also install packages. Why should we use Yum Utility?
Let’s highlight some disadvantages of RPM utility.
- For Installing packages ,RPM command should be executed on the same path where the packages are present, otherwise, it will throw an error “No Such File or directory” as shown in the example below. Please note here packages are present in the DVD-ROM “/media/RHEL_6.2 x86_64 Disc 1/Packages” path.
[root@server1]# pwd / [root@server1]# rpm -ivh createrepo-0.9.8-4.el6.noarch.rpm error: open of createrepo-0.9.8-4.el6.noarch.rpm failed: No such file or directory
Suggested Read: 5 Simple Steps to Recover Root Password of the Linux Server
- When installing the package via RPM, if it has some dependencies it will fail with the warning as shown below. So one by one you need to install all the dependent packages. This is a very tedious task. Here we have executed RPM in the same path where packages are present.
Here we have executed RPM in the same path where packages are present.
[root@server1]# pwd /media/RHEL_6.2 x86_64 Disc 1/Packages [root@server1]# rpm -ivh createrepo-0.9.8-4.el6.noarch.rpm warning: 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
- To overcome these two disadvantages, YUM utility was introduced. When installing a package via Yum, it will check and resolve the dependencies by installing all of them along with the main package as shown below. So you don’t have to install them individually as was the case with RPM utility. Also, you can install package from any path via Yum utility as it knows the exact location of the packages.
[root@server1]# pwd / [root@server1]# yum -y install createrepo.noarch Loaded plugins: product-id, refresh-packagekit, security Resolving Dependencies Dependencies Resolved Installed: createrepo.noarch 0:0.9.8-4.el6 Dependency Installed: deltarpm.x86_64 0:3.5-0.5.20090913git.el6 python-deltarpm.x86_64 0:3.5-0.5.20090913git.el6 Complete!
Please note that you need to create repository before playing with the YUM Command, which is explained in the next step.
2) What are all packages required to install Yum repository?
Initially, you need to use RPM as the only option to install some packages required for Yum Repository.
[root@server1]# rpm -ivh --nodeps createrepo-0.9.8-4.el6.noarch.rpm [root@server1]# rpm -ivh --nodeps deltarpm-3.5-0.5.20090913git.el6.x86_64.rpm [root@server1]# rpm -ivh --nodeps python-deltarpm-3.5-0.5.20090913git.el6.x86_64.rpm [root@server1]# rpm -ivh --nodeps vsftpd-2.2.2-6.el6_0.1.x86_64.rpm
4) What is Yum Repository & How to Create it?
- The exact meaning of repository is “Central location in which data is stored”. Here we will create a directory “yum server” & will copy all the packages from the DVD to it. After copying all the files, we will specify the Repository Location to YUM using “createrepo” command, so that when we run Yum from any path, it knows the location from where it can fetch the package and later will install it.
[root@server1]# mkdir /var/ftp/pub/yumserver [root@server1]# cp -var /media/RHEL_6.2 x86_64 Disc 1/Packages/* /var/ftp/pub/yumserver/ [root@server1]# createrepo -v /var/ftp/pub/yumserver
- We will now have to create a file in “/etc/yum.repos.d/” path with .repo extension using vi editor and modify its content exactly as mentioned below.
[root@server1]# cat /etc/yum.repos.d/yum.repo [YumServer] name="Yum Repository" baseurl=ftp://220.127.116.11/pub/yumserver gpgcheck=0 enabled=1
Please note that IP “18.104.22.168” mentioned in baseurl entry is the server’s Own IP. Hence it can act as a Host server also for other Client servers.
- Now execute the below commands, to bring the Yum utility into effect.
[root@server1]# yum clean all -->To clean yum metadata [root@server1]# yum update all -->To Update yum packages
- Now the Yum status can be checked from “yum repolist” command which displays the repo name and the count of the packages linked to Yum as shown below.
[root@server1]# yum repolist Loaded plugins: product-id, refresh-packagekit, security repo id repo name status YumServer "Yum Repository" 3,596 repolist: 3,596
5) How can the Client Server access the Local Repository present in the Host Server?
If you want the Client machine (Server2) to use the Local repository of the Host Server(Server1). Just copy the “yum.repo” file as it is from Server1 to Server2 on the same path. By doing this there is no need of copying packages in Server2 and will also save the disk space. Please find the steps below to be executed in Server2.
[root@server2]# scp -r 22.214.171.124:/etc/yum.repos.d/yum.repo /etc/yum.repos.d [root@server2]# yum clean all [root@server2]# yum update all [root@server2]# yum repolist
Please note here “126.96.36.199” is the IP of Host Server (Server1).
Now you are good to go to create Yum repository in both Host and Client server.
Please leave your comments and feedback in the comment box if you find it beneficial or in case of any doubts.