1、掌握Linux系统之间资源共享和互访方法
2、掌握NFS服务器和客户端的安装与配置方法
3、掌握客户端挂载共享目录并使用的方法
4、掌握NFS访问权限的各种配置方法
5、了解NFS服务器的端口使用以及配置方法
[root@centos-a1 ~]# yum install nfs-utils -y [root@centos7-a3 ~]# yum install nfs-utils -y2、服务端创建共享资源目录/mnt/nfs/nfs1_ro,编辑NFS系统配置文件,指定可访问的网段,指定只读及同步
[root@centos-a1 ~]# mkdir /mnt/nfs/nfs1_ro -p [root@centos-a1 ~]# vim /etc/exports /mnt/nfs/nfs1_ro 192.168.111.0/24(ro,sync)3、服务端启动nfs-server服务,并设置自动运行,并检查服务器本地资源抛出,并查看服务端口运行情况
[root@centos-a1 ~]# systemctl start nfs-server [root@centos-a1 ~]# systemctl enable nfs-server Created symlink from /etc/systemd/system/multi-user.target.wants/nfs-server.service to /usr/lib/systemd/system/nfs-server.service. [root@centos-a1 ~]# showmount -e localhost Export list for localhost: /mnt/nfs/nfs1_ro 192.168.111.0/24 [root@centos-a1 ~]# netstat -an | grep :2049 tcp 0 0 0.0.0.0:2049 0.0.0.0:* LISTEN tcp6 0 0 :::2049 :::* LISTEN udp 0 0 0.0.0.0:2049 0.0.0.0:* udp6 0 0 :::2049 :::*4、检查服务器支持NFS版本(v2不支持,v3、v4使用方式不同)
[root@centos-a1 ~]# cat /proc/fs/nfsd/versions -2 +3 +4 +4.1 +4.25、客户端检查服务端的共享资源抛出,并创建本地挂载目录,挂载服务端的共享资源,检查测试确认
[root@centos7-a3 ~]# vim /etc/exports [root@centos7-a3 ~]# rm -rf /etc/exports [root@centos7-a3 ~]# showmount -e 192.168.111.21 Export list for 192.168.111.21: /mnt/nfs/nfs1_ro 192.168.111.0/24 [root@centos7-a3 ~]# mkdir /mnt/nfs/files1 -p [root@centos7-a3 ~]# mount 192.168.111.21:/mnt/nfs/nfs1_ro /mnt/nfs/files1 [root@centos7-a3 ~]# df -hT Filesystem Type Size Used Avail Use% Mounted on /dev/sda2 xfs 10G 3.4G 6.7G 34% / devtmpfs devtmpfs 471M 0 471M 0% /dev tmpfs tmpfs 487M 0 487M 0% /dev/shm tmpfs tmpfs 487M 8.6M 478M 2% /run tmpfs tmpfs 487M 0 487M 0% /sys/fs/cgroup /dev/sda3 xfs 10G 37M 10G 1% /home /dev/sda6 xfs 28G 297M 28G 2% /var /dev/sda1 xfs 497M 167M 330M 34% /boot tmpfs tmpfs 98M 4.0K 98M 1% /run/user/42 tmpfs tmpfs 98M 28K 98M 1% /run/user/1000 /dev/sr0 iso9660 4.3G 4.3G 0 100% /run/media/stu/CentOS 7 x86_64 tmpfs tmpfs 98M 0 98M 0% /run/user/0 192.168.111.21:/mnt/nfs/nfs1_ro nfs4 10G 3.4G 6.7G 34% /mnt/nfs/files16、测试服务端以及客户端的NFS运行状态,检查确认
[root@centos7-a3 ~]# nfsstat -m /mnt/nfs/files1 from 192.168.111.21:/mnt/nfs/nfs1_ro Flags: rw,relatime,vers=4.1,rsize=131072,wsize=131072,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,clientaddr=192.168.111.23,local_lock=none,addr=192.168.111.21 [root@centos7-a3 ~]# nfsstat -c Client rpc stats: calls retrans authrefrsh 26 0 26 Client nfs v4: null read write commit open open_conf 0 0% 0 0% 0 0% 0 0% 0 0% 0 0% open_noat open_dgrd close setattr fsinfo renew 0 0% 0 0% 0 0% 0 0% 3 12% 0 0% setclntid confirm lock lockt locku access 0 0% 0 0% 0 0% 0 0% 0 0% 3 12% getattr lookup lookup_root remove rename link 2 8% 4 16% 1 4% 0 0% 0 0% 0 0% symlink create pathconf statfs readlink readdir 0 0% 0 0% 2 8% 1 4% 0 0% 0 0% server_caps delegreturn getacl setacl fs_locations rel_lkowner 5 20% 0 0% 0 0% 0 0% 0 0% 0 0% secinfo exchange_id create_ses destroy_ses sequence get_lease_t 0 0% 0 0% 1 4% 1 4% 0 0% 0 0% reclaim_comp layoutget getdevinfo layoutcommit layoutreturn getdevlist 0 0% 1 4% 0 0% 0 0% 0 0% 0 0% (null) 1 4% [root@centos-a1 ~]# nfsstat -s Server rpc stats: calls badcalls badclnt badauth xdrcall 27 0 0 0 0 Server nfs v4: null compound 1 3% 26 96% Server nfs v4 operations: op0-unused op1-unused op2-future access close commit 0 0% 0 0% 0 0% 3 3% 0 0% 0 0% create delegpurge delegreturn getattr getfh link 0 0% 0 0% 0 0% 21 25% 5 6% 0 0% lock lockt locku lookup lookup_root nverify 0 0% 0 0% 0 0% 4 4% 0 0% 0 0% open openattr open_conf open_dgrd putfh putpubfh 0 0% 0 0% 0 0% 0 0% 20 24% 0 0% putrootfh read readdir readlink remove rename 2 2% 0 0% 0 0% 0 0% 0 0% 0 0% renew restorefh savefh secinfo setattr setcltid 0 0% 0 0% 0 0% 0 0% 0 0% 0 0% setcltidconf verify write rellockowner bc_ctl bind_conn 0 0% 0 0% 0 0% 0 0% 0 0% 0 0% exchange_id create_ses destroy_ses free_stateid getdirdeleg getdevinfo 1 1% 1 1% 0 0% 0 0% 0 0% 0 0% getdevlist layoutcommit layoutget layoutreturn secinfononam sequence 0 0% 0 0% 0 0% 0 0% 1 1% 24 28% set_ssv test_stateid want_deleg destroy_clid reclaim_comp 0 0% 0 0% 0 0% 0 0% 1 1%7、客户端测试服务器共享资源目录的可读权限,检查确认
[root@centos-a1 ~]# cd /mnt/nfs/nfs1_ro/ [root@centos-a1 nfs1_ro]# ll total 0 [root@centos-a1 nfs1_ro]# echo "123456" > 1.txt [root@centos-a1 nfs1_ro]# cat 1.txt 123456 [root@centos7-a3 ~]# cd /mnt/nfs/files1/ [root@centos7-a3 files1]# ll total 4 -rw-r--r-- 1 root root 7 Jun 12 20:44 1.txt [root@centos7-a3 files1]# cat 1.txt 123456 [root@centos7-a3 files1]# touch 2.txt touch: cannot touch ‘2.txt’: Read-only file system8、查看开机启动程序rc.local的权限,并对该程序增加操作权,将挂载命令写入开机启动程序使能自动挂载,并重启确认。(不建议写入/etc/fstab文件)
[root@centos7-a3 files1]# ll -d /etc/rc.d/rc.local -rw-r--r--. 1 root root 473 Oct 31 2018 /etc/rc.d/rc.local [root@centos7-a3 files1]# chmod +x /etc/rc.d/rc.local [root@centos7-a3 files1]# ll -d /etc/rc.d/rc.local -rwxr-xr-x. 1 root root 473 Oct 31 2018 /etc/rc.d/rc.local [root@centos7-a3 files1]# vim /etc/rc.d/rc.local #!/bin/bash # THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES # # It is highly advisable to create own systemd services or udev rules # to run scripts during boot instead of using this file. # # In contrast to previous versions due to parallel execution during boot # this script will NOT be run after all other services. # # Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure # that this script will be executed during boot. touch /var/lock/subsys/local mount 192.168.111.21:/mnt/nfs/nfs1_ro /mnt/nfs/files1 [root@centos7-a3 ~]# umount /mnt/nfs/files1 [root@centos7-a3 ~]# df -hT Filesystem Type Size Used Avail Use% Mounted on /dev/sda2 xfs 10G 3.4G 6.7G 34% / devtmpfs devtmpfs 471M 0 471M 0% /dev tmpfs tmpfs 487M 0 487M 0% /dev/shm tmpfs tmpfs 487M 8.4M 478M 2% /run tmpfs tmpfs 487M 0 487M 0% /sys/fs/cgroup /dev/sda3 xfs 10G 37M 10G 1% /home /dev/sda6 xfs 28G 295M 28G 2% /var /dev/sda1 xfs 497M 167M 330M 34% /boot tmpfs tmpfs 98M 8.0K 98M 1% /run/user/42 tmpfs tmpfs 98M 0 98M 0% /run/user/0 [root@centos7-a3 files1]# reboot [root@centos7-a3 ~]# df -hT Filesystem Type Size Used Avail Use% Mounted on /dev/sda2 xfs 10G 3.4G 6.7G 34% / devtmpfs devtmpfs 471M 0 471M 0% /dev tmpfs tmpfs 487M 0 487M 0% /dev/shm tmpfs tmpfs 487M 8.2M 479M 2% /run tmpfs tmpfs 487M 0 487M 0% /sys/fs/cgroup /dev/sda3 xfs 10G 37M 10G 1% /home /dev/sda6 xfs 28G 296M 28G 2% /var /dev/sda1 xfs 497M 167M 330M 34% /boot 192.168.111.21:/mnt/nfs/nfs1_ro nfs4 10G 3.4G 6.7G 34% /mnt/nfs/files1 tmpfs tmpfs 98M 8.0K 98M 1% /run/user/42 tmpfs tmpfs 98M 0 98M 0% /run/user/09、服务器端创建共享资源目录/mnt/nfs/nfs2_rw,编辑配置文件,指定网段,指定可读写及同步,客户端挂载
[root@centos-a1 nfs1_ro]# mkdir /mnt/nfs/nfs2_rw [root@centos-a1 nfs1_ro]# vim /etc/exports /mnt/nfs/nfs1_ro 192.168.111.0/24(ro,sync) /mnt/nfs/nfs2_rw 192.168.111.0/24(rw,sync) [root@centos-a1 nfs1_ro]# exportfs -r [root@centos7-a3 ~]# mkdir /mnt/nfs/files2 [root@centos7-a3 ~]# mount 192.168.111.21:/mnt/nfs/nfs2_rw /mnt/nfs/files2 [root@centos7-a3 ~]# df -hT Filesystem Type Size Used Avail Use% Mounted on /dev/sda2 xfs 10G 3.4G 6.7G 34% / devtmpfs devtmpfs 471M 0 471M 0% /dev tmpfs tmpfs 487M 0 487M 0% /dev/shm tmpfs tmpfs 487M 8.4M 478M 2% /run tmpfs tmpfs 487M 0 487M 0% /sys/fs/cgroup /dev/sda3 xfs 10G 37M 10G 1% /home /dev/sda6 xfs 28G 296M 28G 2% /var /dev/sda1 xfs 497M 167M 330M 34% /boot 192.168.111.21:/mnt/nfs/nfs1_ro nfs4 10G 3.4G 6.7G 34% /mnt/nfs/files1 tmpfs tmpfs 98M 8.0K 98M 1% /run/user/42 tmpfs tmpfs 98M 0 98M 0% /run/user/0 192.168.111.21:/mnt/nfs/nfs2_rw nfs4 10G 3.4G 6.7G 34% /mnt/nfs/files210、服务端目录赋权,或修改目录属主nfsnobody,查看确认
[root@centos-a1 nfs1_ro]# cd .. [root@centos-a1 nfs]# cd nfs2_rw/ [root@centos-a1 nfs2_rw]# echo "123456" > 1.txt [root@centos-a1 nfs2_rw]# ll total 4 -rw-r--r-- 1 root root 7 Jun 12 21:33 1.txt [root@centos7-a3 ~]# cd /mnt/nfs/files2 [root@centos7-a3 files2]# cat 1.txt 123456 [root@centos7-a3 files2]# touch 2.txt touch: cannot touch ‘2.txt’: Permission denied [root@centos7-a3 files2]# ll total 4 -rw-r--r-- 1 root root 7 Jun 12 21:33 1.txt [root@centos-a1 nfs2_rw]# cd .. [root@centos-a1 nfs]# chmod 777 nfs2_rw/ [root@centos-a1 nfs]# ll total 0 drwxr-xr-x 2 root root 19 Jun 12 20:44 nfs1_ro drwxrwxrwx 2 root root 19 Jun 12 21:33 nfs2_rw [root@centos7-a3 files2]# touch 2.txt [root@centos7-a3 files2]# ll total 4 -rw-r--r-- 1 root root 7 Jun 12 21:33 1.txt -rw-r--r-- 1 nfsnobody nfsnobody 0 Jun 12 21:36 2.txt [root@centos-a1 nfs]# chown nfsnobody nfs2_rw/ [root@centos7-a3 files2]# ll total 4 -rw-r--r-- 1 root root 7 Jun 12 21:33 1.txt -rw-r--r-- 1 nfsnobody nfsnobody 0 Jun 12 21:36 2.txt -rw-r--r-- 1 nfsnobody nfsnobody 0 Jun 12 21:39 3.txt11、服务器端创建共享资源目录/mnt/nfs/nfs3_root,编辑配置文件,指定网段,指定可读写及同步,增加root不压缩,客户端挂载,检查确认(没777权,root写入)
[root@centos-a1 nfs]# mkdir /mnt/nfs/nfs3_root -p [root@centos-a1 nfs]# ll total 0 drwxr-xr-x 2 root root 19 Jun 12 20:44 nfs1_ro drwxr-xr-x 2 nfsnobody root 45 Jun 12 21:39 nfs2_rw drwxr-xr-x 2 root root 6 Jun 12 21:41 nfs3_root [root@centos-a1 nfs]# vim /etc/exports /mnt/nfs/nfs1_ro 192.168.111.0/24(ro,sync) /mnt/nfs/nfs2_rw 192.168.111.0/24(rw,sync) /mnt/nfs/nfs3_root 192.168.111.0/24(rw,sync,no_root_squash) [root@centos-a1 nfs]# exportfs -r [root@centos7-a3 files2]# mkdir /mnt/nfs/files3 [root@centos7-a3 files2]# mount 192.168.111.21:/mnt/nfs/nfs3_root /mnt/nfs/files3 [root@centos7-a3 files2]# df -hT Filesystem Type Size Used Avail Use% Mounted on /dev/sda2 xfs 10G 3.4G 6.7G 34% / devtmpfs devtmpfs 471M 0 471M 0% /dev tmpfs tmpfs 487M 0 487M 0% /dev/shm tmpfs tmpfs 487M 8.4M 478M 2% /run tmpfs tmpfs 487M 0 487M 0% /sys/fs/cgroup /dev/sda3 xfs 10G 37M 10G 1% /home /dev/sda6 xfs 28G 296M 28G 2% /var /dev/sda1 xfs 497M 167M 330M 34% /boot 192.168.111.21:/mnt/nfs/nfs1_ro nfs4 10G 3.4G 6.7G 34% /mnt/nfs/files1 tmpfs tmpfs 98M 12K 98M 1% /run/user/42 tmpfs tmpfs 98M 0 98M 0% /run/user/0 192.168.111.21:/mnt/nfs/nfs2_rw nfs4 10G 3.4G 6.7G 34% /mnt/nfs/files2 192.168.111.21:/mnt/nfs/nfs3_root nfs4 10G 3.4G 6.7G 34% /mnt/nfs/files3 [root@centos7-a3 files2]# cd .. [root@centos7-a3 nfs]# cd files3 [root@centos7-a3 files3]# ll total 0 [root@centos7-a3 files3]# echo "file3 1.txt was be created" > 1.txt [root@centos7-a3 files3]# cat 1.txt file3 1.txt was be created [root@centos-a1 nfs]# cd nfs3_root/ [root@centos-a1 nfs3_root]# cat 1.txt file3 1.txt was be created12、为了增加NFS系统安全性,服务端设置root压缩,检查确认
[root@centos-a1 nfs3_root]# vim /etc/exports /mnt/nfs/nfs1_ro 192.168.111.0/24(ro,sync) /mnt/nfs/nfs2_rw 192.168.111.0/24(rw,sync) /mnt/nfs/nfs3_root 192.168.111.0/24(rw,sync,root_squash) [root@centos-a1 nfs3_root]# exportfs -r [root@centos7-a3 files3]# touch 2.txt touch: cannot touch ‘2.txt’: Permission denied [root@centos-a1 nfs3_root]# cd .. [root@centos-a1 nfs]# ll total 0 drwxr-xr-x 2 root root 19 Jun 12 20:44 nfs1_ro drwxr-xr-x 2 nfsnobody root 45 Jun 12 21:39 nfs2_rw drwxr-xr-x 2 root root 19 Jun 12 21:45 nfs3_root [root@centos-a1 nfs]# chown nfsnobody nfs3_root/ [root@centos7-a3 files3]# touch 2.txt [root@centos7-a3 files3]# ll total 4 -rw-r--r-- 1 root root 27 Jun 12 21:45 1.txt -rw-r--r-- 1 nfsnobody nfsnobody 0 Jun 12 21:51 2.txt二、NFS服务高级配置 1、服务器端创建共享资源目录/mnt/nfs/nfs4_group,编辑配置文件,设指定组可读写,其他用户只读,客户端挂载
[root@centos-a1 nfs]# mkdir /mnt/nfs/nfs4_group [root@centos-a1 nfs]# vim /etc/exports /mnt/nfs/nfs1_ro 192.168.111.0/24(ro,sync) /mnt/nfs/nfs2_rw 192.168.111.0/24(rw,sync) /mnt/nfs/nfs3_root 192.168.111.0/24(rw,sync,root_squash) /mnt/nfs/nfs4_group 192.168.111.0/24(rw,sync) *(ro,sync) [root@centos-a1 nfs]# exportfs -r [root@centos7-a3 nfs]# mkdir /mnt/nfs/files4 [root@centos7-a3 nfs]# mount 192.168.111.21:/mnt/nfs/nfs4_group /mnt/nfs/files4 [root@centos7-a3 nfs]# df -hT Filesystem Type Size Used Avail Use% Mounted on /dev/sda2 xfs 10G 3.4G 6.7G 34% / devtmpfs devtmpfs 471M 0 471M 0% /dev tmpfs tmpfs 487M 0 487M 0% /dev/shm tmpfs tmpfs 487M 15M 472M 3% /run tmpfs tmpfs 487M 0 487M 0% /sys/fs/cgroup /dev/sda3 xfs 10G 37M 10G 1% /home /dev/sda6 xfs 28G 296M 28G 2% /var /dev/sda1 xfs 497M 167M 330M 34% /boot 192.168.111.21:/mnt/nfs/nfs1_ro nfs4 10G 3.4G 6.7G 34% /mnt/nfs/files1 tmpfs tmpfs 98M 12K 98M 1% /run/user/42 tmpfs tmpfs 98M 0 98M 0% /run/user/0 192.168.111.21:/mnt/nfs/nfs2_rw nfs4 10G 3.4G 6.7G 34% /mnt/nfs/files2 192.168.111.21:/mnt/nfs/nfs3_root nfs4 10G 3.4G 6.7G 34% /mnt/nfs/files3 192.168.111.21:/mnt/nfs/nfs4_group nfs4 10G 3.4G 6.7G 34% /mnt/nfs/files42、服务器增加归属nfsgroup组的用户,查看该用户的uid及gid
[root@centos-a1 nfs]# groupadd nfsgroup [root@centos-a1 nfs]# cat /etc/group nfsgroup:x:1001: [root@centos-a1 nfs]# cat /etc/passwd stu:x:1000:1000:stu:/home/stu:/bin/bash [root@centos-a1 nfs]# usermod stu -aG nfsgroup [root@centos-a1 nfs]# id stu uid=1000(stu) gid=1000(stu) groups=1000(stu),1001(nfsgroup)3、对该共享目录设置ACL权限,指定nfsgroup组可读写
[root@centos-a1 nfs]# setfacl -m g:nfsgroup:rwx nfs4_group/ [root@centos-a1 nfs]# ll total 0 drwxr-xr-x 2 root root 19 Jun 12 20:44 nfs1_ro drwxr-xr-x 2 nfsnobody root 45 Jun 12 21:39 nfs2_rw drwxr-xr-x 2 nfsnobody root 32 Jun 12 21:51 nfs3_root drwxrwxr-x+ 2 root root 6 Jun 12 21:58 nfs4_group4、客户端测试root用户的读写操作,并创建于服务端归属组gid一致的用户,并测试该用户的读写操作,及检查文件的两端属主属性
[root@centos-a1 nfs]# cd nfs4_group/ [root@centos-a1 nfs4_group]# echo "nfs4_group 1.txt created" > 1.txt [root@centos-a1 nfs4_group]# cat 1.txt nfs4_group 1.txt created [root@centos7-a3 nfs]# cd files4 [root@centos7-a3 files4]# cat 1.txt nfs4_group 1.txt created [root@centos7-a3 files4]# touch 2.txt touch: cannot touch ‘2.txt’: Permission denied [root@centos7-a3 files4]# groupadd nfsgroup [root@centos7-a3 files4]# usermod stu -aG nfsgroup [root@centos7-a3 files4]# id stu uid=1000(stu) gid=1000(stu) groups=1000(stu),1001(nfsgroup) [stu@centos7-a3 files4]$ touch 2.txt [stu@centos7-a3 files4]$ ll total 4 -rw-r--r-- 1 root root 25 Jun 12 22:07 1.txt -rw-rw-r-- 1 stu stu 0 Jun 12 22:10 2.txt [root@centos-a1 nfs4_group]# ll total 4 -rw-r--r-- 1 root root 25 Jun 12 22:07 1.txt -rw-rw-r-- 1 stu stu 0 Jun 12 22:10 2.txt5、服务器新增用户nfsuser,查看确认该用户的uid及gid
[root@centos-a1 nfs4_group]# useradd nfsuser [root@centos-a1 nfs4_group]# id nfsuser uid=1001(nfsuser) gid=1002(nfsuser) groups=1002(nfsuser)6、服务器端创建共享目录/mnt/nfs/nfs5_user(属主nfsuser),编辑配置文件,指定网段,指定可读写及同步,增加全压缩,指定anonuid及anongid,客户端挂载,检查确认
[root@centos-a1 nfs]# mkdir /mnt/nfs/nfs5_user -p [root@centos-a1 nfs]# ll total 0 drwxr-xr-x 2 root root 19 Jun 12 20:44 nfs1_ro drwxr-xr-x 2 nfsnobody root 45 Jun 12 21:39 nfs2_rw drwxr-xr-x 2 nfsnobody root 32 Jun 12 21:51 nfs3_root drwxrwxr-x+ 2 root root 32 Jun 12 22:10 nfs4_group drwxr-xr-x 2 root root 6 Jun 12 22:13 nfs5_user [root@centos-a1 nfs]# chown nfsuser:nfsuser nfs5_user/ [root@centos-a1 nfs]# ll total 0 drwxr-xr-x 2 root root 19 Jun 12 20:44 nfs1_ro drwxr-xr-x 2 nfsnobody root 45 Jun 12 21:39 nfs2_rw drwxr-xr-x 2 nfsnobody root 32 Jun 12 21:51 nfs3_root drwxrwxr-x+ 2 root root 32 Jun 12 22:10 nfs4_group drwxr-xr-x 2 nfsuser nfsuser 6 Jun 12 22:13 nfs5_user [root@centos-a1 nfs]# vim /etc/exports /mnt/nfs/nfs1_ro 192.168.111.0/24(ro,sync) /mnt/nfs/nfs2_rw 192.168.111.0/24(rw,sync) /mnt/nfs/nfs3_root 192.168.111.0/24(rw,sync,root_squash) /mnt/nfs/nfs4_group 192.168.111.0/24(rw,sync) *(ro,sync) /mnt/nfs/nfs5_user 192.168.111.0/24(rw,sync,all_squash,anonuid=1001,anongid=1002) [root@centos-a1 nfs]# exportfs -r [root@centos7-a3 nfs]# mkdir files5 [root@centos7-a3 nfs]# mount 192.168.111.21:/mnt/nfs/nfs5_user /mnt/nfs/files5 [root@centos7-a3 nfs]# df -hT Filesystem Type Size Used Avail Use% Mounted on /dev/sda2 xfs 10G 3.4G 6.7G 34% / devtmpfs devtmpfs 471M 0 471M 0% /dev tmpfs tmpfs 487M 0 487M 0% /dev/shm tmpfs tmpfs 487M 15M 472M 3% /run tmpfs tmpfs 487M 0 487M 0% /sys/fs/cgroup /dev/sda3 xfs 10G 37M 10G 1% /home /dev/sda6 xfs 28G 298M 28G 2% /var /dev/sda1 xfs 497M 167M 330M 34% /boot 192.168.111.21:/mnt/nfs/nfs1_ro nfs4 10G 3.4G 6.7G 34% /mnt/nfs/files1 tmpfs tmpfs 98M 12K 98M 1% /run/user/42 tmpfs tmpfs 98M 0 98M 0% /run/user/0 192.168.111.21:/mnt/nfs/nfs2_rw nfs4 10G 3.4G 6.7G 34% /mnt/nfs/files2 192.168.111.21:/mnt/nfs/nfs3_root nfs4 10G 3.4G 6.7G 34% /mnt/nfs/files3 192.168.111.21:/mnt/nfs/nfs4_group nfs4 10G 3.4G 6.7G 34% /mnt/nfs/files4 192.168.111.21:/mnt/nfs/nfs5_user nfs4 10G 3.4G 6.7G 34% /mnt/nfs/files57、客户端创建于服务端相同用户名的用户,并测试该用户的写操作,以及测试root用户、其他用户的写操作,并查看客户端是否继承服务器用户信息,检查确认
[root@centos7-a3 nfs]# useradd nfsuser [root@centos7-a3 nfs]# su nfsuser [nfsuser@centos7-a3 nfs]$ cd files5 [nfsuser@centos7-a3 files5]$ echo "nfsuser 1.txt" > 1.txt [nfsuser@centos7-a3 files5]$ cat 1.txt nfsuser 1.txt [nfsuser@centos7-a3 files5]$ ll total 4 -rw-rw-r-- 1 nfsuser nfsuser 14 Jun 12 22:17 1.txt [nfsuser@centos7-a3 files5]$ su Password: [root@centos7-a3 files5]# echo "root 2.txt" > 2.txt [root@centos7-a3 files5]# ll total 8 -rw-rw-r-- 1 nfsuser nfsuser 14 Jun 12 22:17 1.txt -rw-r--r-- 1 nfsuser nfsuser 11 Jun 12 2022 2.txt [root@centos7-a3 files5]# cat 2.txt root 2.txt [stu@centos7-a3 files5]$ echo "stu 3.txt" > 3.txt [stu@centos7-a3 files5]$ cat 3.txt stu 3.txt [stu@centos7-a3 files5]$ ll total 12 -rw-rw-r-- 1 nfsuser nfsuser 14 Jun 12 22:17 1.txt -rw-r--r-- 1 nfsuser nfsuser 11 Jun 12 22:17 2.txt -rw-rw-r-- 1 nfsuser nfsuser 10 Jun 12 22:18 3.txt



