NFS File system mounts and optimizations

Source: Internet
Author: User

The NFS(Network File system), which is one of the file systems supported by FreeBSD, allows computers in the network to share resources across TCP/IP networks. in an NFS application, a local NFS client application can transparently read and write to files located on the remote NFS server, just as you would access a local file.

1. Install NFS

1.1 Installing the Server Software

[[email protected] ~]yum install–y nfs-utilsrpcbind[[email protected] ~]chkconfig NFS On[[email protected] ~]chkconfig RP Cbind On[[email protected] ~]# chkconfig--list |egrep "Nfs|rpcbind" NFS 0:OFF1:OFF2:ON3:ON4:ON5:ON6:OFFN Fslock 0:off1:off2:off3:on4:on5:on6:offrpcbind 0:off1:off2:on3:on4:on5:on6:off


2. Service-side configuration

2.1 Server configuration file

The server-side configuration file is /etc/exports, in the following format:

/WWW/APPDATA/UPLOAD/172.16.11.0/24 (Rw,async,all_squash)

/www/appdata/upload/ is the local directory to be published, 172.16.11.0/24 to publish this NFS directory to a specified range of hosts, support a single host, network user group @group, wildcard characters *,? , ETC., IP network , in this case the IP network used

the parameter descriptions in parentheses are as follows ( you can use Manexports to view Help )

RO: Shared directory is read-only; RW: Shared directory readable and writable; All_squash: All access users are mapped to anonymous users or groups of users; No_all_squash (default): The Access user matches the native user first, and the match fails before it is mapped to an anonymous user or user group; root_ Squash (default): Maps the visiting root user to an anonymous user or user group; No_root_squash: The root user remains the root account, Anonuid=<uid>: Specifies the local user UID of the anonymous access user, The default is Nfsnobody (65534); Anongid=<gid>: Specifies the local user group of the anonymous Access user GID, which defaults to Nfsnobody (65534); secure (default): Limit the client to tcp/from less than 1024 only IP port connection server; Insecure: Allows the client to connect to the server from a TCP/IP port greater than 1024; Sync: Write Data synchronously to the memory buffer and disk, but it is inefficient, but can guarantee the consistency of data; Async: Save the data in the memory buffer first. Write to disk if necessary, Wdelay (default): Check for related write operations, if any, perform these writes together, which can improve efficiency; No_wdelay: If a write operation is performed immediately, it should be used in conjunction with sync; Subtree_check (default) : If the output directory is a subdirectory, the NFS server will check the permissions of its parent directory; No_subtree_check: Even if the output directory is a subdirectory, the NFS server does not check the permissions of its parent directory, which can improve efficiency;


2.2 Creating a mount directory

Mkdir–p/www/appdata/uploadchownnfsnobody:nfsnobody/www/appdata/upload

2.3 start NFS service

[[email protected] ~]#/etc/init.d/rpcbind Start[[email protected] ~]#/etc/init.d/nfs start

View NFS releases

[[Email protected] ~] #exportfs-v/www/appdata/upload 172.16.11.0/24 (rw,async,wdelay,root_squash,all_squash,no _subtree_check,sec=sys,rw,root_squash,all_squash) [[email protected] ~] #showmount-e 172.16.11.15Export list For172.16.11.15:/www/appdata/upload172.16.11.0/24

Exportfs–r can reread the configuration file without restarting the NFS service

can go to client configuration after local view is correct

3. Client Configuration

3.1 Client environment configuration

Adding NFS and rpcbind to boot

Chkconfig NFS Onchkconfig Rpcbind on

start rpcbind and NFS

/etc/init.d/rpcbindstart/etc/init.d/nfs start

viewing NFS file conditions on the fileserver side

# Showmount-e172.16.11.15export List for172.16.11.15:/www/appdata/upload172.16.11.0/24

Mounting Parameters Introduction (can use man 8 mount to view Help)

