CONFIGURE NFS MOUNT IN LINUX

CONFIGURE NFS MOUNT IN LINUX

SOURCE SERVER:

Use yum to install nfs packages

[root@dpprod oracle]# yum install nfs-utils nfs-utils-lib -y
Loaded plugins: langpacks, ulninfo
ol7_UEKR5                                                                         | 3.0 kB  00:00:00
ol7_latest                                                                        | 3.6 kB  00:00:00
(1/4): ol7_UEKR5/x86_64/updateinfo                                                | 170 kB  00:00:00
(2/4): ol7_latest/x86_64/updateinfo                                               | 3.3 MB  00:00:02
(3/4): ol7_UEKR5/x86_64/primary_db                                                |  32 MB  00:00:06
(4/4): ol7_latest/x86_64/primary_db                                               |  36 MB  00:00:07
No package nfs-utils-lib available.
Resolving Dependencies
--> Running transaction check
---> Package nfs-utils.x86_64 1:1.3.0-0.66.0.1.el7 will be updated
---> Package nfs-utils.x86_64 1:1.3.0-0.68.0.1.el7.2 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

=========================================================================================================
 Package              Arch              Version                              Repository             Size
=========================================================================================================
Updating:
 nfs-utils            x86_64            1:1.3.0-0.68.0.1.el7.2               ol7_latest            413 k

Transaction Summary
=========================================================================================================
Upgrade  1 Package

Total size: 413 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : 1:nfs-utils-1.3.0-0.68.0.1.el7.2.x86_64                                               1/2
  Cleanup    : 1:nfs-utils-1.3.0-0.66.0.1.el7.x86_64                                                 2/2
  Verifying  : 1:nfs-utils-1.3.0-0.68.0.1.el7.2.x86_64                                               1/2
  Verifying  : 1:nfs-utils-1.3.0-0.66.0.1.el7.x86_64                                                 2/2

Updated:
  nfs-utils.x86_64 1:1.3.0-0.68.0.1.el7.2

Complete!

Start and enable symbolic link for rpcbind and nfs-server using systemctl

[root@dpprod oracle]# systemctl start rpcbind nfs-server
[root@dpprod oracle]# systemctl enable rpcbind nfs-server
Created symlink from /etc/systemd/system/multi-user.target.wants/nfs-server.service to /usr/lib/systemd/system/nfs-server.service.

Create a directory for the nfs share mount

[root@dpprod oracle]# mkdir /oranfs

Go to exports file and add the entries of the nfs

[root@dpprod oracle]# vi /etc/exports
[oracle@dpprod bin]$ cat /etc/exports
/oranfs 192.168.56.123(rw,sync,no_root_squash,no_subtree_check)

Use exportfs to provide access to a remote server for network share

[root@dpprod oracle]# exportfs -a

Add the required services using firewall-cmd and specify the zone

[root@dpprod oracle]# firewall-cmd --permanent --zone=public --add-service=nfs
success
[root@dpprod oracle]# firewall-cmd --permanent --zone=public --add-service=mountd
success
[root@dpprod oracle]# firewall-cmd --permanent --zone=public --add-service=rpc-bind
success
[root@dpprod oracle]# firewall-cmd --reload
success

Restart the nfs service on source

[root@dpprod oracle]# systemctl restart nfs

REMOTE SERVER:

Install nfs packages in another server where nfs needs to be used

[root@dptest oracle]# yum install nfs-utils nfs-utils-lib -y

Create same directory like source server

[root@dptest oracle]# mkdir /oranfs

Check the mounted the nfs and perform an rpc call to remote server

[root@dptest oracle]# showmount -e 192.168.56.122
Export list for 192.168.56.122:
/nfs 192.168.56.123
[root@dptest oracle]# rpcinfo -p 192.168.56.122
   program vers proto   port  service
    100000    4   tcp    111  portmapper
    100000    3   tcp    111  portmapper
    100000    2   tcp    111  portmapper
    100000    4   udp    111  portmapper
    100000    3   udp    111  portmapper
    100000    2   udp    111  portmapper
    100024    1   udp  30784  status
    100024    1   tcp  59105  status
    100005    1   udp  20048  mountd
    100005    1   tcp  20048  mountd
    100005    2   udp  20048  mountd
    100005    2   tcp  20048  mountd
    100005    3   udp  20048  mountd
    100005    3   tcp  20048  mountd
    100003    3   tcp   2049  nfs
    100003    4   tcp   2049  nfs
    100227    3   tcp   2049  nfs_acl
    100003    3   udp   2049  nfs
    100227    3   udp   2049  nfs_acl
    100021    1   udp  26992  nlockmgr
    100021    3   udp  26992  nlockmgr
    100021    4   udp  26992  nlockmgr
    100021    1   tcp  31163  nlockmgr
    100021    3   tcp  31163  nlockmgr
    100021    4   tcp  31163  nlockmgr

Mount the nfs in remote server

[root@dptest oracle]# mount 192.168.56.122:/oranfs /oranfs

Check if the mount reflect on remote server

[root@dptest oracle]# df -h
Filesystem           Size  Used Avail Use% Mounted on
devtmpfs             1.8G     0  1.8G   0% /dev
tmpfs                1.8G  928M  911M  51% /dev/shm
tmpfs                1.8G  9.3M  1.8G   1% /run
tmpfs                1.8G     0  1.8G   0% /sys/fs/cgroup
/dev/sda2             15G  9.0G  5.8G  61% /
/dev/sda5             14G  6.0G  8.0G  43% /apps01
/dev/sda1             20G  8.4G   12G  44% /u01
tmpfs                368M   12K  368M   1% /run/user/42
tmpfs                368M     0  368M   0% /run/user/54321
192.168.56.233:/nfs   15G  8.1G  6.7G  55% /oranfs

Go to the nfs directory and create a test file to check if the files are shared between source and remote server

[root@dptest oracle]# cd /oranfs
[root@dptest nfs]# touch test
[root@dpprod oranfs]# ls
test

To make permanent changes, set the fstab file with below entry

[root@dpprod oranfs]# vi /etc/fstab
[oracle@dpprod bin]$ cat /etc/fstab

#
# /etc/fstab
# Created by anaconda on Tue Oct 19 20:35:23 2021
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=7009654a-4fbd-42fe-b619-daf80783afea /                       xfs     defaults        0 0
UUID=feb6d49d-e21f-49d0-83fc-8ebcb316c55d /apps01                 xfs     defaults        0 0
UUID=9393fa23-58ff-4ceb-91eb-24231b650835 /u01                    xfs     defaults        0 0
UUID=45b89753-7082-4dc2-8480-a07517909f4e swap                    swap    defaults        0 0
192.168.56.122:/oranfs /oranfs nfs auto,noatime,nolock,bg,nfsvers=3,intr,tcp,actimeo=1800 0 0

Whenever there is a server reboot, use the below command to mount the nfs directory using root user

[oracle@dpprod bin]$ su
Password:
[root@dpprod bin]# mount -a

Leave a Reply

Discover more from XscalibaL

Subscribe now to keep reading and get access to the full archive.

Continue reading