[What is NFS] NFS = Network File System [count] Network File System www.2cto.com
NFS is often used to share storage on the network. In this case, you may not know much about NFS.
Here is an example of what NFS is used. If there are three machines A, B, and C, they need to access the same
Directories are all images. The traditional method is to put these images in A, B, and C respectively. However, NFS only requires
Put it on A and share A with B and C. B and C access A through the network.
The directory on. [Configure NFS]
NFS configuration is quite simple. You only need to edit the configuration file/etc/exports. Next, I will first create
A simple NFS server. [Root @ localhost ~] # Cat/etc/exports
/Home/10.0.2.0/24 (rw, sync, all_squash, anonuid = 501, anongid = 501)
This configuration file is a simple line. There are three parts in total. The first part is the local directory to be shared, and the second
The third part is in parentheses,
For some permission options. For the third part, I will briefly introduce:
Www.2cto.com
Rw: read/write;
Ro: Read-only;
Sync: synchronization mode. Data in the memory is always written to the disk;
Async: the data in the memory is periodically written to the disk;
No_root_squash: with this option added, the root user will have the highest permission control over the shared directory
It is like operating the local directory. Not secure. not recommended;
Root_squash: corresponds to the preceding options. The root user has low permissions on the shared directory and only has the permissions of common users,
Root; all_squash: no matter who the NFS user is, his identity will be limited to a specified normal user identity;
Anonuid/anongid: used with root_squash and all_squash to specify NFS users.
The uid and gid after the limitation, provided that the uid and gid exist in the/etc/passwd of the local machine.
After introducing the relevant permission options above, let's analyze the/etc/exports file that I just configured.
The directory to be shared is/home, the trusted host is 10.0.2.0/24, the permission is read/write, synchronization, Limited
All users, and the specified uid and gid are both 501. Www.2cto.com [Use NFS]
After editing the configuration file/etc/exports, start the NFS service. Start method:
[Root @ localhost ~] # Service portmap start; service nf sstartNFS relies on portmap. Therefore, you must first start portmap and then start NFS to make the configuration take effect.
After starting NFS, you should use the NFS service. [Root @ localhost ~] # Showmount e 127.0.0.1 (used on client)
With shoumount-e and IP address, you can view NFS sharing. In the previous example, you can see sharing of 127.0.0.1.
The directory is/home, And the trusted host is 10.0.2.0/24. In addition, this showmount command also has a common
The option is-a, which means to list all NFS clients connected to the local machine.
[Root @ localhost ~] # Mount t nfs 10.0.2.69:/home/mnt (on the client)
[Root @ localhost ~] # Showmount-a (on the nfs server)
Allmountpointsonlocalhost: 10.0.2.69:/home
The preceding mount command is used to mount the NFS shared directory. We believe you can understand this format. Showmount-a command to list
All clinet.
Another common command in the NFS service www.2cto.com is exportfs. Its common option is [-aruv].
-A: Mount or detach all;
-R: remount;
-U: unmount a directory;
-V: displays the shared directory;
Use the exportfs command to directly use the exportfs after changing the/etc/exports configuration file.
You can. [Root @ localhost ~] # Cat/etc/exports
/Tmp/10.0.2.0/24 (rw, sync, no_root_squash)
[Root @ localhost ~] # Exportfs-arv (on the nfs server)
Exporting10.0.2.0/24:/tmp
After the directory is changed, exportfs-arv takes effect directly.
The mount command is used to mount nfs. In fact, mount this nfs service is still mentioned. First
Use-tnfs to specify the mounting type as nfs. In addition, when nfs is used, a common option is nolock, that is
The nfs service is not locked. [Root @ localhost ~] # Mount t nfs o nolock 10.0.2.69:/tmp/mnt/
[Root @ localhost ~] # Showmount-
All mountpointsonlocalhost:
10.0.2.69:/home
10.0.2.69:/tmp
In addition, you can also write the nfs directory to be mounted to the/etc/fstab file on the client.
-. After writing the/etc/fstab file, you only need to mount-a to mount the shared directory of the nfs service.
[Root @ localhost ~] # Umount/mnt/First unmount the mounted nfs
[Root @ localhost ~] # Mount-
[Root @ localhost ~] # Df-h about NFS. I believe you will be able to master it soon!