Wednesday, August 29, 2012

NFS Server and Client Configuration in RHEL / CENTOS / Fedora (Basic)


Server Side
NFS Package Installation

[root@system1 ~]# yum install nfs*

Create a shared directory with appropriate permission to access

[root@system1 ~]# cd /

[root@system1 /]# mkdir redhat

[root@system1 /]# ls
bin   dev  home  lost+found  misc  net  proc    root  selinux  sys  usr
boot  etc  lib   media       mnt   opt  redhat  sbin  srv      tmp  var

[root@system1 /]# cd redhat

Create sample files in to that

[root@system1 redhat]#  touch  ma ba ca

Check the service status

[root@system1 /]# service nfs status
 
rpc.mountd is stopped
nfsd is stopped
rpc.rquotad is stopped

Put a share entry in vim /etc/exports

[root@system1 /]# vim etc/exports
 
/redhat         192.168.0.100(rw)
~                                                                               
~                                                                               
~                                                                               
~                                                                               
~                                                                               
~                                                                               
"etc/exports" 1L, 27C

Start the service

[root@system1 /]# service nfs start
 
Starting NFS services:                                     [  OK  ]
Starting NFS quotas:                                       [  OK  ]
Starting NFS daemon:                                       [  OK  ]
Starting NFS mountd:                                       [  OK  ]

[root@system1 /]# chkconfig nfs on

Output verification

[root@system1 /]# exportfs
/redhat         192.168.0.100

Client Side

In client side create a directory to mount the NFS sharing what you made in server side.

[root@system2 /]# mkdir /data


Commands used at the client end to verify the sharing availability:-

[root@system2 /]# showmount -e <nfs server ip_address> ( or )
[root@system2 /]# showmount -e <nfs server hostname>   ( or )
[root@system2 /]# showmount -e <nfs server FQDN>


Mounting of NFS sharing

There are two types of mounting is possible, that is temporary mount and other is permanent mount by put an entry in /etc/fstab

[root@system2 /]# mount -t nfs 192.168.0.100:/redhat /data

Check this by type ls command and see the file content is present or not

Entry in vim /etc/fstab

[root@system2 /]# vim /etc/fstab
 
#
# /etc/fstab
# Created by anaconda on Mon Aug 13 21:49:03 2012
#
# 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
#
sysfs                     /sys     sysfs  defaults  0 0
proc                      /proc    proc   defaults  0 0
192.168.0.100:/redhat     /data    nfs    defaults  0 0


[root@system2 /]# mount -a

Now we have a permanent mount path for NFS file sharing in client machine.

That’s it….

0 comments:

Powered by Blogger.