This is so far. I have seen the most detailed documents about NFS configuration. 1. the NFS package requires five RPM, namely: setup -*: the shared NFS directory defines initscripts in/etc/exports-*: includes the basic script nfs-utils -*:...
This is the most detailed Chinese document on NFS configuration.
1. NFS package
NFS requires 5 RPM, which are:
Setup-*: the shared NFS directory is defined in/etc/exports.
Initscripts-*: includes the basic script for loading the network directory during the boot process.
Nfs-utils-*: includes basic NFS commands and monitoring programs.
Portmap-*: Supports secure connections to the nfs rpc service.
Quota-*: The Directory quota shared on the network, including rpc. rquotad (this package is not required)
2. basic monitoring program
To run NFS smoothly, at least five Linux services are required. they have different functions, some are responsible for loading services, and some ensure that remote commands are directed to the correct location. These services are started through nfs, nfslock, and portmap scripts in the/etc/rc. d/init. d Directory. The following describes each monitoring program:
(1) Basic NFS
Rpc. nfsd is the NFS server monitoring program, which is started through the nfs script in the/etc/rc. d/init. d Directory. The NFS monitor also starts rpc. mountd to load the monitor program and export the shared directory.
(2) RPC loading
You can use the mount command to connect to the local directory or network directory, but you also need a special monitoring program rpc. mountd that loads the NFS directory.
(3) Port er
The portmap monitor only directs RPC communication data streams, but it is very important for the NFS service. If portmap is not run, the NFS client cannot find the shared directory from the NFS server.
(4) restart and statd
When the NFS service needs to be interrupted or restarted, the rpc. statd monitoring program and rpc. lockd resume the NFS connection of the client after the server is restarted.
(5) lock
When a file is opened through the shared NFS directory, the user cannot overwrite the same file if the file is locked. Use the nfslock script and run the rpc. lockd monitoring program.
3. configure NFS
The shared NFS directory is listed in/etc/exports. This File controls directory sharing. The writing rule is: (one row for each sharing rule)
Shared directory host (parameter)
Example:/mnt/cdrom * .abc.com (ro, sync) master.abc.com (rw, sync)
The above rule means to share the/mnt/cdrom directory to the * .abc.com domain in read-only synchronization mode and share it with the master.abc.com host in read/write synchronization mode. Sync or async must be specified for any shared directory, that is, whether the shared NFS directory responds to the command before the file is written to the disk.
Below are some common NFS sharing parameters:
Ro: Read-only access
Rw: read/write access
Sync: write and share all data upon request
Async: NFS can request data before writing data.
Secure: NFS is sent through the secure TCP/IP ports below 1024
Insecure: NFS is sent over port 1024.
Wdelay: if multiple users want to write data to the NFS Directory, group write (default)
No_wdelay: if multiple users want to write data to the NFS Directory, write the data immediately. this setting is not required when async is used.
Hide: do not share its subdirectories in the NFS shared directory.
No_hide: a subdirectory that shares the NFS Directory
Subtree_check: If sub-directories such as/usr/bin are shared, force NFS to check the permissions of the parent directory (default)
No_subtree_check: the parent directory permission is not checked.
All_squash: the UID and GID of the shared file are mapped to the anonymous user anonymous, which is suitable for public directories.
No_all_squash: Reserve the UID and GID of the shared file (default)
Root_squash: All requests of the root user are mapped to the same permissions as those of the anonymous user (default)
No_root_squas: the root user has full management access permissions to the root directory.
Anonuid = xxx: specify the UID of an anonymous user in the NFS server/etc/passwd file
Anongid = xxx: specify the GID of anonymous users in the NFS server/etc/passwd file
4. start NFS
# Service portmap start
# Service nfs start
Check the NFS running level:
# Chkconfig -- list portmap
# Chkconfig -- list nfs
Set automatic NFS startup at the appropriate running level as needed:
# Chkconfig -- level 235 portmap on
# Chkconfig -- level 235 nfs on
In addition, check whether the correct NFS access rules are set for iptables,/etc/hosts. allow, and/etc/hosts. deny of the system.
Refer:
Nfs-howto
Keywords: nfs optimization
Today visit the Boss blog (http://www.raidcheng.net), from the above to see an introduction to nfs optimization, I think it is very good, so reprinted, also calculate their favorite
1. set the block size
The risize and wsize of the mount command specify the block size transmitted between the server and client.
Mount-t nfs-o rsize = 8192, wsize = 8192, timeo = 14, intr client:/partition
If not specified, the system sets the default risize and wsize based on nfs version. In most cases, 4 K is used for nfs v2 and the maximum is 8 K. for v3, use the server-side kernel to set the risize and wsize limits.
Vi/usr/src/linux2.4.22/include/linux/nfsd/const. h
Constant: NFSSVC_MAXBLKSIZE
All 2.4 clients support a maximum of 32 K transmission blocks. The default system block may be too large or too small. it depends mainly on your kernel and your Nic. too large or too small may lead to slow nfs speed.
Specifically, you can use benchmark such as Bonnie, Bonnie ++, and iozone to test the nfs speed for different risize and wsize instances. Of course, dd can also be used for testing.
# Time dd if =/dev/zero of =/testfs/testfile bs = 8 k count = 1024 Test nfs write
# Time dd if =/testfs/testfile of =/dev/null bs = 8 k test nfs read
During the test, the file size must be at least twice that of the system RAM. in each test, umount and mount are used to mount/testfs. by comparing different block sizes, the optimized block size is obtained.
2. size of the network transmission package
During packet transmission, packets must be grouped. the bandwidth of the network cannot be used too much or too small. Therefore, the network should be tested and optimized. You can use ping-s 2048-f hostname to ping and try different package sizes to view the packet loss. In addition, you can use nfsstat-o net to test the packet loss rate of nfs over udp transmission. Because statistics cannot be cleared, you must first run this command to remember the value and then run the statistics again. If the packet loss rate is much higher than the previous statistics. Then you can see the size of the network transmission package. Run the following command:
# Tracepath node1/port number
# Ifconfig eth0
Use # ifconfig eth0 mtu 16436 to compare the mtu of the network adapter with the previous pmtu. Of course, if risize and wsize are greater than mtu values, then the server package will be reorganized to the client, which will consume the cpu resources of the client. In addition, packet restructuring may lead to network failures and packet loss. any packet loss will result in the re-transmission of rpc requests. the re-transmission of rpc requests will lead to timeout, seriously reducing nfs performance.
You can view
/Proc/sys/net/ipv4/ipfrag_high_thresh
/Proc/sys/net/ipv4/ipfrag_low_thresh
Understand the number of packages that the system can process. if the network package reaches ipfrag_high_thresh, the system will start to lose packets until the number of packets reaches ipfrag_low_thresh.
3. nfs mounting optimization
Timeo: If the timeout occurs, the client waits for a second.
Retrans: number of times of timeout attempts.
Bg: supports background mounting.
Hard: if the server does not respond, the client keeps trying to mount
Wsize: write block size
Rsize: Read block size
Intr: an unsuccessful mount can be interrupted.
Noatime: does not update the inode access time of the file, which can increase the speed
Async: asynchronous read/write
4. number of nfsd instances
The default system has eight nfsd processes at startup.
# Ps-efl | grep nfsd
By viewing the th row of the/proc/net/rpc/nfsd file, the first is the number of nfsd, and the last 10 is the number of time used by the thread, if the second to fourth values are large, you need to increase the number of nfsd instances.
The details are as follows:
# Vi/etc/init. d/nfs
Locate RPCNFSDCOUNT and modify this value, which is generally the same as the number of clients.
# Service nfs restart
# Mount-
5. nfsd queue length
For 8 nfsd processes, the system's nfsd queue length is 64 K. If there are more than 8 processes, the corresponding queue size must be increased accordingly.
/Proc/sys/net/core/rwmem_default
/Proc/sys/net/core/wwmem_default
/Proc/sys/net/core/rmmem_max
/Proc/sys/net/core/wmmem_max
The queue length should be 8 kB for each nfsd. In this way, the server can queue client requests. If you want to change this value permanently
# Vi/etc/sysctl. conf
Net. core. rmmem_default = number
Net. core. wmmem_default = number
Net. core. rmmem_max = number
Net. core. wmmem_max = number
# Service nfs restart
Output:
Http://hi.baidu.com/lqlboy/blog/item/8c35de431d72221173f05db8.html