NFS is often used to share storage on the network. So, you may not know much about NFS, Amin give an example of what NFS is for. If there are three machines A, B, C, they need to access the same directory, the directory is a picture, the traditional practice is to put these pictures in a, B, C. But using NFS only needs to be placed on a, then a is shared with B and C. At the time of the visit, B and C go through the network to access the directory on a
Server-side configuration NFS
The NFS service on CentOS requires the installation of two packages (Nfs-utils and Rpcbind), but the Rpcbind is installed when installing nfs-utils with Yum
650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M00/89/62/wKiom1gRkhvx6-CZAAAhzCQCJ2E074.png-wh_500x0-wm_3 -wmp_4-s_2205045325.png "title=" 1.png "alt=" Wkiom1grkhvx6-czaaahzcqcj2e074.png-wh_50 "/>
In the previous CentOS version, it is necessary to install the Portmap package, starting from CentOS6, it is easy to rpmbind the NFS configuration, only need to edit the configuration file/etc/exports. The following Amin first creates a simple NFS server.
The first is to modify the configuration file, the default file is empty, and now edit it:
Vim/etc/exports
Write the following:
650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M01/89/60/wKioL1gRktPyf_XoAAAM3bmZ3_M984.png-wh_500x0-wm_3 -wmp_4-s_776616096.png "title=" 2.png "alt=" Wkiol1grktpyf_xoaaam3bmz3_m984.png-wh_50 "/>
This configuration file is a simple line. is divided into three parts, the first part is the local directory to be shared, the second part is allowed to access the host (can be an IP can also be an IP segment) The third part is the parentheses inside, for some permission options.
Once you've edited the configuration file, it's time to start the NFS service:
650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M02/89/62/wKiom1gRk3DyFKq9AAAgx4TEWLs735.png-wh_500x0-wm_3 -wmp_4-s_2105197329.png "title=" 3.png "alt=" Wkiom1grk3dyfkq9aaagx4tewls735.png-wh_50 "/>
Before starting the NFS service, the Rpcbind service needs to be started before the old CentOS version is not rpcbind, but is called Portmap
Client Mount NFS
before the Client mounts NFS, we need to look at which directories are shared by the server, which requires the use of the Showmount command, but this command is nfs-utils the package, so it needs to be installed nfs- Utils:
650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M02/89/62/wKiom1gRlB3QpBSQAAAdYjszN2I410.png-wh_500x0-wm_3 -wmp_4-s_2180589452.png "title=" 4.png "alt=" Wkiom1grlb3qpbsqaaadyjszn2i410.png-wh_50 "/>
Now you can see which directories are shared on the server side:
650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M00/89/60/wKioL1gRlGGChe2RAAANZzr8adw784.png-wh_500x0-wm_3 -wmp_4-s_2314184641.png "title=" 5.png "alt=" Wkiol1grlggche2raaanzzr8adw784.png-wh_50 "/>
You can see the NFS shared information we have just configured on the server side. showmount - e plus IP can see the sharing of NFS, the above example, you can see the 192.168.137.10 shared directory is/home, the trusted host is 192.168.137.0/2 4 This network segment.
On the Client Mount NFS on the server side:
650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M00/89/62/wKiom1gRlI_wpIslAAAHiH7Ding446.png-wh_500x0-wm_3 -wmp_4-s_2279915763.png "title=" 6.png "alt=" Wkiom1grli_wpislaaahih7ding446.png-wh_50 "/>
650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M00/89/62/wKiom1gRlVSzWqlhAAAbz1P5aqw955.png-wh_500x0-wm_3 -wmp_4-s_1554375575.png "title=" 7.png "alt=" Wkiom1grlvszwqlhaaabz1p5aqw955.png-wh_50 "/>
With the DF - H command you can see more than one/mnt partition, which is the NFS shared directory.
In this section, there are not many commands to use, and there is a common command that is EXPORTFS, and its common option is [-aruv].
A: Mount or uninstall all;
-R: Re-mount;
-U: Uninstalls a directory;
-V: Displays the shared directory;
With the Exportfs command, after changing the/etc/exports configuration file, do not restart the NFS service directly with this exportfs, then Amin do an experiment, first change the server configuration file:
Vim/etc/exports
650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M01/89/60/wKioL1gRls3B3QXNAAAPy_0yH3Q383.png-wh_500x0-wm_3 -wmp_4-s_3593125096.png "title=" 8.png "alt=" Wkiol1grls3b3qxnaaapy_0yh3q383.png-wh_50 "/>
Then execute the command on the server:
650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M02/89/63/wKiom1gRly7yvHKoAAAOo_GUXSY502.png-wh_500x0-wm_3 -wmp_4-s_2272801489.png "title=" 9.png "alt=" Wkiom1grly7yvhkoaaaoo_guxsy502.png-wh_50 "/>
The Mount command was used in the previous command to Mount NFS, but there are some assertions about mount, the NFS service. The first is to use-t NFS to specify that the mount Type is NFS. In addition, when using NFS, one of the most common options is the-O nolock, which is not locked when the NFS service is mounted. Execute on the client:
650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M02/89/60/wKioL1gRmADz0HCPAAANtVjjNDI553.png-wh_500x0-wm_3 -wmp_4-s_614769176.png "title=" 10.png "alt=" Wkiol1grmadz0hcpaaantvjjndi553.png-wh_50 "/>
We can also write the NFS directory to be mounted to the/etc/fstab file on the client, only mount-A is required to mount. Add a line in/etc/fstab
650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M02/89/63/wKiom1gRmKGAN1_yAAAUlXgBZDc807.png-wh_500x0-wm_3 -wmp_4-s_2996059832.png "title=" 11.png "alt=" Wkiom1grmkgan1_yaaaulxgbzdc807.png-wh_50 "/>
Since it has just been mounted, uninstall it first:
650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M01/89/63/wKiom1gRmO7g5ghcAAAGLBZucUE581.png-wh_500x0-wm_3 -wmp_4-s_2878404668.png "title=" 12.png "alt=" Wkiom1grmo7g5ghcaaaglbzucue581.png-wh_50 "/>
Then execute:
650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M00/89/63/wKiom1gRmSKwryRCAAAD8cC-R8M744.png-wh_500x0-wm_3 -wmp_4-s_3327167274.png "title=" 13.png "alt=" Wkiom1grmskwryrcaaad8cc-r8m744.png-wh_50 "/>
This can also be mounted, and the boot will be automatically mounted.
650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M00/89/60/wKioL1gRmXPyII5OAAAcooXuN08223.png-wh_500x0-wm_3 -wmp_4-s_1018058740.png "title=" 14.png "alt=" Wkiol1grmxpyii5oaaacooxun08223.png-wh_50 "/>
NFS Service Configuration