Module – 14 NFS Server & Client configuration

NFS Server & Client Configuration – RHEL 6.4

  • NFS, Network File System, is a server-client protocol used for sharing files between linux systems.
  • NFS enables you to mount a remote share locally.
  • You can then directly access any of the files on that remote share.

Let’s see how to configure NFS master server & client setup.

Step:1

@ Master server, create a new file system (or directory) you wanted to share with other servers.

$ su – root

# mkdir /nfs_mast 

** this is the directory we wanted to share to other linux clients.

Step:2

Install NFS packages to configure NFS master server:

# yum groupinstall “NFS file server –> “Y” to install all listed packages.

Verify the NFS packages installed :

# rpm -qa | grep nfs
nfs-utils-lib-1.1.5-6.el6.x86_64
nfs-utils-1.2.3-36.el6.x86_64
nfs4-acl-tools-0.3.3-6.el6.x86_64

Step:3

Start the NFS server &  add the script in start-up

# service nfs start
Starting NFS services:                                     [  OK  ]
Starting NFS quotas:                                       [  OK  ]
Starting NFS mountd:                                       [  OK  ]
Starting NFS daemon:                                       [  OK  ]

#  service nfs status    (To check NFS services running)

#  Remember NFS use TCP port “2049”,  verify it is “LISTENING”

# netstat -an |grep 2049
tcp        0      0 0.0.0.0:2049                0.0.0.0:*                   LISTEN
tcp        0      0 :::2049                     :::*                        LISTEN

#  chkconfig –levels 35 nfs on    (this command turn on NFS only for run level 3 & 5)

or

# chkconfig nfs on   (this command trun on NFS on 2,3,4 & 5)

# chkconfig –list | grep nfs    (check the status)
nfs                      0:off    1:off    2:on    3:on    4:on    5:on    6:off
nfslock            0:off    1:off    2:off    3:on    4:on    5:on    6:off

Step: 4

NFS service is running  &  we are ready to share our directory “nfs_master”

Edit the NFS configuration file ” /etc/exports” & add the following entry

vi /etc/exports

/nfs_share 192.168.1.100(ro,root_squash)

or

/nfs_share *(rw)

Where:

  • /nfs_share  is the directory you want to export.
  • 192.168.1.100 is the client allowed to log in this directory.
  • The ro option mean mounting read-only.
  • The root_squash option for not allowing root write access in this directory.
  • * (star means, everyone)
  • rw (read & write)

Step: 5

When ever we edit/update configuration file, it is mandatory to restart the service (NFS) to take effect.

# service nfs restart   (or stop/start)

Step:6

Verify the directory being exported by NFS.

#exportfs

/nfs_share        xxxx.xx.xx

Step: 7

Now, NFS server setup is done & we are ready to login to client server and mount the NFS directory “nfs_server”

login to client linux server

# su – root

Verify what directory shared from server & NFS port status

# showmount -e  “NFS server IP “

# telnet “server IP” 2049   (If it fails, you should check IPTABLES/firewall between servers)

All looks good, let us mount it.

# mkdir /nfs_share

#mount -t nfs 192.168.1.10:/nfs_share /nfs_share

#df -h  (verify it is mounted)

Now you can write in to the NFS share.

Note:

Update /etc/fstab file at client server, other wise you will loose NFS mount during server restart.

vi /etc/fstab (add the following line)

192.168.1.1:/nfs_share  /nfs_share              nfs     defaults        0 0

That’s it.

 

 

 

 

Leave a Comment

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>