nfs的学习第十二天

实验:

服务端(172.24.8.128)

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

/data   *(ro)

[root@localhost ~]# mkdir /data

[root@localhost ~]# systemctl status rpcbind

[root@localhost ~]# systemctl restart rpcbind

[root@localhost ~]# systemctl restart nfs

[root@localhost ~]# showmount -e 172.24.8.128

Export list for 172.24.8.128:

/data *

[root@localhost ~]# systemctl stop firewalld 

客户端(172.24.8.129)

[root@localhost ~]# showmount -e 172.24.8.128

Export list for 172.24.8.128:

/data *

[root@localhost ~]# mount 172.24.8.128:/data /mnt

服务端

[root@localhost data]# echo this is ceshi > /data/ceshi

客户端

[root@localhost mnt]# ll /mnt

total 4

-rw-r--r--. 1 root root 14 Mar 28  2019 ceshi

[root@localhost mnt]# rm -f ceshi

rm: cannot remove ‘ceshi’: Read-only file system

注意:在客户端如果要删除ceshi文件需要在服务端的主配置文件更改为

data *(rw)

服务端

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

/data   *(rw)

[root@localhost data]# exportfs -r

exportfs的选项

-a全部挂载或卸载/etc/exports中的内容

-r重新读取/etc/exports中的信息,并同步更新/etc/exports,/var/lib/nfs/xtab

-u卸载单一目录(和-a一起使用为卸载所有/etc/exports文件中的目录)

-v在export的时候,将详细的信息输出到屏幕上

客户端

[root@localhost mnt]# rm -f ceshi

rm: cannot remove ‘ceshi’: Permission denied

服务端

[root@localhost data]# chmod o+w /data/

[root@localhost data]# ll -d /data/

drwxr-xrwx. 2 root root 18 3月  28 15:05 /data/

客户端

[root@localhost mnt]# rm -f ceshi

[root@localhost mnt]# ll

total 0

[root@localhost mnt]# echo this is client ceshi > client

[root@localhost mnt]# ll /mnt

total 4

-rw-r--r--. 1 nfsnobody nfsnobody 21 Mar 28  2019 client

[redhat@localhost mnt]$ touch /mnt/red

[redhat@localhost mnt]$ ll /mnt

total 4

-rw-r--r--. 1 nfsnobody nfsnobody 21 Mar 28  2019 client

-rw-rw-r--. 1 redhat    redhat     0 Mar 28  2019 red

练习:架设一台NFS服务器,并按照以下要求配置

1、开放/nfs/shared目录,供所有用户查询资料;

2、开放/nfs/upload目录,该目录为172.24.8.0/24网段的主机的数据上传目录,并将所有该网段主机上传文件的所属者和所属组映射为nfs-upload,其UID和GID为2001;

3、将/home/tom(该目录为uid=1111,gid=1111的tom用户的家目录)目录仅共享给172.24.8.129这台主机上的jerry用户,jerry对该目录具有访问、新建和删除文件的权限。

8.3客户端使用autofs自动挂载

在一般NFS文件系统的使用过程中,如果客户端要使用服务端所提供的文件系统,可以在/etc/rc.d/rc.local中设置开机时自动挂载(/etc/rc.d/rc.local文件中写入的命令,在每次启动系统用户登录之前都会执行一次);也可以在登录系统后手动利用mount来挂载。

由于网络的问题,NFS服务器与客户端的连接不会一直存在,当我们挂载了NFS服务器之后,任何一方脱机都可能造成另外一方等待超时。为了解决这样的问题,就出现了下面的想法:

1、当客户端在有使用NFS文件系

实验:

服务端(172.24.8.128)

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

/data   *(ro)

[root@localhost ~]# mkdir /data

[root@localhost ~]# systemctl status rpcbind

[root@localhost ~]# systemctl restart rpcbind

[root@localhost ~]# systemctl restart nfs

[root@localhost ~]# showmount -e 172.24.8.128

Export list for 172.24.8.128:

/data *

[root@localhost ~]# systemctl stop firewalld 

客户端(172.24.8.129)

[root@localhost ~]# showmount -e 172.24.8.128

Export list for 172.24.8.128:

/data *

[root@localhost ~]# mount 172.24.8.128:/data /mnt

服务端

[root@localhost data]# echo this is ceshi > /data/ceshi

客户端

[root@localhost mnt]# ll /mnt

total 4

-rw-r--r--. 1 root root 14 Mar 28  2019 ceshi

[root@localhost mnt]# rm -f ceshi

rm: cannot remove ‘ceshi’: Read-only file system

注意:在客户端如果要删除ceshi文件需要在服务端的主配置文件更改为

data *(rw)

服务端

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

/data   *(rw)

[root@localhost data]# exportfs -r

exportfs的选项

-a全部挂载或卸载/etc/exports中的内容

-r重新读取/etc/exports中的信息,并同步更新/etc/exports,/var/lib/nfs/xtab

-u卸载单一目录(和-a一起使用为卸载所有/etc/exports文件中的目录)

-v在export的时候,将详细的信息输出到屏幕上

客户端

[root@localhost mnt]# rm -f ceshi

rm: cannot remove ‘ceshi’: Permission denied

服务端

[root@localhost data]# chmod o+w /data/

[root@localhost data]# ll -d /data/

drwxr-xrwx. 2 root root 18 3月  28 15:05 /data/

