Monday, December 30, 2013

Configure NFS server on CentOS 6.4

I use two physical machines to conduct this experiment.
NFS Server IP: 192.168.0.21
NFS Client IP: 192.168.0.27

Install NFS Server (CentOS 6.4)

$ yum install nfs-utils -y
$ service nfs start
$ chkconfig nfs on

Configure NFS Server

$ mkdir /nfs_dir
$ chmod 777 /nfs_dir
$ vim /etc/exports
add this line into the file
/nfs-dir 192.168.0.27(rw.sync,root_squash)

These settings accomplish several tasks:
  • rw: This option allows the client server to both read and write 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 filesystem, 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 director

$ exportfs -a
$ exportfs 
$ showmount -e

You may want to flush the IP Tables to allow the NFS connection
$ iptables -L 
$ iptables -F

Configure NFS Client

$ mkdir /nfs_mnt
$ mount -t nfs 192.168.0.21:/nfs_dir /nfs_mnt

Or you can set the /etc/fstab file, and this line into the file
192.168.0.21:/nfs_dir  /nfs_mnt   nfs4     defaults,acl        1 1

Show mount list
$ mount
$ df -h

If you have an error message:
# mount -a
mount: wrong fs type, bad option, bad superblock on 172.31.27.164:/nfs_meerkats,
       missing codepage or helper program, or other error
       (for several filesystems (e.g. nfs, cifs) you might
       need a /sbin/mount.<type> helper program)
       In some cases useful info is found in syslog - try

       dmesg | tail  or so

Solution: You need to install nfs-utils on the client side. Also, you need to service rpcbind start


No comments: