Configuring NFS on the Server
Both the NFS server and NFS client have to have parts of the NFS package installed and running. The server needs portmap, nfs, and nfslock operational, as well as a correctly configured /etc/exports file. Here's how to do it.
The /etc/exports File
The /etc/exports file is the main NFS configuration file, and it consists of two columns. The first column lists the directories you want to make available to the network. The second column has two parts. The first part lists the networks or DNS domains that can get access to the directory, and the second part lists NFS options in brackets.
For the scenario you need:
Read-only access to the /data/files directory to all networks Read/write access to the /home directory from all servers on the 192.168.1.0 /24 network, which is all addresses from 192.168.1.0 to 192.168.1.255 Read/write access to the /data/test directory from servers in the my-web-site.org DNS domain Read/write access to the /data/database directory from a single server, 192.168.1.203
In all cases, use the sync option to ensure that file data cached in memory is automatically written to the disk after the completion of any disk data copying operation.
#/etc/exports
/data/files *(ro,sync)
/home 192.168.1.0/24(rw,sync)
/data/test *.my-web-site.org(rw,sync)
/data/database 192.168.1.203/32(rw,sync)
After configuring your /etc/exports file, you need to activate the settings, but first make sure that NFS is running correctly.
Starting NFS on the Server
Configuring an NFS server is straightforward:
1. | Use the chkconfig command to configure the required nfs and RPC portmap daemons to start at boot. You also should activate NFS file locking to reduce the risk of corrupted data.
[root@bigboy tmp]# chkconfig --level 35 nfs on
[root@bigboy tmp]# chkconfig --level 35 nfslock on
[root@bigboy tmp]# chkconfig --level 35 portmap on
| 2. | Use the init scripts in the /etc/init.d directory to start the nfs and RPC portmap daemons. The examples use the start option, but when needed, you can also stop and restart the processes with the stop and restart options:
[root@bigboy tmp]# service portmap start
[root@bigboy tmp]# service nfs start
[root@bigboy tmp]# service nfslock start
| 3. | Test whether NFS is running correctly with the rpcinfo command. You should get a listing of running RPC programs that must include mountd, portmapper, nfs, and nlockmgr:
[root@bigboy tmp]# rpcinfo -p localhost
program vers proto port
100000 2 tcp 111 portmapper
100000 2 udp 111 portmapper
100003 2 udp 2049 nfs
100003 3 udp 2049 nfs
100021 1 udp 1024 nlockmgr
100021 3 udp 1024 nlockmgr
100021 4 udp 1024 nlockmgr
100005 1 udp 1042 mountd
100005 1 tcp 2342 mountd
100005 2 udp 1042 mountd
100005 2 tcp 2342 mountd
100005 3 udp 1042 mountd
100005 3 tcp 2342 mountd
[root@bigboy tmp]#
|
 |