HOW TO CONFIGURE YUM REPOSITORY PACKAGE MANAGER IN RHEL 7/CENTOS 7
Introduction
In this article we are going to discuss on how to configure local yum repository package manager on RHEL 7.
YUM stands for Yellowpage Updater Modifier is for rpm package supportable Linux distros/Operating Systems ex: RHEL 5/6/7 and so on. It is used to install, uninstall, update, list available packages, list installed packages and search the rpm packages from the database. The main purpose of yum is to install rpm packages easily with all required dependencies and convienent way of package management for administrators. YUM was first introduced on RHEL 5 then available on all later versions.
Bydefault you can use yum to install packages by downloading from Internet but also you can configure local yum repository package manager server by using RHEL Installation DVD or by placing the packages on Remote Servers like FTP, HTTP. In this article we are goint to learn how to configure local YUM Repository Package Manager using FTP Server i.e. Vsftpd Server.
So let’s have a look at installation and configuration steps of local YUM Repository Package Manager.
My Sceanrio for YUM Repository:
Server Side :
IP Address – 192.168.1.100
OS – RHEL 7
Client Side :
IP Address : 192.168.1.101
OS – RHEL 6.8
Follow the below steps to Configure Local YUM Repository Package Manager :
Step : 1 Install Required Packages
First we have to install all required packages to configure YUM Repository Package Manager. So for that we need to install below packages :
yum.xxx.xxx.xx.rpm
yum-utils.xxx.xxx.xx.rpm
createrepo.xxx.xxx.xx.rpm
vsftpd.xxx.xxx.xx.rpm
You can found all below packages from RHEL Installation media, so mount the Installation DVD and install all packages by using below command.
[root@localhost packages]# rpm -ivh yum-3.2.29-73.el6.centos.noarch.rpm Preparing... ########################################### [100%] 1:yum ########################################### [100%] [root@localhost packages]# rpm -ivh yum-utils-1.1.30-37.el6.noarch.rpm Preparing... ########################################### [100%] 1:yum-utils ########################################### [100%] [root@localhost packages]# rpm -ivh vsftpd-2.2.2-21.el6.x86_64.rpm Preparing... ########################################### [100%] 1:vsftpd ########################################### [100%] [root@localhost pub]# rpm -ivh createrepo-0.9.9-24.el6.noarch.rpm Preparing... ########################################### [100%] 1:createrepo ########################################### [100%]
You can confirm the package installation by using below command.
[root@localhost ~]# rpm -qa | grep yum yum-3.2.29-73.el6.centos.noarch yum-utils-1.1.30-37.el6.noarch [root@localhost ~]# rpm -qa | grep vsftpd vsftpd-2.2.2-21.el6.x86_64
Step : 2 Configure the Vsftpd Server
As we are going to configure local yum repository package manager with FTP Server i.e Vsftps Server, So before configure the YUM we need to prepare the Vsftpf Server.
For that just edit the main configuration file of Vsftpd Server i.e. (/etc/vsftpd.conf) and search for below lines and comment-out by removing the #.
anonymous_enable=YES anon_upload_enable=YES anon_mkdir_write_enable=YES idle_session_timeout=600 data_connection_timeout=120
After configure the Vsftpd Server mount the Installation media and copy all rpm packages to Vsftpd default directory i.e. /var/ftp/pub.
[root@localhost Packages]# mount /dev/cdrom /media # Mount the RHEL Installation media in /media Directory [root@localhost Packages]#cd /media/CentOS-6.8-x86_64-bin-DVD1/Packages # Change the Directory to Packages [root@localhost Packages]# cp * -rfv /var/ftp/pub/ # Copy all the rpm Packages to FTP default directory
Then start the Vsftpd server by using below command.
[root@localhost ~]# /etc/init.d/vsftpd start Starting vsftpd for vsftpd: [ OK ]
Step : 3 Configure YUM Repository from Server Side
Main configuration file of yum repository is yum.conf which is located at /etc directory i.e. /etc/yum.conf. Here in this file we can see that we have to put our .repo files on /etc/yum.repos.d directortory.
Note : .repo file is the Repository file of YUM Repositiry where we have to mention the path of rpm Package location. Here we have configure vsftpd server to keep the rpm packages.
[root@localhost ~]# cat /etc/yum.conf # See the yum.conf file just for Reference [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=5 bugtracker_url=http://bugs.centos.org/set_project.php?project_id=19&ref=http://bugs.centos.org/bug_report_page.php?category=y$ distroverpkg=centos-release # 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
Now go to /etc/yum.repos.d directory where we can found some default .repo files. So here we have to move all default .repo file to some other directory and craete a new .repo file using touch command.
[root@localhost ~]# cd /etc/yum.repos.d/ # Change the Directory to /etc/yum.respo.d [root@localhost yum.repos.d]# ls CentOS-Base.repo CentOS-fasttrack.repo CentOS-Vault.repo # Default .repo files CentOS-Debuginfo.repo CentOS-Media.repo # Here I created a Directory to move Sample .repo Files [root@localhost yum.repos.d]# mkdir /data [root@localhost yum.repos.d]# mv CentOS* /data/ [root@localhost yum.repos.d]# touch file.repo # Create a new .repo file
Now edit the file.repo YUM Repository file and copy all below lines in that and then save the file.
[root@localhost yum.repos.d]# nano file.repo [base] name=base baseurl=ftp://192.168.1.100/pub/ enabled=1 gpgcheck=0
After configure the .repo file generate database for yum by using createrepo command as shown below. This will create a .xml file and store all the package information it that and will get the from that xml file when user try to install any package.
[root@localhost ~]# createrepo /var/ftp/pub/ # Createing Database file for YUM Repository
Spawning worker 0 with 3204 pkgs
Workers Finished
Gathering worker results
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
Then restart the Vsftpd Server by using below command to take effect.
[root@localhost pub]# /etc/init.d/vsftpd restart Shutting down vsftpd: [ OK ] Starting vsftpd for vsftpd: [ OK ]
Now we are done with all required configuration. Now we can list all available packages in yum database by running below command.
[root@localhost ~]# yum list # List all available packages
Step : 4 Configure YUM Repository from Client Side
Install Required Packages
We need to install required packages to connect with YUM Repository server to get the Packages Information. So Install below packages :
yum.xxx.xxx.xx.rpm
yum-utils.xxx.xxx.xx.rpm
[root@localhost packages]# rpm -ivh yum-3.2.29-73.el6.centos.noarch.rpm Preparing... ########################################### [100%] 1:yum ########################################### [100%] [root@localhost packages]# rpm -ivh yum-utils-1.1.30-37.el6.noarch.rpm Preparing... ########################################### [100%] 1:yum-utils ########################################### [100%]
Configure the .repo file
Then go to /etc/yum.repos.d directory and move default sample files to a directory as we did on server configuration (on Step : 3)and create a new .repo file. Follow the steps below.
[root@localhost ~]# cd /etc/yum.repos.d/ # Change the Directory to /etc/yum.respo.d [root@localhost yum.repos.d]# ls CentOS-Base.repo CentOS-fasttrack.repo CentOS-Vault.repo # Default .repo files CentOS-Debuginfo.repo CentOS-Media.repo # Here I created a Directory to move Sample .repo Files [root@localhost yum.repos.d]# mkdir /data [root@localhost yum.repos.d]# mv CentOS* /data/ [root@localhost yum.repos.d]# touch file.repo # Create a new .repo file
After create a .repo file just edit it and copy below lines and then save the file.
[root@localhost yum.repos.d]# nano file.repo [base] name=base baseurl=ftp://192.168.1.100/pub/ enabled=1 gpgcheck=0
Now we are done with YUM Repository client configuration. Now just use yum command to install a package for testing purpose. Follow the below steps.
[root@localhost ~]# yum -y install dhcp Loaded plugins: fastestmirror, refresh-packagekit, security Setting up Install Process Loading mirror speeds from cached hostfile Resolving Dependencies --> Running transaction check ---> Package dhcp.x86_64 12:4.1.1-51.P1.el6.centos will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: dhcp x86_64 12:4.1.1-51.P1.el6.centos base 823 k Transaction Summary ================================================================================ Install 1 Package(s) Total download size: 823 k Installed size: 1.9 M Downloading Packages: dhcp-4.1.1-51.P1.el6.centos.x86_64.rpm | 823 kB 00:00 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : 12:dhcp-4.1.1-51.P1.el6.centos.x86_64 1/1 Verifying : 12:dhcp-4.1.1-51.P1.el6.centos.x86_64 1/1 Installed: dhcp.x86_64 12:4.1.1-51.P1.el6.centos Complete!
So This is how we can configure YUM Repository Package Manager in RHEL 7/ CentOS 7.
If you found this article useful then Like Us, Subscribe our News Letter, Or if you have any thing to say then feel free to comment on comment box below.