The ro  is loaded in read-only mode. The rw  is loaded in read-write mode. The sync  performs the input and output actions of the file system in a synchronous manner. The async  performs the input and output actions of the file system in a non-synchronous manner. defaults  uses the default options. The default options are RW, suid, dev, exec, anto nouser, and async. atime  Each access updates the Inode's access time, the default setting, and the Cancel option is noatime. noatime  does not update inode access time for each access. dev  a character or block device on a readable file system, the Cancel option is Nodev. nodev  does not read characters or block devices on the file system. exec  executable binary file, cancel option is noexec. noexec  cannot execute binary file. auto  must specify this option in the/etc/fstab file. When the-a parameter is executed, the device set to Auto is loaded and deselected as Noauto. noauto  cannot use the-a parameter to load. suid  start Set-user-identifier (set User ID) with Set-group-identifer (set group ID) Set bit, cancel option is nosuid. nosuid  off Set-user-identifier (set User ID) with Set-group-identifer (set group ID) setting bit. user  Normal users can perform load operations. nouser  Normal user cannot perform load operation, default setting. remount  Reload the device. Typically used to change the device's setting state. rsize  read data buffer size, default setting 1048576 (rhel6.6). wsize  Write data buffer size, default setting 1048576 (rhel6.6). fg  is the default setting for performing Mount operations in the previous form. The normal operation response is affected when the mount fails. bg  performs a mount operation in the background form. hard  hard mount, default setting. If communication with the server fails, the operation that attempts to access it is blocked until the server recovers. soft  soft mounted. If the server communication fails, the operation that attempts to access it fails, returning an error message. This feature is useful for avoiding process "hangs" on trivial installation operations. retrans=n  specifies that an error message is returned on a file system that is installed on a softThe number of times the request was made before repeating. nointr  does not allow user interrupts, default settings. intr  allows users to interrupt blocked operations (and have them return an error message). timeo=n  sets the time-out period in one-tenth seconds for the request.


Mount the command prompt:

# mount -t nfs -onoexec,nosuid,nodev,noatime 172.16.11.15:/www/appdata/upload / www/appdata/upload/# df -hfilesystem             Size  Used Avail Use% Mounted on/dev/sda3              243G  4.8G 226G   3%  /tmpfs                  101g     0 101g   0% /dev/shm/dev/sda1              772M   32M 700M    5% /boot172.16.11.15:/www/appData/upload                       2.7t  5.8g 2.6t    1% /www/appData/upload 

write /etc/fstab to automatically take effect on the boot

172.16.11.15:/www/appdata/upload/www/appdata/upload NFS Noatime,nosuid,noexec,nodev 0 0

Mount Test

# umount/www/appdata/upload/# mount -a# df - Hfilesystem            size used avail  Use% Mounted on/dev/sda3              243G  4.8G 226G   3% /tmpfs                  101G     0  101g   0% /dev/shm/dev/sda1              772m   32m 700m   5% /boot172.16.11.15:/www/appdata/ upload                       2.7t  5.8g 2.6t   1% /www/appdata/upload 

3.2 viewing mount status and Parameters

# Cat/proc/mounts|grep Upload172.16.11.15:/www/appdata/upload/www/appdata/upload Nfs4rw,nosuid,nodev,noexec, Noatime,vers=4,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys, clientaddr=172.16.11.10,minorversion=0,local_lock=none,addr=172.16.11.150 0

using rpcinfo to view RPC information

using nfsstat to view the status of NFS

#nfsstat  -lnfs v4 client        total:   110127-------------------------- --------nfs v4 client         write:        1nfs v4 client          open:    55000nfs v4 client     open_conf:        3nfs v4 client         close:   55000nfs v4 client       setattr:        2nfs v4 client        fsinfo:        9nfs v4 client         renew:       25nfs v4  client    setclntid:        2nfs v4 client       confirm:        2nfs v4 client        access:       17nfs v4 client       getattr:       20nfs v4 client        lookup:       13nfs v4 client   lookup_root:        3nfs v4 client        remove:        1nfs v4 client      pathconf:        6nfs v4  Client       statfs:        4nfs  v4 client       readdir:        4nfs v4 client   server_caps:       15

use the-o option to view network status

Nfsstat–o Net

3.3 NFS mount optimization

NOEXEC: Do not allow binary file Nodev: Do not read characters or block devices on the file system Nosuid: Turn off Set-user-identifier (set User ID) and Set-group-identifer (set group ID) Set bit noatime: Do not update inode access time on each access


Optimizing kernel Parameters:/etc/sysctl.conf

Cat >>/etc/sysctl.conf<<eofnet.core.rmem_default=8838608net.core.wmem_default=262144net.core.rmem_ Max=16777216net.core.wmem_max=1048576eof

3.4 performance Test

Read file Speed test

# ll-h/www/appdata/upload/services-rw-r--r--1nfsnobody nfsnobody 626K September 6 14:53/www/appdata/upload/servicescp/etc/s        ervices/www/appdata/upload# Time for ((i=1;i<500;i++));d o cat/www/appdata/upload/services >/dev/null;donereal 0m1.562suser 0m0.227ssys 0m0.654s

Write file test

[[Email protected]]# time DD If=/dev/zero of=/www/appdata/upload/testbigfile bs=1mcount=1000 recorded 1000+0 read-in record 1000+0 Write-out 1048576000 bytes (1.0 GB) copied, 10.1055 sec, 104 MB/s real 0m10.109suser 0m0.002ssys 0m1.599s


This article is from the "Sunny" blog, make sure to keep this source http://francis198.blog.51cto.com/720670/1847103

NFS File system mounts and optimizations

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.