网络环境: 一台Linux server ip 192.168.1.254,一台Linux client ip 192.168.1.100 操作系统:CentOS 6.5 需求描述: 1:将/root 共享给192.168.1.100,可写、同步,允许客户机以root权限访问 2:将/usr/src 共享给192.168.1.0/24网段,可写、异步 3:在上一个实验基础上实现客户端上面所有用户身份都映射成nfsnobody 实施步骤: 1:查看nfs程序是否安装 [root@server ~]# rpm -qa |grep nfs 查看nfs是否安装 nfs-utils-1.2.3-39.el6.i686 [root@server ~]# rpm -qa |grep rpcbind 查看RPC是否安装 rpcbind-0.2.0-11.el6.i686 2:启动服务并设为开机启动 [root@server ~]# service nfs start [root@server ~]# service rpcbind start [root@server ~]# chkconfig rpcbind on [root@server ~]# chkconfig nfs on 3:备份nfs配置文件 [root@server ~]# cp /etc/exports /etc/exports.bak 4:编辑配置文件实现需求1,2要求 [root@server ~]# vim /etc/exports /root 192.168.1.100(rw,sync,no_root_squash) /usr/src 192.168.1.0/24(rw,async) 5:重启服务 [root@server ~]# service nfs restart [root@server ~]# service rpcbind restart 6:服务器端设置/usr/src本地写权限 [root@server ~]# chmod o+w /usr/src/ 7:客户机测试 [root@client ~]# mkdir -p /data/root [root@client ~]# mount 192.168.1.254:/root /data/root/ [root@client ~]# mkdir -p /tmp/src [root@client ~]# mount 192.168.1.254:/usr/src /tmp/src/ [root@client ~]# mount |tail -2 192.168.1.254:/root on /data/root type nfs (rw,vers=4,addr=192.168.1.254,clientaddr=192.168.1.100) 192.168.1.254:/usr/src on /tmp/src type nfs (rw,vers=4,addr=192.168.1.254,clientaddr=192.168.1.100) [root@client ~]# cd /data/root/ 进入挂载目录测试需求1 [root@client root]# touch nfs [root@client root]# ll -rw-r--r--. 1 root root 0 6月 14 14:14 nfs [sw@client src]$ cd /tmp/src 普通用户进入挂载目录测试需求2 [sw@client src]$ touch nks [sw@client src]$ ll -rw-r--r--. 1 sw sw 0 6月 14 14:25 nks 8:需求3把所有用户都映射成nfsnobody [root@server ~]# cat /etc/exports /root 192.168.1.100(rw,sync,all_squash) /usr/src 192.168.1.0/24(rw,async,all_squash) [root@server ~]# chmod o-w /usr/src 清除上面实验的权限 [root@server ~]# setfacl -m u:nfsnobody:rwx /usr/src/ 设置访问控制列表 9:客户机测试 [sw@client src]$ touch nksss [sw@client src]$ ll -rw-r--r--. 1 nfsnobody nfsnobody 0 6月 14 14:28 nksss (责任编辑:IT) |