I NFS common service management 1.1 start NFS
1 [[email protected] ~] # Systemctl start NFS # Start centos7.x Series 2 3 [[email protected] ~] # Service NFS start # centos6.x series startup
1.2 view the status
1 [[email protected] ~] # Systemctl status NFS # view the centos7.x Series 2 3 [[email protected] ~] # Ervice NFS status # view centos6.x Series
1.3 Stop Service
1 [[email protected] ~] # Systemctl stop NFS # centos7.x series stop 2 3 [[email protected] ~] # Service NFS stop # Stop centos6.x Series
1.4 set startup
1 [[email protected] ~] # Systemctl Enable NFS # centos7.x series self-starting 2 3 [[email protected] ~] # Chkconfig NFS on # centos6.x series self-starting
2. Install NFS
[[Email protected] ~] # Yum-y install nfs-utils *
3. Configure as needed
Requirement: create a file server with the NSF shared path "/mywork" so that all visitors can hide the anonymous user "nfsnobody" and have the read and write permissions. The visitor regards this as the root directory.
4. Create a shared directory
1 [[email protected] ~] # Mkdir/mywork # create a directory for NFS sharing 2 3 [[email protected] ~] # Chown nfsnobody/mywork/# change the directory owner to nfsnobody. It is strongly not recommended to change the permission to 777 4 5 [[email protected] ~] # Vi/etc/exports # modify the configuration file 6 7/mywork 192.168.10.0/24 as needed (RW, all_squash, sync, fsid = 0) 8 9 # fsid = 0 indicates packing the/mywork Directory into the root directory
5. Check and disable firewall 5.1
1 [[email protected] ~]# exportfs 2 3 /mywork 192.168.10.0/24
5.2 disable SELinux and Firewall
1 [[email protected] ~]# setenforce 0 2 3 [[email protected] ~]# iptables -F
5.3 restart the service
1 [[email protected] ~]# systemctl restart nfs
6. Verify and test 6.1 install NFS on the client
1 [[email protected] ~] # Yum-y install nfs-utils.x86_64 # After installation, the client does not need to start the NFS service 2 3 [email protected] ~] # Showmount-e 192.168.10.10 # test whether the link can be 4 5 Export list for 192.168.10.10: 6 7/mywork 192.168.10.0/24
6.2 mount the client to the Local Machine
1 [[email protected] ~] # Mkdir/Data 2 3 [[email protected] ~] # Mount-t nfs 192.168.10.10:/mywork/data/4 5 [[email protected] ~] # Vi/etc/fstab # Mount 6 7 192.168.10.10 on startup: /mywork/Data NFS defaults 0 0 8 9 # You can also add TCP to enable NFS to transmit 10 11 [[email protected] ~] over TCP. # Mount-A 12 13 [[email protected] ~] # DF-th 14 15 filesystem type size used avail use % mounted on 16 17 ...... 18 19 192.168.10.10:/mywork NFS 18g 5.9G 12g 33%/Data 20 21 [email protected] ~] # Cd/data/22 23 [[email protected] data] # Touch test.txt 24 25 [[email protected] data] # ls-L 26 27 total 0 28 29-RW-R -- r --. 1 nfsnobody 0 Sep 3 0:04 test.txt
Appendix: Permission analysis attachment. 1 check common users during Client Connection
- If the identity of a common user is clearly set, the client user's identity is converted to a specified user;
- If the NFS server has a user with the same name, the identity of the client Logon account is converted to the user with the same name on the NFS server;
- If no user with the same name is specified, the user identity is compressed into nfsnobody;
Attachment. 2 Check root during Client Connection
- If no_root_squash is set, the root user's identity is compressed to the root on the NFS server;
- If all_squash, anonuid, and anongid are set, the root identity is compressed to the specified user;
- If not explicitly specified, the root user is compressed to nfsnobody;
- If both no_root_squash and all_squash are specified, the user will be compressed to nfsnobody. If anonuid and anongid are set, they will be compressed to the specified user and group;
003. NFS configuration instance