天天看点

NFS

nfs

实验一:

将/root 共享给192.168.10.20,可写、同步,允许客户机以root权限访问

服务端

[root@localhost server]# vim /etc/exports

/root           192.168.10.250(rw,sync,no_root_squash)

[root@localhost server]# vim /etc/exports 

[root@localhost server]# service portmap restart

停止 portmap:                                             [确定]

启动 portmap:                                             [确定]

[root@localhost server]# chkconfig portmap on

[root@localhost server]# service nfs restart

关闭 nfs mountd:                                          [失败]

关闭 nfs 守护进程:                                        [失败]

关闭 nfs quotas:                                          [失败]

启动 nfs 服务:                                            [确定]

关掉 nfs 配额:                                            [确定]

启动 nfs 守护进程:                                        [确定]

启动 nfs mountd:                                          [确定]

stopping rpc idmapd:                                       [确定]

正在启动 rpc idmapd:                                      [确定]

[root@localhost server]# chkconfig nfs on

客户端

[root@localhost ~]# showmount -e 192.168.10.253

export list for 192.168.10.253:

/root 192.168.10.250

[root@localhost ~]# mkdir -p /data/root

[root@localhost ~]# mount 192.168.10.253:/root/ /data/root/

[root@localhost ~]# df -ht | grep nfs

               nfs     19g  6.7g   12g  37% /data/root

[root@localhost ~]# cd /data/root

[root@localhost root]# touch file1.txt

[root@localhost root]# ls -l file1.txt 

-rw-r--r-- 1 root root 0 06-12 20:26 file1.txt

实验二:

将/usr/src 共享给192.168.10.0/24网段,可写、异步

[root@localhost ~]# vim /etc/exports

/usr/src        192.168.10.0/24 (rw,async)

[root@localhost ~]# exportfs -rv

exporting 192.168.10.0/24:/usr/src

exporting 192.168.10.250:/root

[root@localhost ~]# setfacl -m u:nfsnobody:rwx /usr/src/

/root    192.168.10.250

/usr/src 192.168.10.0/24

[root@localhost ~]# mount 192.168.10.253:/usr/src/ /data/src/

you have mail in /var/spool/mail/root

[root@localhost ~]# cd /data/src

[root@localhost src]# touch file1.txt

[root@localhost src]# ls -l file1.txt 

-rw-r--r-- 1 nfsnobody nfsnobody 0 06-12 20:34 file1.txt

实验三:

在上一个实验基础上实现客户端上面所有用户身份都映射成nfsnobody

服务器

[root@localhost ~]# chmod o+w /usr/src/

[root@localhost ~]# useradd tom

[root@localhost ~]# su - tom

[tom@localhost ~]$ cd /data/src/

[tom@localhost src]$ touch tom1.txt

[tom@localhost src]$ ls -l tom1.txt 

-rw-rw-r-- 1 tom tom 0 06-12 20:36 tom1.txt

服务器配置

[root@localhost ~]# 

/usr/src        192.168.10.0/24(rw,async,all_squash)

[tom@localhost src]$ touch tom2.txt

[tom@localhost src]$ ls -l tom2.txt

-rw-rw-r-- 1 nfsnobody nfsnobody 0 06-12 20:39 tom2.txt

NFS

继续阅读