On the principle of NFS, I do not tell you here, in fact, a very simple understanding is a network disk, you need to mount it to your disk to use it. Then let's talk about the NFS network file system.
I need to use 2 machines for this experiment, I configure IP for 192.168.2.69 (server side) 192.168.2.66 (client) respectively
1, first install nfs-utils and rpcbind on the service side.
Yum insall-y nfs-utils Rpcbind
In fact, when Yum was installed, Rpcbind was installed.
2. Edit the NFS configuration file.
Vim/etc/exports
/data/192.168.2.66 (Rw,sync,no_root_squash)/data/means that the directory you want to share is 192.168.2.66 shared to, and you can write a network segment here. (rw,sync,no_root_squash) Read/write, sync, no limit root user.
Here's a place to note: There is no space between the IP and the permission, otherwise there will be an error message. (This is a mistake I often make)
Some options for NFS configuration description
RW: Read and write;
RO: Read only;
Sync: Synchronous mode, in-memory data is always written to disk;
Async: Out-of-sync, write in-memory data to disk on a regular basis;
No_root_squash: With this option, the root user has high control over the shared directory, as if it were a native directory operation. Unsafe, not recommended for use;
Root_squash: And the above options correspond to the root user permissions on the shared directory is not high, only the normal user's permission, that is, limit the root;
All_squash: Regardless of the user who uses NFS, his identity will be limited to a designated ordinary user identity;
Anonuid/anongid: To be used with Root_squash and All_squash to specify a user-defined UID and GID using NFS, provided the UID and GID exist in the/etc/passwd of this machine.
3. Start the Rpcbind NFS service.
/etc/init.d/rpcbind start (start first)
/etc/init.d/nfs start
4, the client mounts the directory.
1, you need to use the Showmount command before mounting the directory, so install Nfs-utils. Yum install-y nfs-utils.
2. See which directories are shared on the server side. SHOWMOUNT-E 192.168.2.69 can see
3, Mount. Mount-t nfs-onolock,nfsvers=3 192.168.2.69:/data//mnt/
If you do not add-onolock,nfsvers=3, there will be a variety of problems when mounting, so we want to specify that the NFS version is 3.
Df-h View the Mount status.
Second, when the server changes the configuration file, we can not restart the service, the use of Exportfs-arv can be effective, of course, you can also restart the service. At this point, the client needs to be mounted again.
Use of the EXPORTFS command
-A: Mount or uninstall all;
-R: Re-mount;
-U: Uninstalls a directory;
-V: Show shared Directories
When using NFS, one of the most common options is-o nolock
We can also write the NFS directory you want to mount to the/etc/fstab file on the client 192.168.2.69:/data//mnt NFS nolock,nfsvers-3 0 0 and then mount-a.
NFS (Network File system Setup)