Sunday, 20 October 2019

How to Create Local YUM repository on CentOS 7



YUM (YellowDog Updater Modified) is a package management tool for RPM based Linux system that helps to install, uninstall, and update packages local and over the network. YUM resolve all dependency and install the package with all dependencies.

Local YUM repository is used for package installation from a local repository without internet connection.

This article describes How to create Local YUM repository on CentOS 7 using a CentOS 7 ISO.

Step 1. Copy ISO Contents to Local Directory: Run the following commands to mount and copy ISO content into Apache document directory to access the RPM packages by YUM:

[root@linuxcnf ~]# mkdir -p /home/local_repos
[root@linuxcnf ~]# mount /dev/cdrom /mnt/
mount: /dev/sr0 is write-protected, mounting read-only
[root@linuxcnf ~]# cp -arv /mnt/Packages/* /home/local_repos/
‘/mnt/Packages/389-ds-base-1.3.9.1-10.el7.x86_64.rpm’ -> ‘/home/local_repos/389-ds-base-1.3.9.1-10.el7.x86_64.rpm’
.........................
‘/mnt/Packages/zziplib-0.13.62-11.el7.x86_64.rpm’ -> ‘/home/local_repos/zziplib-0.13.62-11.el7.x86_64.rpm’
[root@linuxcnf ~]#

Step 2. Configure the Local Repository: Run the following commands to install createrepo package from the copied ISO contents. createrepo package and its dependency can be installed using ISO contents. createrepo tool helps to create the rpm meta-structure repository:

[root@linuxcnf ~]# cd /mnt/Packages/
[root@linuxcnf Packages]# rpm -ivh createrepo-0.9.9-28.el7.noarch.rpm deltarpm-3.6-3.el7.x86_64.rpm libxml2-python-2.9.1-6.el7_2.3.x86_64.rpm python-deltarpm-3.6-3.el7.x86_64.rpm
Preparing...                          ################################# [100%]
Updating / installing...
   1:deltarpm-3.6-3.el7               ################################# [ 25%]
   2:python-deltarpm-3.6-3.el7        ################################# [ 50%]
   3:libxml2-python-2.9.1-6.el7_2.3   ################################# [ 75%]
   4:createrepo-0.9.9-28.el7          ################################# [100%]
[root@linuxcnf Packages]#

[root@linuxcnf ~]# createrepo /home/local_repos
Spawning worker 0 with 4067 pkgs
Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
[root@linuxcnf ~]#

Step 3. Create a Repo file: Move all the existing repos configuration file to other location. Create a repository configuration file under /etc/yum.repos.d/ and put the following contents:

[root@linuxcnf ~]# mv /etc/yum.repos.d/* /opt/
[root@linuxcnf ~]# vi /etc/yum.repos.d/local_repos.repo
[CentOS7-Local]
name=Local YUM Repository
baseurl=file:///home/local_repos
enabled=1
gpgcheck=0
[root@linuxcnf ~]#

Step 4. Verification: Run the following command to validate the installation:

[root@linuxcnf ~]# yum clean all
Loaded plugins: fastestmirror
Cleaning repos: CentOS7-Local
Cleaning up list of fastest mirrors
Other repos take up 90 M of disk space (use --verbose for details)
[root@linuxcnf ~]#

[root@linuxcnf ~]# yum repolist
Loaded plugins: fastestmirror
…………………..
repo id                                                                      repo name                                                                            status
CentOS7-Local                                                                Local YUM Repository                                                                 4,067
repolist: 4,067
[root@linuxcnf ~]#

Done!!! CentOS Local Repositories is configured.

No comments:

Post a Comment