1. View the mount configuration:
cat /var/lib/nfs/etab see NFS Details of server-side configuration parameters cat /proc/mounts View client mount Mount parameter details for
2. Description of NFS client mount parameters
fg/bg default[fg],When the client performs mounting, you can choose to be in the foreground(fg)Execution or background(bg)implement soft/hart default[hart]When the network and server When something goes wrong, soft The parameter will stop mounting after timeout, hard The parameter will be mounted until it succeeds (but it may cause no response from the client, so it often cooperates with the client) intr Parameter usage) intr When hard Mount resources timeout After, if used intr Parameters can be mounted on the terminal after timeout to prevent NFS Lock resize/wsize The read and write block size affects the buffer storage of data transmitted between the client and the server segment proto=tcp default[tcp]Protocol used for transmission, cross internet proposal tcp Good error correction ability, recommended for Intranet udp Improve performance
3. Suggestions for mounting mode:
Pursuit of perfection:
mount -t nfs -o fg,hart,intr,resize=13107,wsize=131072 172.16.1.31:/date/ /mnt
Easy to use:
mount -t nfs 172.16.1.31:/date/ /mnt # The default parameters can meet most requirements
4. Description of parameters that mount - O can use (red default)
ro/rw ■Read only/Read write mount dev/nodev Whether to retain the special functions of device files, such as the difference between partition and optical drive, it is recommended to be general nodev sync/async ●Write directly to disk synchronously or asynchronously, write to memory first and then write to hard disk later auto/noauto allow/Not allowed–a Option to mount automatically exec/noexec ●Whether you have permission to execute files. If the purpose of mounting is data storage, it is recommended to noexec suid/nosuid ●Mounted file system, cancel suid This permission user/nouser Whether to allow general users to mount and uninstall functions dirsync ●Synchronous write to disk during directory update remount Attempt to remount a mounted file system noatime ■Do not update files when accessing files inode Timestamp in, high concurrency environment can improve performance nodiratime ■As above, the access timestamp of the directory is not updated atime defaults Use default values for all options( auto,nouser,rw,suid) loop Mount the "swing device" and“ ISO Mirror file ●Represents safety optimization parameters,■Represents performance optimization parameters. Safety and performance are opposite
The remount parameter is very important. After the file system becomes read-only and enters the single user mode for repair, mount -o remount,rw / * * should be used to remount the directory Some of the above parameters are only valid in fatab, and sync to is valid in ext234\fat\vfat\ufat
5. Three common uses of NFS optimized mounting in enterprise production environment
1)Default mount mount -t nfs IP:catalogue /Mount point # In fact, the default mount performance of centos is already very good 2)performance optimization # Reduce disk I/O from updating access timestamps mount -t nfs -o noatime,nodiratime IP:catalogue /Mount point 3)Security optimization # Carry out execution and right raising, and prevent hanging horse mount -t nfs -o nosuid,noexec,nodev IP:catalogue /Mount point 4)Both safety and performance are optimized mount -t nfs -o nosuid,noexec,nodev,noatime,nodiratime,intr,rsize=131072,wsize=131072 IP:catalogue /Mount point
Note: the odiratime option cannot be added when the local file system is mounted, and an error will be reported
6 NFS kernel optimization instructions and suggestions
proc/sys/net/core/rmem_default Specifies the default buffer size of the receive socket (default: 124928) proc/sys/net/core/rmem_max Specifies the maximum buffer size of the receive socket (default: 124928) proc/sys/net/core/wmem_default Specifies the default size of the send socket buffer (default: 124928) proc/sys/net/core/wmem_max Specifies the maximum buffer size of the send socket (default: 124928)
The optimization commands are as follows:
cat >>/etc/sysctl.conf<<EOF net.core.wmem_dafault = 8388608 net.core.rmem_dafault = 8388608 net.core.wmem_max = 16777216 net.core.rmem_max = 16777216 EOF sysctl -p
7 Enterprise scenario NFS shared storage optimization summary
- Hardware: SAS/SSD hard disk, RAID10 group, Gigabit network card, bond with multiple network cards
- NFS server configuration optimization: / directory ip segment (RW, sync, all_square, anonuid = 65535, anongid = 65534)
- NFS mount client Optimization: - o nosuid,noexec,nodev,noatime,nodiratime,intr,rsize=131072,wsize=131072
- NFS server kernel optimization: see the above command. Execute sysctl -p to make the configuration effective
- Large websites can replace NFS with distributed file systems. Moosefs(mfs) and FastDFS are suitable for small file systems, and GlusterFS is suitable for large file systems
If umount: /mnt: device is busy is prompted during uninstall, you need to exit the mount directory and mount again. If NFS server is down, you need to force uninstall and execute the command umount -lf /mnt
8 summary of advantages and disadvantages of NFS system
advantage:
1) Simple, easy to use, easy to master 2) The data is directly visible. Do not want the distributed file system data to be invisible 3) Rapid deployment, simple, convenient and controllable maintenance (the one that meets the requirements is the best) 4) Reliable, high data reliability and durability 5) The service is very stable
Disadvantages:
1) There is a single point of failure, which can be compensated by high load and high availability schemes 2) Big data is high and NFS efficiency and performance are limited (but below 20 million / day PV is OK, if it can't meet 20 million, the architecture is too poor) 3)FS data is clear text, and NFS itself does not verify data integrity 4) When multiple clients mount an NFS server, connection management and maintenance are troublesome. After the NFS server side has a problem, all clients are in the hung state 5) The coupling degree is high, and there is always connection, involving the concepts of synchronization (real-time waiting) and asynchrony (decoupling). The website should minimize the coupling degree
Recommendations:
It can be used for large and medium-sized websites (less than 20 million PV / day). In the production scenario, data access should be pushed back as much as possible, and the resources in static storage should be provided with services through CDN or cache server. If there is no cache service or the architecture is poor, no matter how many storage servers can not carry it, the user experience will be very poor, even if the distributed file system is used (CDN can provide 90-95% of data access services, memory server 3%, and the rest is provided by file server)
Learning requirements
Be able to dictate the network principle and process of NFS server Dictate NFS optimization Can dictate the advantages and disadvantages of NFS