NFS (Baidu Encyclopedia): 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.
NFS relies on the RPC protocol during file transfer or information transfer. RPC, remote procedure invocation (Procedure call) is a mechanism that enables clients to perform programs in other systems. NFS itself does not provide the protocol and functionality for transmitting information, but NFS allows us to share information over the network, because NFS uses some other transport protocols. And these transport protocols are used for this RPC function. It can be said that NFS itself is a program that uses RPC. Or, NFS is also an RPC SERVER. So whenever you use NFS, you start the RPC service, whether it's NFS server or NFS CLIENT. This allows the server and client to implement the program port correspondence via RPC. You can understand the relationship between RPC and NFS: NFS is a file system, and RPC is responsible for the transfer of information.
Experimental Environment Preparation: Server centos6.7,ip:192.168.1.3; client machine test,ip:192.168.1.6; Two machines can communicate, that is, to ping each other, turn off the server Firewall (command: Service iptables Stop) and Sexlinux (command: Setenforce 0).
Configuration steps:
1. Installing NFS on the client
Yum Install nfs* (This will download the dependent software, including Portmap)
2. Modify the configuration file (default open is blank)
Vi/etc/exports
Add one:/home/dong * (rw)
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/82/EB/wKiom1dk8FKw1aOJAAASm4vz8Ms291.jpg "title=" 0.1. JPG "alt=" wkiom1dk8fkw1aojaaasm4vz8ms291.jpg "/>
(Note: The 2.0 NFS configuration file is/etc/exports and the content format is as follows:
< shared directory > Client 1 (Options) [Client 2 (Options) ...]
Shared directory: The directory that NFS shares to the client.
Client: A host in the network that can access this directory. Multiple clients are separated by a space.
Options: Set access permissions for the directory, user mappings, and more, with multiple options separated by commas.
For example: /home/dong 1 92.168.1.0/24 (rw,insecure,sync,all_squash,anonuid= 65534,anongid=65534)
2.1 How clients are specified
Specify the IP address of the host: 192.168.0.100 or Specify all hosts in the subnet: 192.168.0.0/24 or 192.168.0.0/255.255.255.0 designation host of the domain name: nfs.test.com Specify all hosts in the domain: *.test.com
All hosts: *
2.2 Description of options
RO: Shared directory read only;
RW: The shared directory can be read and writable;
All_squash: All access users are mapped to anonymous users or user groups;
No_all_squash (default): The Access user first matches the native user, the match fails and then maps to the 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 has the root account privileges;
ANONUID=<UID>: Specifies the local user UID of the anonymous access user, which defaults to Nfsnobody (65534);
Anongid=<gid>: Specifies the local user group of the anonymous Access user GID, default is Nfsnobody (65534);
Secure (default): Restricts the client from connecting to the server only from TCP/IP ports less than 1024;
Insecure: Allow clients to connect to the server from TCP/IP ports greater than 1024;
Sync: It is inefficient to write data synchronously to memory buffer and disk, but it can guarantee the consistency of data;
Async: Save the data in the memory buffer first, and write to disk if necessary;
Wdelay (default): Check if there is a related write operation, if any, then perform these writes together, which can improve the 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; )
3. Start NFS Service: Service NFS start will get up four services
650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M01/82/EB/wKiom1dk8PrhXXi4AADBRih6Xn8195.jpg-wh_500x0-wm_3 -wmp_4-s_2517158744.jpg "title=" 1.jpg "alt=" Wkiom1dk8prhxxi4aadbrih6xn8195.jpg-wh_50 "/>
4. Mount on Client
650) this.width=650; "src=" http://s2.51cto.com/wyfs02/M01/82/EB/wKiom1dk8jzSuTpYAAAUgwBjw1Y490.jpg "title=" 2.jpg " alt= "Wkiom1dk8jzsutpyaaaugwbjw1y490.jpg"/>
If there is an error, it is recommended that you install the following NFS-related applications on the client side, because there are many error cases, after installation: Yum install-y nfs*
5. See if the contents of the directory you are mounting appear on the server side , if there is no problem to prove the success of the experiment, to this end, please go to the back to see the configuration of automatic mounting, if you find that you do not have permission to appear below the picture of the situation
650) this.width=650; "src=" http://s5.51cto.com/wyfs02/M00/82/EB/wKiom1dk9Cay_g6VAAAkcJbxWiY764.jpg "title=" 3.jpg " alt= "Wkiom1dk9cay_g6vaaakcjbxwiy764.jpg"/>
Go to Server View permissions for shared directories
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/82/EB/wKiom1dk9InAOpvnAAAUv1IlIbI879.jpg "title=" 4.1. JPG "alt=" wkiom1dk9inaopvnaaauv1ilibi879.jpg "/>
If you find that the permissions of other users and other users in the same group are---, execute the following command
650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M01/82/EA/wKioL1dk9OKhuXNBAACFQ76Xpus844.jpg-wh_500x0-wm_3 -wmp_4-s_980683981.jpg "title=" 4.jpg "alt=" Wkiol1dk9okhuxnbaacfq76xpus844.jpg-wh_50 "/>
Set permissions and then return to the client to view the mounted directory discovery to see the exact same file.
650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M01/82/EB/wKiom1dk9SSAID4GAAB0OKBjX18345.jpg-wh_500x0-wm_3 -wmp_4-s_1829653855.jpg "title=" 5.jpg "alt=" Wkiom1dk9ssaid4gaab0okbjx18345.jpg-wh_50 "/>
In/mnt, you can create and delete files.
To configure the end of NFS, the following is the inconvenience of having to enter a long mount command each time the client is powered on, followed by the configuration that the client automatically mounts:
1. Install the software on the client AutoFS
650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M02/82/EA/wKioL1dk9qmhFmTXAACIg2_JYYo557.jpg-wh_500x0-wm_3 -wmp_4-s_2293933530.jpg "title=" 6.jpg "alt=" Wkiol1dk9qmhfmtxaacig2_jyyo557.jpg-wh_50 "/>
2. Modify the master configuration file Vim/etc/auto.master
Add a /home/text-autonfs/etc/auto.nfs
/home/autofs-test does not need to exist for this directory to be automatically created after mounting.
3. Edit Auto.nfs (not originally present, automatically created when editing)
Vi/etc/auto.nfs
Add one: dong-rw 192.168.1.3:/home/dong
4. Restart the AutoFS service
Serveice autofs Restart
650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M00/82/EA/wKioL1dk-UTQ__zxAAAkLoR7EsE733.jpg-wh_500x0-wm_3 -wmp_4-s_2064229193.jpg "title=" 6.1.jpg "alt=" Wkiol1dk-utq__zxaaaklor7ese733.jpg-wh_50 "/>
5. Test: Uninstall the original mount, enter only the command: Mount will automatically mount the set of commands.
650) this.width=650; "src=" http://s4.51cto.com/wyfs02/M02/82/EB/wKiom1dk-k6BmP8WAAAe0opcN20202.jpg "title=" 5.jpg " alt= "Wkiom1dk-k6bmp8waaae0opcn20202.jpg"/>
6. View the automatically generated mount directory
650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M01/82/EB/wKiom1dk-ujS53YdAAA0J0OXkYo373.jpg-wh_500x0-wm_3 -wmp_4-s_2033129018.jpg "title=" 4.jpg "alt=" Wkiom1dk-ujs53ydaaa0j0oxkyo373.jpg-wh_50 "/>
7. View the mounted directory and discover that the mapping was successful.
Ls/mnt/test-autonfs/dong
650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M02/82/EB/wKiom1dk_QOBFdbpAABpUhBucYE937.jpg-wh_500x0-wm_3 -wmp_4-s_2744510065.jpg "title=" 8.jpg "alt=" Wkiom1dk_qobfdbpaabpuhbucye937.jpg-wh_50 "/>
Ok!
This article is from the "Li Xiaodong" blog, make sure to keep this source http://lixiaodong2016.blog.51cto.com/11693292/1790620
Configuring NFS servers and setting up automatic mounts under Linux (take centos6.7 as an example)