Next, for the configuration of the NFS service, I use the CentOS6.5 operating system under the VMware virtual machine.
What is NFS?
NFS is often used to share storage on the network. I would like to say that 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, and 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, that's right.
1, the service side of the configuration
With the NFS service on CentOS, two packages (Nfs-utils and rpcbind) need to be installed, but when installing nfs-utils with Yum, the Rpcbind is installed together:
[email protected] ~]# Yum install-y nfs-utils
In the previous CentOS version, it was necessary to install the Portmap package, starting from CentOS6, and changed to Rpmbind. NFS is quite simple to configure, just 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:
[Email protected] ~]# Vim/etc/exports
Write the following content:
/HOME/192.168.84.0/24 (rw,sync,all_squash,anonuid=501,anongid=501)
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. For the third part, let me briefly say:
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.
After describing the relevant permission options above, then analyze the/etc/exports file that you just configured. The directory to be shared is/home, the trusted host is 192.168.84.0/24 this network segment, the permissions for read-write, synchronization, limited to all users, and the qualified UID and GID are 501.
Once you've edited the configuration file, it's time to start the NFS service:
[[email protected] ~]#/etc/init.d/rpcbind start; /etc/init.d/nfs start
2. Mount NFS on the client
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 you also need to install Nfs-utils:
[email protected] ~]# Yum install-y nfs-utils
Now you can see which directories are shared on the server side:
[[email protected] ~]# showmount-e 192.168.84.1Export list for 192.168.84.1:/home 192.168.84.0/24
You can see the NFS shared information we have just configured on the server side. showmount -eadd IP to see the Sharing of NFS, the above example, you can see the 192.168.84.1 shared directory is/home, the trusted host is 192.168.84.0/24 this network segment.
On the Client Mount NFS on the server side:
[[email protected] ~]# mount -t nfs 192.168.84.1:/home/ /mnt/[[email Protected] ~]# df -h File System capacity used available used%% mount point/dev/sda3 14G 6.4G 6.7G 50% /tmpfs 160m 0 160m 0% /dev/shm/dev/sda1 97M 27M 66M 29% /boot/dev/sdb5 989M 19M 920M 3% /home192.168.84.1:/home/ 989m 19m 920m 3% /mnt
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, you can use this exportfs without restarting the NFS service after changing the/etc/exports configuration file. Next we do an experiment, first change the server configuration file:
[Email protected] ~]# Vim/etc/exports
Add a line:
/TMP/192.168.84.0/24 (Rw,sync,no_root_squash)
Then execute the command on the server:
[Email protected] ~]# exportfs-arvexporting 192.168.84.0/24:/tmpexporting 192.168.84.0/24:/home
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:
[Email protected] ~]# mkdir/test[[email protected] ~]# mount-t nfs-o nolock 192.168.84.10:/tmp//test/
We can also write the NFS directory that we want to mount to the/etc/fstab file on the client, just execute it when you mount it mount -a . Add a line in/etc/fstab:
192.168.84.1:/tmp//test NFS Nolock 0 0
Since it has just been mounted, uninstall it first:
[Email protected] ~]# umount/test/
Then execute:
[Email protected] ~]# mount-a
3, temporarily speaking of this, interested in-depth understanding of friends can add me qq:754677217
This article is from the "10694514" blog, please be sure to keep this source http://10704514.blog.51cto.com/10694514/1705362
NFS Service Configuration