Creating Local YUM Repository in Red Hat /CentOS 7
In my previous article, we have seen YUM Repository Configuration in RHEL 6 using with RHEL ISO. In this article, I am going to configure Local YUM repo in RHEL/CentOS 7 using FTP service on the server side and client side.
Recommended Read: More Information about Yum Server
Also Read : Red Hat 7 Installation and Configuration
What is YUM Repository ?
Yellowdog Updater Modifier(YUM) is a software package manager that install, upgrade and remove the packages on .rpm based Linux distros. Yum makes it easier to maintain a group of machines without manually updating each one using rpm.
YUM repository is a warehouse of Linux software (RPM packages ). RPM (Red hat Package manager) is software file and it enables quick and easy software installation on .rpm based Linux distributions like Red Hat Linux / CentOS and Fedora.
What is the Use of Local YUM repository?
Local YUM repositories are helpful when:
1. Your system is not having access to the internet to get public repository (official repo) and want to use yum packages for installation, as YUM, can resolve/install all the dependencies of .rpm packages.
2. You can up to date keep the stable version of. rpm packages of the local yum repository to ensure all the installation get the same package.
After successful local yum repository creation, can use the same repo for local network Linux clients with FTP or HTTP protocol.
YUM configuration Steps:
Requirements for YUM Repository:
1. mount point with minimum free space of 6GB to copy the DVD content. Example: /yum-local and 6GB free space on disk.
2. RHEL 7 / CENTOS7 DVD/Source Image(ISO)
1. Create a repo directory and dump the ISO image content into the mount directory
|[[email protected] ~]# mkdir -p /yum-local|
Creating a Directory to mount the ISO/DVD. Note: this is not required, you can mount any directory that you want.
|[[email protected] ~]# mkdir -p /mnt/isodump|
A) : Insert the RHEL/CentOS 7 DVD and mount on the system, then verify the media mount status with below command.
|[[email protected] ~]# mount | grep /dev/sr0|
|/dev/sr0 on /run/media/root/CentOS 7 x86_64 type iso9660 (ro,nosuid,nodev,relatime,uid=0,gid=0,iocharset=utf8,mode=0400,dmode=0500,uhelper=udisks2)|
B) : Mount the DVD or ISO on /mnt/isodump directory and check the status with below commands:
Mounting DVD on directory /mnt/isodump
|[[email protected] ~]# mount /dev/sr0 /mnt/isodump (or) mount /dev/cdrom /mnt/isodump|
|mount: /dev/sr0 is write-protected, mounting read-only|
Verify the content of the DVD or ISO on the mounted directory.
|[[email protected] ~]# ls -l /mnt/isodump/|
Use any one method to mount the Linux ISO/DVD into your mount point.
Dump the ISO files into the directory.
If you’re using ISO image: ISO file is copying into a specified directory (/mnt/isodump)
|[[email protected] ~]# mount -t iso9660 -o loop /dev/sr0 /mnt/isodump|
2. Copy the DVD/ISO content into a repo directory that you want to use to locate the all the .rpm packages.
copy the DVD/ISO data from mount point to local directory.
|[[email protected] ~]# rsync -av /mnt/isodump/ /yum-local/ |
|[[email protected] ~]# cp -rvf /mnt/isodump/ /yum-local/|
After coping the entire data, now it’s time create a repo file in /etc/yum.repos.d/ to discover the .rpm packages from the location. repo file name should be end with .repo, otherwize yum service don’t recognize the yum repository.
Here I’m going to creating a repo file in the name of yum-local.repo and adding the below information to configure local yum repository.
This is for Local Repo configuration file.
|[[email protected] mnt]# vim /etc/yum.repos.d/yum-local.repo|
name=yum-local repository # Name of the repository
baseurl=file:///yum-local # It will resolve the packages from /yum-local directory.
enable=1 # This means it will enable the repository.
gpgcheck=1 # This will enable to check the gpgkey file. if want to disable, simply use gpgcheck=0
gpgkey=file:////yum-local/RPM-GPG-KEY-CentOS-7 # This is public GPG key for security concerns.
If you want to use FTP service to push the packages over the network to yum client systems, you need to install vsftpd rpm packages then start/enable the service,
FTP Installation and Initial Configuration
|[[email protected] ~]# yum install vsftpd|
Enable the vsftpd service to start while booting the system.
|[[email protected] ~]# systemctl enable vsftpd|
Starting ftp service
|[[email protected] ~]# systemctl start vsftpd|
Go to vsftpd configuration file and edit /etc/vsftpd/vsftpd.conf file to map the local directory to use yum repo.
add below line to the end of the configuration file: This syntax will change the default FTP browsable directory(pub) to the local directory(/yum-local)
Yum server settings to use local ftp service:
baseurl=ftp://172.16.3.101 # (or) ftp://localhost : It will use the FTP service to download the packages over the local network
Client Side: just verify the installed yum packages on the client system, if it is not installed, go to the FTP server address on the web browser and download the yum-utils then install it.
After installing the yum-utils packages on client system, now add the configuration script into /etc/yum.repos.d/”ANYNAME”.repo.
baseurl=ftp://172.16.3.101 # ftp or httpd address of the rpm packages location It will use the FTP service to download the packages over the local network
gpgcheck=0 ; if you want to enable gpgcheck make the value 0 to 1.