CyberKeeda In Social Media

How to configure an NFS server in RHEL6 /CentOS 6

NFS (Network File System) is basically developed for sharing of files and folders between Linux/Unix systems by Sun Microsystems in 1980. It allows you to mount your local file systems over a network and remote hosts to interact with them as they are mounted locally on the same system. With the help of NFS, we can set up file sharing between Unix to Linux system and Linux to Unix system.

Benefits of NFS
  • NFS allows local access to remote files.
  • It uses standard client/server architecture for file sharing between all *nix based machines.
  • With NFS it is not necessary that both machines run on the same OS.
  • With the help of NFS we can configure centralized storage solutions.
  • Users get their data irrespective of physical location.
  • No manual refresh needed for new files.
  • Newer version of NFS also supports aclpseudo root mounts.
  • Can be secured with Firewalls and Kerberos.

Important Files for NFS configuration.

  • /etc/exports : Its a main configuration file of NFS, all exported files and directories are defined in this file at the NFS Server end.
  • /etc/fstab : To mount a NFS directory on your system across the reboots, we need to make an entry in/etc/fstab.
  • /etc/sysconfig/nfs : Configuration file of NFS to control on which port rpc and other services are listening.
Install NSF packages from yum.
# yum install -y nfs-utils nfs-utils-lib

# yum install -y portmap (Not required for NFS4)

Set the service to the chkconfig list so it will start at boot time:
# chkconfig --add rpcbind
# chkconfig --add nfs
# chkconfig rpcbind on
# chkconfig nfs on

Start the following services:
# service rpcbind start
# service nfs start

Make a shared directory for NFS (change xxxx to real directory name)
# mkdir /xxxx

# mkdir /nfsserver (example)

Export directory.
# vi /etc/exports
/xxxx *(rw)    example /nfsserver *(rw)
# exportfs

or 

/nfsserver clientremoteip(rw,sync,no_root_squash)

NFS Options

  • Some other options we can use in “/etc/exports” file for file sharing is as follows.
  • ro: With the help of this option we can provide read only access to the shared files i.e client will only be able to read.
  • rw: This option allows the client server to both read and write access within the shared directory.
  • sync: Sync confirms requests to the shared directory only once the changes have been committed.
  • no_subtree_check: This option prevents the subtree checking. When a shared directory is the subdirectory of a larger file system, nfs performs scans of every directory above it, in order to verify its permissions and details. Disabling the subtree check may increase the reliability of NFS, but reduce security.
  • no_root_squash: This phrase allows root to connect to the designated directory.
  • For more options with “/etc/exports“, you are recommended to read the man pages for export.

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...
Designed By Kunal Saha