33.2 Configuring an NFS Server

   

The networking subsystem and NFS subsystem must be present in the kernel configuration to use NFS. The configuration process of an NFS server consists of multiple steps which will be discussed shortly. You may want to set up one or more NFS servers depending on the requirements and nature of the use of shared files and directories. For powerful NFS servers, the ratio of clients per server may be increased compared with a slow server. Similarly, you may consider changing this ratio depending on the type of applications used. For applications that are disk intensive , a lower ratio may be more efficient. Similarly, the network also plays an important role in the speed of data transfer. For high-volume data transfer, you may plan to have a high-capacity network or segment your network to divide network traffic.

After the planning process, you can follow the following steps to configure an NFS server. For proper access permissions to files shared through NFS, keep the UID and GID of all users the same on the NFS server and client machines. This can be done by copying the /etc/passwd and /etc/ group files from the NFS server onto all client machines. If you are using NIS, all NFS server and client machines should be NIS clients in the same NIS domain.

Creating the /etc/exports File

This file consists of a list of file systems that are made available or exported to NFS clients. The following major rules apply to this file.

  • Each line in the file starts with a file or directory name followed by a set of options related to that file or directory. See Table 33-1 for a list of options.

  • Multiple options can be listed by using a comma to separate these options.

  • The exported files and directories may have restricted access permissions. For example, some directories may be exported only to particular NFS clients. Similarly, if you don't want any modification to files in some directories, like manual pages, you can export these as read-only.

  • All subdirectories are automatically exported when you export a parent directory.

  • You can export an individual file or a directory.

  • A file system mounted from another NFS server can't be exported.

  • You should not export the root file system to all clients. This makes every file and directory visible to all NFS clients.

  • If a file system is exported with the root option, clients will have root user access on that file system. This should be done very carefully . The root permission is not granted by default.

A sample /etc/exports file is shown next .

 /home            -access=myhp:hp0 /usr/share/man   -ro /opt/apps        -ro 

The first line grants access to the /home directory to users on hosts myhp and hp0 . The second and third lines grant read-only access to the /usr/share/man and /opt/apps directories to all hosts.

The options used in this file are listed in Table 33-1.

Table 33-1. Options Used in the /etc/exports File
Option Description
-ro Used to grant read-only access to clients.
-rw Used to grant read-write access to clients.
-access=client1[:client2] Used to grant access to one or more clients only. The list of clients is separated using a colon .
-root=client1[:client2] Used to grant root access to one or more clients. The list of clients is separated using a colon.
-anon=uid If a request comes from an unknown user, he or she is granted access using the UID specified here. Usually a UID of -2 is used that corresponds to a user nobody with minimum access rights.
-anon=65534 Access to unknown users is not granted.

You can also use SAM to export file systems using the Network File System button in the Networking and Communications area of SAM.

A file system does not become available automatically for clients until it is exported using the exportfs command. File systems in /etc/exports are exported at boot time with the help of the exportfs command. If you want to export these manually without rebooting after making a change, use the exportfs -a command. This command reads the /etc/exports file and copies these entries to the /etc/xtab file. Use the following command to export all file systems in the /etc/exports file.

 exportfs -a 

To unexport all exported file systems, use the following command.

 exportfs -au 

To unexport a particular file system, e.g., /usr/share/man , use this command.

 exportfs -u /usr/share/man 

Starting the Server Process at Boot Time

There are three startup scripts for the NFS system in the /sbin/init.d directory. The scripts are listed next.

  1. The nfs. core script is executed at system run level 2 and is used for both NFS client and server machines. It starts portmap or rpcbind depending on the HP-UX version. The rpcbind daemon is used in HP-UX 10.30 and above, while the earlier versions use portmap .

  2. The nfs.client script is executed at system run level 2 on an NFS client.

  3. The nfs.server script is executed at system run level 3 on an NFS server. Among other tasks , it executes the exportfs command mentioned earlier.

These scripts use configuration parameters present in the /etc/rc.config.d/nfsconf file at startup time. The following values should be present for a system acting as an NFS server.

 NFS_CLIENT=0 NFS_SERVER=1 NUM_NFSD=4 NUM_NFSIOD=4 PCNFS_SERVER=0 START_MOUNTD=1 

Starting an NFS Server and Exporting Directories Manually

If you want to start an NFS server without rebooting the system, follow these steps.

  1. Edit the /etc/exports file and add entries for exported file systems.

  2. Use the exportfs -a command to export these file systems.

  3. Edit the /etc/rc.config.d/nfsconf file and set proper values to different variables as mentioned earlier.

  4. Execute the /sbin/init.d/nfs.core start command.

  5. Execute the /sbin/init.d/nfs.server start command.

Viewing Exported and Mounted File Systems

Exported file systems can be listed using the exportfs command without any arguments. To list file systems remotely mounted by NFS clients, you can use the showmount command. The command can also be used to list exported file systems on a particular NFS server using the -e command-line option. If a client name is specified on the command line, it only lists file systems mounted by that client. The following command shows a list of hosts who have recently mounted local file systems.

 #  showmount  myhp hp0 # 

The following command lists file systems mounted by remote hosts in the host:filesystem format.

 #  showmount -a  hp0:/home myhp:/usr/share/bin # 

Entries of all remotely mounted file systems and remote NFS clients are present in the /etc/rmtab file. It is a text file and can be viewed using the cat command.


   
Top


HP Certified
HP Certified: HP-UX System Administration
ISBN: 0130183741
EAN: 2147483647
Year: 2000
Pages: 390
Authors: Rafeeq Rehman

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net