Network File System (NFS)

NFS allows you to mount disks on remote systems so that they appear as though they are local to your system. Similarly, NFS allows remote systems to mount your local disk so that it looks as though it is local to the remote system. We'll go through a simple NFS server and client setup in this section after NFS background is supplied. You can use standard-mounted directories or automounted directories with NFS. Our upcoming example uses standard-mount directories but you can find out more about automounted directories and all NFS-related topics in Installing and Administering NFS Services from docs.hp.com. Configuring NFS to achieve this functionality is simple. Here are the steps to go through in order to configure NFS:

1.
Configure NFS startup files to specify whether your system will be an NFS Client, NFS Server, or both.

2.
Start NFS server processes.

3.
Specify which of your local file systems can be mounted by remote systems.

4.
Specify the remote disks you want to mount and view as if they were local to your system.

As with Internet Services, you could enable other aspects to NFS, but again, I cover what I know to be the NFS functionality that nearly every UNIX installation uses.

Because NFS may be setup on your system to meet the needs of many users, you may want to understand the terminology associated with NFS. The following are commonly used NFS terms:

NodeA computer system that is attached to or is part of a computer network.
ClientA node that requests data or services from other nodes (servers).
ServerA node that provides data or services to other nodes (clients) on the network.
File SystemA disk partition or logical volume.
ExportMakes a file system available for mounting on remote nodes using NFS.
MountAccesses a remote file system using NFS.
Mount PointThe name of a directory on which the NFS file system is mounted.
ImportMounts a remote file system.

Some of the specific configuration tasks and related files are different among UNIX variants. The following are some general tasks and examples related to configuring NFS. Your system administrator, of course, has to deal with the specifics of configuration on the UNIX variants.

Your system must be an NFS client, NFS server, or both. There are also daemons that must be running to support NFS. Both of these tasks are performed somewhat differently among the UNIX variants.

Your system then imports remote file systems to which you have local access and exports local file systems that are accessed by other systems.

A remote file system that you are mounting locally has an entry similar to the one that follows in /etc/fstab, /etc/filesystems, or whatever file is used to mount file systems:


system2:/opt/app3  /opt/app3   nfs rw,suid 0 0

In this case, we are mounting /opt/app3 on system2 locally as /opt/app3. This is an NFS mount with the permissions shown.

You can use the showmount command to show all remote systems (clients) that have mounted a local file system. This command is supported on most UNIX variants. showmount is useful for determining the file systems that are most often mounted by clients with NFS. The output of showmount is particularly easy to read, because it lists the host name and the directory that was mounted by the client. You have the three following options to the showmount command:

-aprints output in the format “name:directory”
-dlists all the local directories that have been remotely mounted by clients
-eprints a list of exported file systems

Example NFS Configuration

Let's take a look at the steps to setup an NFS server and client. We'll perform the following steps on our NFS server, with hostname asodevlab1, to export the directory /home/frame:

1.
Configure NFS startup files by setting the following variables to 1 in /etc/rc.config.d/nfsconf:

NFS_CLIENT=1
NFS_SERVER=1
NUM_NFSD=16
NUM_NFSIOD=16
PCNFS_SERVER=1

All of the startup variables have been set to 1 thereby enabling all NFS-related functionality at startup. I left the number of daemons (NUM_NFSD and NUM_NFSIOD) with default values.

2.
Next we'll start the NFS server and check to see what NFS-related processes are running, as shown in the following output:

# /sbin/init.d/nfs.server start
    starting NFS SERVER networking

    starting up the rpcbind daemon
        rpcbind already started, using pid: 837
    Reading in /etc/exports
    starting up the mount daemon
        rpc.mountd already started, using pid: 1938
    starting up the NFS daemons
      nfsd(s) already started, using pid(s): 1970 1971 1973 1974 1975 1958 1959 1960 196
1 1962 1963 1964 1965 1966 1967 1968 1976
    starting up the Status Monitor daemon
        rpc.statd already started, using pid: 884
    starting up the Lock Manager daemon
        rpc.lockd already started, using pid: 890
