Вы находитесь на странице: 1из 12

NFS Configuration on Linux RHEL

NFS (NETWORK FILE SYSTEM)

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 :

NFS Port Number

: 2049 (for NFS)


: 111 Port Map

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

Scripts and commands


/etc/rc.d/init.d/nfs
nfstat
showmount
rpcinfo
exportfs

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>
#

Client Side Configuration


Step 1: Install NFS Packages & start NFS service
Install NFS Packages using yum command
(I)
# yum install nfs-utils nfs-utils-lib -y
(II)
# yum install showmount rpcbind -y
# service nfs start
# chkconfig nfs on

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

Step 4: Mount a directory from server to client


# mount -t nfs 192.168.6.136:/oracle /data

====> (Temporary Mount )

#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
#

Step 5: To check the directory


# cd /data
# ls
abc.txt
# cat abc.txt
this is test file for NFS
#
For permanent
#Vi /etc/fstab

====> (Permanent Mount )

192.168.6.134:/oracle
:wq
#mount -a
#cd /data
#ls

/data

nfs

defaults

0 0

HARD MOUNT AND SOFT MOUNT


HARD mount :(Permonent Mounting)

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

SOFT Mount : (Temperory Mounting)


A soft mount allows the client to stop trying an operation after a period of time. If the NFS
server goes down at the time of data transfer , it will alert and the process will do
down.Thsi may cause the data corruption.
A soft link will return with an error and fail.
you should only use soft mounts in the cases where client responsiveness is more important
than data integrity.

In another word ..soft mount will allow automatic unmount if the filesystem is idle for a
specified time period
ex:

[root@sadeek ~]# showmount -e 172.28.50.109


Export list for 192.168.0.105:
/nfs *
Soft mounting (Temporary Mounting):[root@sadeek ~]# mount 172.28.50.109:/nfs/ /mnt/

Probles and Solution --- > (This is server side Problem)


[root@localhost ~]# service nfs restart
Shutting down NFS daemon:
[FAILED]
Shutting down NFS mountd:
[FAILED]
Shutting down NFS quotas:
[FAILED]
Shutting down NFS services:
[ OK ]
Starting NFS services:
[ OK ]
Starting NFS quotas: Cannot register service: RPC: Unable to receive; errno = Connection
refused
rpc.rquotad: unable to register (RQUOTAPROG, RQUOTAVERS, udp).
[FAILED]
Starting NFS mountd:
[FAILED]
Starting NFS daemon: rpc.nfsd: writing fd to kernel failed: errno 111 (Connection refused)
rpc.nfsd: unable to set any sockets for nfsd
[FAILED]
[root@localhost ~]# service rpcbind restart =====> To restart the rpcbind once
Stopping rpcbind:
[FAILED]
Starting rpcbind:
[ OK ]
[root@localhost ~]# service rpcbind restart
Stopping rpcbind:
[ OK ]
Starting rpcbind:
[ OK ]
[root@localhost ~]# service nfs restart
Shutting down NFS daemon:
Shutting down NFS mountd:
Shutting down NFS quotas:
Shutting down NFS services:

[FAILED]
[FAILED]
[FAILED]
[ OK ]

Starting NFS services:


Starting NFS quotas:
Starting NFS mountd:
Starting NFS daemon:
[root@localhost ~]#

[ 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

Now Client Side


#service nfs restart
#chkconfig nfs on
# showmount -e 192.168.6.136
/oracle *
#

Export list for 192.168.6.136:

To check the NFS Server or NFS Client

To check the NFS Version

NFS was originally developed by Sun Microsystems:


NFSv2 released in 1985
NFSv3 released in 1995
NFSv4 released in 2003 for Sun and NetApp. Available in Linux now.

# mount -v
desktop75.example.com:/java on /mnt type nfs
(rw,vers=4,addr=192.168.0.75,clientaddr=192.168.0.62)

Вам также может понравиться