Nfs server is used on many systems and hosts. So many friends also asked how to implement the nfs server application on Linux. Here we will summarize how to create an nfs server and hope to help you.
I. LINUX is used as an example for server configuration)
Server-side settings are all set in the/etc/exports file. The format is as follows:
Host Name 1 or IP1 (parameter 1, parameter 2) host name 2 or IP2 parameter 3, parameter 4)
The above format indicates that the same directory is shared to two different hosts, but the permissions and parameters provided to these two hosts are different. Therefore, the permissions obtained by the two hosts are set separately.
You can set the following parameters:
Rw: read/write permission;
Ro: Read-Only permission;
No_root_squash: if the user logging on to the NFS host is a ROOT user, the user has the ROOT permission. this parameter is insecure and is not recommended.
Root_squash: Are you logged on to the NFS master? C. What is the purpose of sharing? If the user is the user's identity;
All_squash: No matter what users log on to the NFS host, they will be reset to nobody.
Anonuid: sets all users logging on to the NFS host to the specified user id, which must exist in/etc/passwd.
Anongid: Same as anonuid,? Group ID!
Sync: data is synchronized to the storage.
Async: The data is temporarily stored in the memory and not directly written to the hard disk.
Insecure allows unauthorized access from this machine.
For example, you can edit/etc/exports as follows:
/Tmp * (rw, no_root_squash)
/Home/public 192.168.0. * (rw) * (ro)
/Home/test 192.168.0.100 (rw)
/Home/linux * .the9.com (rw, all_squash, anonuid = 40, anongid = 40)
After setting, run the following command to start NFS:
/Etc/rc. d/init. d/portmap start (PORTMAP is started by default in REDHAT)
/Etc/rc. d/init. d/nfs start
Exportfs command:
If we modify/etc/exports after starting NFS, do we have to restart nfs? At this time, we can use the exportfs command to make the change take effect immediately. The command format is as follows:
Exportfs [-aruv]
-A: All content in mount or unmount/etc/exports
-R: Re-mount the directory shared in/etc/exports
-U: umount directory
-V: in export? R wait, and output the detailed information to the screen.
Example:
[Root @ test root] # exportfs-rv <= All are re-export once!
Exporting 192.168.0.100:/home/test
Exporting 192.168.0. *:/home/public
Exporting * .the9.com:/home/linux
Exporting *:/home/public
Exporting *:/tmp
Reexporting 192.168.0.100:/home/test to kernel
Exportfs-au <= All are uninstalled.