lab environment:
Two hosts
node4: 192.168.37.44 NFS server
node2: 192.168.37.22 Client
In nfs server, install nfs and rpcbind
[root@node4 fenxiang]#yum install rpcbind nfs -y
Create a shared directory on NFS server and shared directory export
[root @ Node4 fenxiang] # mkdir / the Data / fenxiang / [root @ Node4 exports.d] #vim /etc/exports.d/ fenxiang.exports #: Attention must be ending Exports / the Data / fenxiang 192.168 . 37.22 (rw , async, all_squash, anonuid = 99 , anongid = 99 ) #: rw read and write async asynchronous synchronization all_squash all the people in this folder build file, all mapped to the Apache anonuid set the mapping of people's UID, this article is a mapping the nobody anongid set the mapping of people's GID, this article is nobody map
In the NFS server as a shared directory permissions settings
[Root @ node4 fenxiang] #setfacl -mu: nobody: rwx / data / fenxiang / #: permissions and user mappings to be consistent, otherwise you can not write to the client mount
View and end customers begin to mount
[root@node2 mnt]#showmount -e 192.168.37.44 Export list for 192.168.37.44: /data/fenxiang 192.168.37.22 [root@node2 mnt]#vim /etc/fstab 192.168.37.44:/data/fenxiang /mnt nfs defaults 0 0
[root@node2 mnt]#mount -a
Now you can normally use
Autofs mounts rules to achieve (achieve shared home directory)
Autofs package filled not confirm the client
[root@node2 mnt]#rpm -q autofs autofs-5.0.7-99.el7.x86_64
In the end the export NFS home directory needs to be shared
[@ Node4 the root exports.d] #vim /etc/exports.d/ ma.exports / Home / ma 192.168 . 37.22 (RW, the async, the all_squash, the anonuid = 1003 , anongid = 1003 ) # 1003 is the UID and user ma gid
In the client configuration autofs (absolute path method, the user's home directory or other directory will be overwritten)
[root @ node2 ma] #vim / etc / the auto.master / - / etc / auto.ma #: / - Fixed wording /etc/auto.ma specified profile ma
[root @ node2 ma] #vim / etc / auto.ma
/ home / ma -fstype = nfs 192.168.37.44:/home/ma
#: ma first paragraph client's home directory
second paragraph of the type specified mount
the third paragraph NFS server to share out the directory
Restart Service
[root@node2 ma]#systemctl restart autofs
This will automatically mount when implementing access