NFS Configuration On Linux RHEL
NFS Configuration On Linux RHEL
NFS Configuration On Linux RHEL
NFS (Network File System) is used to sharing the files and folders between linux to unix and
unix to linux machines,NFS was developed by Sun Mycro Systems in the year 1984.
Features:
1. Every one can access same data.
2. Reduce Storage Cost and Easy to use.
3. Centralized Management of Files.
4. Secured with Firewalls and Kerberos.
NFS Configuration :
Service Name
: nfs
Packages
: i) nfs-utils
ii) nfs-utils-lib
Configuration File
: /etc/exports
It is main Configuration file of NFS, define all exported files
and folders in this path.
: /etc/sysconfig/nfs
It is also Configuration file of NFS to controle on which port rpc
and other services are listening.
status files
/etc/exports
/var/lib/nfs/rmtab
/var/lib/nfs/xtab
/etc/hosts.allow
/etc/hosts.deny
Daemons
rpc.portmap
rpc.mountd
rpc.nfsd
rpc.statd
rpc.lockd
rpc.rquotad
To setup NFS Server, we have at least two Linux Machines. one is NFS Server and another one
is NFS Client
NFS Server
: 192.168.x.xx
NFS Client
: 192.168.x.xx
Sever Side
To check the nfs RPM is installed or Not
# rpm -qa nfs-utils
# rpm -qa nfs-utils-lib
Install the NFS Packages using Yum
# yum install nfs-utils nfs-utils-lib -y
(or)
#yum install nfs* -y
To create directory.
# mkdir /oracle
To export directory.
#vim /etc/exports
/oracle
*(rw,sync ,no_root_squash ,no_all_squash)
/oracle
192.168.0.0/24(ro,sync)
:wq
Note
rw
Writable permission to shared folder
ro
-- Read-only permission to shared folder
sync
Synchronize shared directory
no_root_squash
Enable root privilege
no_all_squash
Enable users authority
#exportfs -r (Re exports the nfs share)
#service nfs restart
# chkconfig nfs --list
nfs
0:off 1:off 2:on 3:on 4:on 5:on 6:off
# exportfs -v
/oracle
<world>(rw,wdelay,no_root_squash,no_subtree_check)
#
#chkconfig nfs on
# showmount -e 192.168.0.17
# exportfs -av
exporting 192.168.0.75:/oracle
exporting *:/kick
exporting *:/var/ftp/pub
# exportfs -u
/oracle
192.168.0.75
/var/ftp/pub <world>
/kick
<world>
#
Step2 : To findout which files or directories are exported from the server
# showmount -e 192.168.6.136
Export list for 192.168.6.136:
/oracle *
#
Step 3: Create a Directory
# mkdir /data
#mount
# df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/sda2 ext4 18G 2.4G 15G 15% /
tmpfs
tmpfs 495M 224K 495M 1% /dev/shm
/dev/sda1 ext4 291M 33M 243M 12% /boot
/dev/sr0 iso9660 3.5G 3.5G 0 100% /mnt
192.168.6.136:/oracle
nfs 18G 2.4G 15G 15% /data
#
192.168.6.134:/oracle
:wq
#mount -a
#cd /data
#ls
/data
nfs
defaults
0 0
If the NFS file system is hard mounted, the NFS daemons will try repeatedly to contact the
server. The NFS daemon retries will not time out, will affect system performance, and you
cannot interrupt them
If you just mount a file system without specifying hard or soft, the default is a hard mount.
Hard mounts are preferable because of the stateless nature of NFS.
If a client sends an I/O request to the server (such as an ls -la), and the server gets rebooted,
in client machine the process will keep on running.
This preserves data transfers in the event of a server failure
ex:
Hard Mount (Permanent mounting):[root@sadeek~]# mount -o rw,hard,intr 172.28.50.109/nfs /mnt
[root@sadeek ~]# vim /etc/fstab
172.28.50.109:/nfs
/mnt
nfs Defaults 0 0
:wq!
We can check nfs share with the help of below mention command.
[root@sushee ~]# mount a
In another word ..soft mount will allow automatic unmount if the filesystem is idle for a
specified time period
ex:
[FAILED]
[FAILED]
[FAILED]
[ OK ]
[ OK ]
[ OK ]
[ OK ]
[ OK ]
scniario2
Client side
[root@localhost ~]# showmount -e 192.168.6.136
clnt_create: RPC: Port mapper failure - Unable to receive: errno 113 (No route to host)
#
solution
server side :
1.Go to server side
2. #iptables -L
3.#iptables -F
or
# service iptables stop
# chkconfig iptables off
# mount -v
desktop75.example.com:/java on /mnt type nfs
(rw,vers=4,addr=192.168.0.75,clientaddr=192.168.0.62)