The short name of the NFS (network File system) is a common way of file sharing between Linux systems, and the following is a brief description of its construction process, which requires two Linux system virtual machines. Assume that the client's IP is 192.168.1.105, and the IP on the server is 192.168.1.107.
Server: 1, install Nfs-utils and Rpcbind package.
Yum install-y nfs-utils# installs the Rpcbind together when installing Nfs-utils
2,vim/etc/exports
Add to:
/mnt 192.168.1.105 (rw,sync,all_squash,annouid=501,anongid=501) #可以是一个网段192.168.1.0/24
1, shared directory
2, allow access to IP or some segment 192.168.1.0/24
3, Options
RW, read and write
Ro, Read only
Sync, synchronous mode, writes memory data to disk in real time
Async, out-of-sync, writes memory data to disk periodically
All_squash, restrict all users, exclude users of the UID set later
Root_squash Limit Root User
No_root_squash does not restrict root user
The anonuid is used to specify a user-defined UID and GID that uses NFS.
Anongid
3, Start Rpcbind Service and NFS service
/etc/init.d/rpcbind start
/etc/init.d/nfs start
Client
1,yum install-y Nfs-utils (because of the need to use the command to Showmount)
2,SHOWMOUNT-E 192.168.1.107
Shown below,
Export list for 192.168.1.105:
/mnt 192.168.1.105
3, Mount
Mount-t nfs-o nolock-o nfsvers=3 192.168.1.105:/mnt/opt = = "Mount-t nfs-o nolock,nfsvers=3 192.168.1.105:/mnt/opt
-O nolock mount without locking the purpose is to be able to create files in this directory, modify the file time is shortened, if not added, it will take a long time to react.
-O nfsvers specifies that the version of NFS is 3 to avoid permissions clutter (without this option, the owner and owner group of the created file may be nobody)
4,df-h Viewing mounted partitions
5, create file or directory in/mnt directory prompt permission is insufficient, set the shared directory to 777 (in server segment settings)
In addition, if you change the/etc/exports configuration file, you can reload or restart the NFS service via the EXPORTFS-AVR command.
Exportfs
-A All mount or uninstall
-R Re-mount
-V Displays the contributing directory
-U Uninstalls a directory
6, if you want the system to mount this partition, Vim/etc/fstab, add the following information
192.168.1.105:/mnt/opt NFS Nolock 00
Uninstall UMOUT/MNT Mount Mount-a common error: Mount.nfs:access denied by server while mounting may be configuration error or port number greater than 1024 need to add/etc/exports under Inse Cure option or server-side directory does not have permissions [[email protected] ~]# showmount-e 192.168.1.107clnt_create:rpc:port mapper failure-unable to R Eceive:errno 113 (No route to host)
Workaround:
The firewall on the NFS server being accessed does not add a rule, add all the following ports to Iptables
#iptables-F
#service iptables Stop//firewall off
Linux Common services Deployment and optimization for NFS articles