客户端

[root@localhost mnt]# rm -f ceshi

[root@localhost mnt]# ll

total 0

[root@localhost mnt]# echo this is client ceshi > client

[root@localhost mnt]# ll /mnt

total 4

-rw-r--r--. 1 nfsnobody nfsnobody 21 Mar 28  2019 client

[redhat@localhost mnt]$ touch /mnt/red

[redhat@localhost mnt]$ ll /mnt

total 4

-rw-r--r--. 1 nfsnobody nfsnobody 21 Mar 28  2019 client

-rw-rw-r--. 1 redhat    redhat     0 Mar 28  2019 red

练习:架设一台NFS服务器,并按照以下要求配置

1、开放/nfs/shared目录,供所有用户查询资料;

2、开放/nfs/upload目录,该目录为172.24.8.0/24网段的主机的数据上传目录,并将所有该网段主机上传文件的所属者和所属组映射为nfs-upload,其UID和GID为2001;

3、将/home/tom(该目录为uid=1111,gid=1111的tom用户的家目录)目录仅共享给172.24.8.129这台主机上的jerry用户,jerry对该目录具有访问、新建和删除文件的权限。

8.3客户端使用autofs自动挂载

在一般NFS文件系统的使用过程中,如果客户端要使用服务端所提供的文件系统,可以在/etc/rc.d/rc.local中设置开机时自动挂载(/etc/rc.d/rc.local文件中写入的命令,在每次启动系统用户登录之前都会执行一次);也可以在登录系统后手动利用mount来挂载。

由于网络的问题,NFS服务器与客户端的连接不会一直存在,当我们挂载了NFS服务器之后,任何一方脱机都可能造成另外一方等待超时。为了解决这样的问题,就出现了下面的想法:

1、当客户端在有使用NFS文件系

实验:

服务端(172.24.8.128)

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

/data   *(ro)

[root@localhost ~]# mkdir /data

[root@localhost ~]# systemctl status rpcbind

[root@localhost ~]# systemctl restart rpcbind

[root@localhost ~]# systemctl restart nfs

[root@localhost ~]# showmount -e 172.24.8.128

Export list for 172.24.8.128:

/data *

[root@localhost ~]# systemctl stop firewalld 

客户端(172.24.8.129)

[root@localhost ~]# showmount -e 172.24.8.128

Export list for 172.24.8.128:

/data *

[root@localhost ~]# mount 172.24.8.128:/data /mnt

服务端

[root@localhost data]# echo this is ceshi > /data/ceshi

客户端

[root@localhost mnt]# ll /mnt

total 4

-rw-r--r--. 1 root root 14 Mar 28  2019 ceshi

[root@localhost mnt]# rm -f ceshi

rm: cannot remove ‘ceshi’: Read-only file system

注意:在客户端如果要删除ceshi文件需要在服务端的主配置文件更改为

data *(rw)

服务端

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

/data   *(rw)

[root@localhost data]# exportfs -r

exportfs的选项

-a全部挂载或卸载/etc/exports中的内容

-r重新读取/etc/exports中的信息,并同步更新/etc/exports,/var/lib/nfs/xtab

-u卸载单一目录(和-a一起使用为卸载所有/etc/exports文件中的目录)

-v在export的时候,将详细的信息输出到屏幕上

客户端

[root@localhost mnt]# rm -f ceshi

rm: cannot remove ‘ceshi’: Permission denied

服务端

[root@localhost data]# chmod o+w /data/

[root@localhost data]# ll -d /data/

drwxr-xrwx. 2 root root 18 3月  28 15:05 /data/

客户端

[root@localhost mnt]# rm -f ceshi

[root@localhost mnt]# ll

total 0

[root@localhost mnt]# echo this is client ceshi > client

[root@localhost mnt]# ll /mnt

total 4

-rw-r--r--. 1 nfsnobody nfsnobody 21 Mar 28  2019 client

[redhat@localhost mnt]$ touch /mnt/red

[redhat@localhost mnt]$ ll /mnt

total 4

-rw-r--r--. 1 nfsnobody nfsnobody 21 Mar 28  2019 client

-rw-rw-r--. 1 redhat    redhat     0 Mar 28  2019 red

练习:架设一台NFS服务器,并按照以下要求配置

1、开放/nfs/shared目录,供所有用户查询资料;

2、开放/nfs/upload目录,该目录为172.24.8.0/24网段的主机的数据上传目录,并将所有该网段主机上传文件的所属者和所属组映射为nfs-upload,其UID和GID为2001;

3、将/home/tom(该目录为uid=1111,gid=1111的tom用户的家目录)目录仅共享给172.24.8.129这台主机上的jerry用户,jerry对该目录具有访问、新建和删除文件的权限。

8.3客户端使用autofs自动挂载

在一般NFS文件系统的使用过程中,如果客户端要使用服务端所提供的文件系统,可以在/etc/rc.d/rc.local中设置开机时自动挂载(/etc/rc.d/rc.local文件中写入的命令,在每次启动系统用户登录之前都会执行一次);也可以在登录系统后手动利用mount来挂载。

由于网络的问题,NFS服务器与客户端的连接不会一直存在,当我们挂载了NFS服务器之后,任何一方脱机都可能造成另外一方等待超时。为了解决这样的问题,就出现了下面的想法:

1、当客户端在有使用NFS文件系

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值