Why?


Search This Blog

Sunday, April 5, 2015

Setting Up the NFS Server and Client on Centos 6.6

Setting Up the NFS Server

Server IP is 192.168.10.110
Client IP is 192.168.10.20


Download the Required Software on the NFS Server

# yum -y install nfs-utils nfs-utils-lib

Start services now and start on reboot as well

# chkconfig nfs on
# chkconfig rpcbind on
# service rpcbind start
# service nfs start


Make the NFS exported/shared directory of /nfsexports/home/

# mkdir -p /nfsexports/home/


Now set the shared directory for export

# vi /etc/exports

Add the following to the file

/nfsexports/home          192.168.10.20(rw,sync,no_root_squash,no_subtree_check)

The above settings accomplish:

* 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 directory
   
Now export them within

# exportfs -a


Now create a file in your /nfsexports/home/ directory called testfile

# touch /nfsexports/home/testfile

Now verify the file is there

ls -lsa /nfsexports/home
4 drwxr-xr-x 2 root root 4096 Apr  5 18:37 .
4 drwxr-xr-x 3 root root 4096 Apr  5 18:05 ..
0 -rw-r--r-- 1 root root    0 Apr  5 18:37 testfile



Setting Up the NFS Client

Download the Required Software on the Client Server

# yum -y install nfs-utils nfs-utils-lib

Create the directory that will contain the mount from the Server

# mkdir -p /mnt/nfs/home

Now mount it

# mount 192.168.10.110:/nfsexports/home /mnt/nfs/home

See if it is mounted

# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_whittenberg-lv_root
                       18G  2.5G   14G  16% /
tmpfs                 1.9G     0  1.9G   0% /dev/shm
/dev/sda1             477M   48M  405M  11% /boot
192.168.10.110:/nfsexports/home
                       18G  909M   16G   6% /mnt/nfs/home


                      
As you can see above we have a successful mount from 192.168.10.110:/nfsexports/home in our Client Server under /mnt/nfs/home. Now anything we save in the /mnt/nfs/home directory on our client is actually written on the NFS Server.

Now you can make sure the mount on the client server is active after reboot by

# vi /etc/fstab

And add the following to the file

192.168.10.110:/nfsexports/home  /mnt/nfs/home   nfs      auto,noatime,nolock,bg,nfsvers=3,intr,tcp,actimeo=1800 0 0

Commands to show/work with mounts

# man nfs
# mount -a
# df -h
# mount
# umount


The end!

1 comment: