In the NFS service, we need to consider a lot. As the network's user base grows, network resources become increasingly complex and tense. We are all trying to optimize our facilities. Now let's talk about optimizing NFS.
Optimize NFS
Optimization steps:
1. Measure the execution efficiency of the current network, server, and each client.
2. analyze collected data and draw charts to find out special situations, such as high disk and CPU usage and high disk usage time.
3. Adjust the server
4. Repeat steps 1 to 3 until you reach the desired performance.
There are many problems related to NFS performance. You can usually consider the following options:
The WSIZE and RSIZE parameters are used to optimize the NFS execution efficiency.
WSIZE and RSIZE have a great impact on the efficiency of NFS optimization.
Wsize and rsize set the size of the data blocks between the SERVER and the CLIENT. The reasonable settings of these two parameters are related to many aspects, in addition to software, there are also hardware factors that will affect the setting of these two parameters, such as linux kernel, Nic, and switch ).
The following command can test the NFS execution efficiency. The read and write performance can be tested separately to find the appropriate parameters. you can write scripts to test the reading and writing of a large amount of scattered data. during each test, it is best to execute MOUNT and unmount again.
Time dd if =/dev/zero of =/mnt/home/testfile bs = 16 k count = 16384
The WSIZE used for testing. RSIZE is preferably a multiple of 1024. For NFS V2, 8192 is the maximum value of RSIZE and WSIZE. If NFS V3 is used, the maximum value you can try is 32768.
If the value is set to a large value, it is best to enter the directory on the mount on the CLIENT and perform some common operations such as LS and VI) to see if there is any error message. when LS is used, files cannot be fully listed or error messages may occur. different operating systems have different optimal values, therefore, different operating systems must be tested.
Set the maximum number of NFSD copies.
The number of NFSD copies in linux is in/etc/rc. d/init. d/nfs is set in the startup file. The default value is 8 NFSD. The setting of this parameter is generally based on the number of possible clients, similar to WSIZE and RSIZE, we also need to test the latest value.
UDP and TCP
You can set it manually or automatically.
Mount-tNFS-o sync, tcp, noatime, rsize = 1024, wsize = 1024 EXPORT_MACHINE:/EXPORTED_DIR/DIR
UDP provides fast transmission speed and non-connection transmission convenience. However, UDP is not stable over TCP during transmission, when the network is unstable or hackers intrude into the network, NFS Performance can be greatly reduced or even paralyzed. therefore, you must select the transmission protocol for networks in different situations. nfs over tcp is relatively stable, and nfs over udp is faster. when there are few machines with good network conditions, using UDP protocol can bring better performance. When there are many machines and the network conditions are complex, we recommend that you use TCP protocol V2 to only support UDP protocol ). it is better to use UDP protocol in the LAN because the LAN has stable network guarantee and UDP can provide better performance. We recommend that you use TCP protocol in the wide area network, the TCP protocol enables optimized NFS to maintain the best transmission stability in a complex network environment. can refer to this article: http://www.hp.com.tw/ssn/unix/0212/unix021204.asp
Version Selection
V3 is the default option. red hat 8 uses V2 by default and SOLARIS 8 and later uses V3 by default. You can use vers = mount option to select.
In LINUX, The nfsvers = n option is used for selection.