Home > OS >  Linux NFS
Linux NFS

Time:10-07

The service side
1, (192.168.1.10) server, the client (192.168.1.20) set IP
2, root @ server Desktop # yum - y install NFS NFS service
*//# 3, root @ server Desktop systemctl restart rpcbind. Service//start the RPC
[root @ server Desktop] # netstat TPLN | grep, 111//view port
TCP 0 0 0.0.0.0:0.0.0.0:111 * 4898/LISTEN rpcbind
Tcp6 0 0: : : 111: : : * LISTEN 4898/rpcbind
4, root @ server Desktop # mkdir/redhat//create the Shared directory
[root @ server redhat] # & gt; Nfs1//to create a test file
[root @ server redhat] # & gt; Nfs2
# 5, root @ server Desktop vim/etc/exports//edit configuration files
//redhat 192.168.1.0 255.255.255.0 (rw, sync)
Shared file options
# 6, root @ server Desktop exportfs - v//view Shared
/redhat 192.168.1.20/255.255.255.0 (rw, wdelay root_squash, no_subtree_check, the SEC=sys, rw, secure and root_squash, no_all_squash)
# 7, root @ server redhat systemctl stop firewalld. Service//close the firewall
[root @ server redhat] # setenforce 0//disable selinux firewall
The client
8, [root @ client Desktop] # showmount -e 192.168.1.10//to check the network share
The Export list for 192.168.1.10:
//redhat 192.168.1.0 255.255.255.0
# 9, [root @ client MNT] mount -t NFS 192.168.1.10:/redhat/MNT/Chen//mount
[root @ client MNT] # df -h//look at mount
The Filesystem Size, informs the Avail Use % Mounted on
/dev/mapper/rhel - 27 G 11% root 30 G, 3.2 G/
Devtmpfs 904 m 0 904 m 0%/dev
TMPFS 914 m 140 k 914 m 1%/dev/SHM
TMPFS 914 M, 8.9 M 905 M 1%/run
TMPFS 914 m 0 914 m 0%/sys/fs/cgroup
/dev/sda1 497 m 124 m 373 m 25%/boot
/dev/sr0 3.7 G 3.7 G 0 100%/run/media/root/RHEL 7.1 Server x86_64
192.168.1.10:35 G 9%/redhat 38 G 3.2 G/MNT/Chen
[root @ client MNT] # CD/MNT/Chen/
[root @ client Chen] # ls
Nfs1 nfs2

Create a file and folder
Server/redhat folder permissions by default is 644, the client for someone else, so can't create a file, should change permissions 777
[root @ server redhat] # chmod 777/redhat/
[root @ server redhat] # ll/
28 Jun 22 and redhat DRWXRWXRWX. 2 root root
[root @ client Chen] # & gt; Nfs3
[root @ client Chen] # ll
Total 0
Rw - r - r -. 1 root root 0 Jun 22 and nfs1
Rw - r - r -. 1 root root 0 Jun 22 and nfs2
Rw - r - r -. 1 nfsnobody nfsnobody 0 Jun 22 nfs3 seated

Explain nfsnobody
[Chen @ client Chen] $& gt; Nfs4//using ordinary users to create file
[Chen @ client Chen] $ll
Total 0
Rw - r - r -. 1 root root 0 Jun 22 and nfs1
Rw - r - r -. 1 root root 0 Jun 22 and nfs2
Rw - r - r -. 1 nfsnobody nfsnobody 0 Jun 22 nfs3 seated
- rw - rw - r -. 1 Chen Chen 0 Jun 22 10:44 nfs4
With Chen, the user to create documents, user belongs to group for Chen, only the root user is nfsnobody
Nfsnobody distinguish between root and client server root

Let the root user is displayed as the root
Option root_squash: the default, root writing displayed as nfsnobody
Let the root user is displayed as a root only need to change the options for no_root_squash
[root @ server redhat] # vim/etc/exports//edit configuration files
//redhat 192.168.1.0 255.255.255.0 (rw, sync, no_root_squash)
[root @ server redhat] # systemctl restart the NFS//refresh the NFS service
[root @ server redhat] # exportfs - v//view, options change success
//redhat 192.168.1.0 255.255.255.0 (rw, wdelay no_root_squash, no_subtree_check, the SEC=sys, rw, secure, no_root_squash, no_all_squash)
[root @ client Chen] # & gt; Nfs5//test
[root @ client Chen] # ll
Total 0
Rw - r - r -. 1 root root 0 Jun 22 and nfs1
Rw - r - r -. 1 root root 0 Jun 22 and nfs2
Rw - r - r -. 1 nfsnobody nfsnobody 0 Jun 22 nfs3 seated
- rw - rw - r -. 1 Chen Chen 0 Jun 22 10:44 nfs4
Rw - r - r -. 1 root root 0 Jun 22 10:58 nfs5//user belongs to group for the root

Belongs to the user and group they belong to (deposit for the client's user and group)
[root @ client Chen] # useradd -u 1234 sai//to create user
[root @ client Chen] # id sai
Uid=1234 (sai) gid=1234 (sai) groups=1234 (sai)
[root @ client/] # umount/MNT/Chen///uninstall NFS
[root @ client/] # df -h
The Filesystem Size, informs the Avail Use % Mounted on
/dev/mapper/rhel - 27 G 11% root 30 G, 3.2 G/
Devtmpfs 904 m 0 904 m 0%/dev
TMPFS 914 m 140 k 914 m 1%/dev/SHM
TMPFS 914 M, 8.9 M 905 M 1%/run
TMPFS 914 m 0 914 m 0%/sys/fs/cgroup
/dev/sda1 497 m 124 m 373 m 25%/boot
/dev/sr0 3.7 G 3.7 G 0 100%/run/media/root/RHEL 7.1 Server x86_64
[root @ server redhat] # vim/etc/exports//edit configuration files
//redhat 192.168.1.0 255.255.255.0 (rw, sync, no_root_squash, anonuid=1234, anongid=1234)
[root @ server redhat] # systemctl restart the NFS//refresh the NFS service
nullnullnullnullnullnullnullnullnullnullnull
  • Related