NFS YUM repository configuration on Linux|Centos|RHEL

In production environment it might not possible to provide internet to all systems due to company policy or to control internet bandwidth. Installing a package from internet it might be slow because of low internet bandwidth. To overcome this issue we can configure a local yum server and put all the stuffs in the yum repository. Whenever there is a need to install a package it can be installed from the local repository. It saves a lots of internet bandwidth and as well as time.

Topic

  • How to configure YUM repository using NFS on Centos/RHEL|Scientific Linux ?
  • YUM repository configuration on Centos/RHEL|Scientific Linux using NFS


Solution


Prerequisite
  • Bare minimum install of Centos

YUM Server details

Server IP = 192.168.0.101
Host name = server.example.local
OS = CentOS 7.x

YUM Configuration
  • Install the following packages to configure NFS server
#  yum install nfs*

  • Once the packages are installed, enable the NFS service to start during system startup and start NFS services.
# systemctl enable rpcbind
# systemctl enable nfs-server
# systemctl start rpcbind
# systemctl start nfs-server
# systemctl start rpc-statd
# systemctl start nfs-idmapd
# systemctl start nfs-lock

  • Create NFS Share
# mkdir /yumrepository
# vim /etc/exports
# /yumrepository 192.168.1.0/24(rw,sync,no_root_squash)

  • Mount the CentOS installable ISO image in a directory and copy into /yumrepository directory.
# mkdir /tmp/test
# mount -t iso9660 -o loop CentOS-7-x86_64.iso /tmp/test
# mkdir /yumrepository/centos7
# cp -r /tmp/test/* /yumrepository/centos7
# umount /tmp/test
# mount -t iso9660 -o loop CentOS-6.10-x86_64.iso /tmp/test
# mkdir /yumrepository/centos6
# cp -r /tmp/test/* /yumrepository/centos6
# chmod -R 777 /yumrepository
# umount /tmp/test

  • Export the shared directories using following command
# exportfs -a
# exportfs -v</code></pre>


YUM Firewall Configuration
# firewall-cmd --permanent --zone public --add-service mountd
# firewall-cmd --permanent --zone public --add-service rpc-bind
# firewall-cmd --permanent --zone public --add-service nfs
# firewall-cmd --reload


YUM Client Side Configuration
  • Mount nfs share on the client system and add the mounted path into yum repository.
# yum -y install nfs-utils
# systemctl enable rpcbind
# systemctl start rpcbind

  • Mount the NFS share

# showmount -e 192.168.1.101
Export list for 192.168.1.101:
/yumrepository 192.168.1.0/24
# mkdir /yumrepository
# vim /etc/fstab
192.168.1.101:/yumrepository   /yumrepository  nfs   rw,sync,hard,intr   0  0

  • Take backup all the repo files in /etc/yum.repos.d and create a new repo file for local yum configuration.

# cd /etc/yum.repos.d/
# mkdir bkp
# # mv *.repo bkp/

  • Create repo file in /etc/yum.repos.d for centos 7 operating system.

# vim local.repo
[LocalRepo]
name=Local yum server
baseurl=file:///yumrepository/centos7/
enabled=1
gpgcheck=0

  • Create repo file in /etc/yum.repos.d for centos 6 operating system.

[LocalRepo]
# vim local.repo
name=Local yum server
baseurl=file:///yumrepository/centos6/
enabled=1
gpgcheck=0


Test yum server
# yum clean all
Loaded plugins: fastestmirror
Cleaning repos: LocalRepo
Cleaning up list of fastest mirrors
Other repos take up 112 M of disk space (use --verbose for details)

# yum update all
Loaded plugins: fastestmirror
Determining fastest mirrors
LocalRepo                                                                                       | 3.6 kB  00:00:00     
(1/2): LocalRepo/group_gz                                                                       | 155 kB  00:00:00     
(2/2): LocalRepo/primary_db                                                                     | 5.3 MB  00:00:00     
No Match for argument: all
No package all available.
No packages marked for update</code></pre>

 # yum info vsftpd
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Installed Packages
Name        : vsftpd
Arch        : x86_64
Version     : 3.0.2
Release     : 25.el7
Size        : 353 k
Repo        : installed
From repo   : base
Summary     : Very Secure Ftp Daemon
URL         : https://security.appspot.com/vsftpd.html
License     : GPLv2 with exceptions
Description : vsftpd is a Very Secure FTP daemon. It was written completely from
            : scratch.</code></pre>

# yum install vsftpd
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package vsftpd.x86_64 0:3.0.2-10.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=======================================================================================================================
 Package                  Arch                     Version                           Repository                   Size
=======================================================================================================================
Installing:
 vsftpd                   x86_64                   3.0.2-10.el7                      LocalRepo                   167 k

Transaction Summary
=======================================================================================================================
Install  1 Package

Total download size: 167 k
Installed size: 347 k
Is this ok [y/d/N]: y
Downloading packages:
vsftpd-3.0.2-10.el7.x86_64.rpm                                                                  | 167 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : vsftpd-3.0.2-10.el7.x86_64                                                                          1/1 
  Verifying  : vsftpd-3.0.2-10.el7.x86_64                                                                          1/1 

Installed:
  vsftpd.x86_64 0:3.0.2-10.el7                                                                                         

Complete!</code></pre>

# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
repo id                                              repo name                                                   status
LocalRepo                                            Local yum server                                            3,723
repolist: 3,723


You May Also Like

avatar

About the Author: TekFik

TekFik is a technical blogging site helps techies and engineers to solve their day to day issues and also allows everyone to share knowledge and feedback. Please feel free to contact us at tekfik.rd@gmail.com if there is anything.

1 Comment

  1. Terrific article! That is the kind of information that are supposed to be shared around the internet. Disgrace on the search engines for now not positioning this put up higher! Come on over and consult with my website . Thank you =)| а

Leave a Reply

Your email address will not be published. Required fields are marked *