# ps -ef | grep nfs
    root   842     0  0  Apr 29  ?         0:00 nfskd
    root  1970  1959  0  Apr 29  ?         0:00 /usr/sbin/nfsd 16
    root  1971  1959  0  Apr 29  ?         0:00 /usr/sbin/nfsd 16
    root  1973  1959  0  Apr 29  ?         0:00 /usr/sbin/nfsd 16
    root  1974  1959  0  Apr 29  ?         0:00 /usr/sbin/nfsd 16
    root  1975  1959  0  Apr 29  ?         0:00 /usr/sbin/nfsd 16
    root  1958     1  0  Apr 29  ?         0:00 /usr/sbin/nfsd 16
    root  1959     1  0  Apr 29  ?         0:00 /usr/sbin/nfsd 16
    root  1960  1959  0  Apr 29  ?         0:00 /usr/sbin/nfsd 16
    root  1961  1960  0  Apr 29  ?         0:00 /usr/sbin/nfsd 16
    root  1962  1960  0  Apr 29  ?         0:00 /usr/sbin/nfsd 16
    root  1963  1959  0  Apr 29  ?         0:00 /usr/sbin/nfsd 16
    root  1964  1960  0  Apr 29  ?         0:00 /usr/sbin/nfsd 16
    root  1965  1960  0  Apr 29  ?         0:00 /usr/sbin/nfsd 16
    root  1966  1960  0  Apr 29  ?         0:00 /usr/sbin/nfsd 16
    root  1967  1960  0  Apr 29  ?         0:00 /usr/sbin/nfsd 16
    root  1968  1960  0  Apr 29  ?         0:00 /usr/sbin/nfsd 16
    root  1976  1959  0  Apr 29  ?         0:00 /usr/sbin/nfsd 16
    root 23825     0  0 12:00:10 ?         0:00 nfsktcpd
    root 24527 23078  0 12:44:29 pts/ta    0:00 grep nfs
#

Now that we have the server started, we can proceed to export file systems in step 3.

3.
We'll update the /etc/exports file to include a directory that will be available to all systems, as shown below:

# cat /etc/exports
/home/frame     #exported read/write to all systems
#

We have exported /home/frame to all systems with read/write access.

4.
Run the exportfs command in order to make /home/frame available to other systems:

# exportfs -av //home/frame
								

You can also run showmount -e to see the mounted file system. We have performed all of the setup required on our server to export this file system. Next we'll proceed to the client part of the setup.

The first step is to update the /etc/rc.config.d/nfsconf conf file to enable the NFS client. On our client, with hostname of m4415mxp, we'll enable both the NFS server and client as we did on the server.

1.
Configure NFS startup files by setting the following variables to 1 in /etc/rc.config.d/nfsconf:

NFS_CLIENT=1
NFS_SERVER=1
NUM_NFSD=16
NUM_NFSIOD=16
PCNFS_SERVER=1

All of the startup variables have been set to 1 thereby enabling all NFS-related functionality at startup. I left the number of daemons (NUM_NFSD and NUM_NFSIOD) with default values. I also ran the server start command on the client in our example as well so that all of the NFS daemons are running. The NFS client is enabled by default in the nfsconf file.

2.
Next we'll update the /etc/fstab file to include the mount

# cat /etc/fstab
# System /etc/fstab file.  Static information about the file systems
# See fstab(4) and for further details on configuring devices
/dev/vg00/lvol3 / vxfs delaylog 0 1
/dev/vg00/lvol1 /stand hfs defaults 0 1
/dev/vg00/lvol4 /home vxfs delaylog 0 2
/dev/vg00/lvol5 /tmp vxfs delaylog 0 2
/dev/vg00/lvol6 /opt vxfs delaylog 0 2
/dev/vg00/lvol7 /usr vxfs delaylog 0 2
/dev/vg00/lvol8 /var vxfs delaylog 0 2
asodevlab1:/home/frame /home/frame nfs rw,suid 0 0
#

The /home/frame directory will be automatically mounted at the next boot. We have to run the mount command as shown below to manually mount the file system at this time:

# mount /home/frame
# bdf
Filesystem          kbytes    used   avail %used Mounted on
/dev/vg00/lvol3     409600   69466  318923   18% /
/dev/vg00/lvol1     299157   26357  242884   10% /stand
/dev/vg00/lvol8    4706304  146362 4275401    3% /var
/dev/vg00/lvol7    1036288  748400  269946   73% /usr
/dev/vg00/lvol5     409600    1388  382763    0% /tmp
/dev/vg00/lvol6    3047424  749463 2154357   26% /opt
/dev/vg00/lvol4     409600    1210  382871    0% /home
asodevlab1:/home/frame
                     20480    1128   18144    6% /home/frame
# ls -l /home/frame
total 20
-r--r--r--   1 root       sys      959 May  6 12:14 copy.l.pm.Z
-r--r--r--   1 root       sys     2570 May  6 12:14 copy1.xwd
-r--r--r--   1 root       sys     2574 May  6 12:14 copy_done.xwd
-r--r--r--   1 root       sys     2575 May  6 12:14 copy_sched.xwd
#

We manually mounted /home/frame, ran bdf to get information on all mounted file systems, and then ran ls -l to see its contents. Keep in mind that our client is accessing data on a server. We can write to this directory and the data will be written on the server.

The nfsstat -m command can also be used to verify active NFS client mounts and options. Useful data on the NFS server is also provided by this command.

There are many NFS mount options and trade-offs related to standard-mounting vs. automounting that are not covered in this book that are covered in Installing and Administering NFS Services. This example; however, shows how simple it is to get NFS mounts up-and-running quickly on two systems. With PCNFSD running, the PC NFS daemon, you can also mount this directory from a PC.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.81.214