29 NFS

Network File System
NFS应用场景是:A,B,C三台机器上须要保证被访问到的文件是同样的,A共享数据出来,B和C分别去挂载A共享的数据目录,从而B和C访问到的数据和A上的一致vim

  1. 服务端配置
    yum install -y nfs-utils rpcbind
    vim /etc/exports //加入以下内容
    /home/nfstestdir //表示须要共享的目录
    192.168.86.0/24(rw,sync,all_squash,anonuid=1000,anongid=1000)
    选项含义:
    rw 读写
    ro 只读
    sync 同步模式,内存数据实时写入磁盘
    async 非同步模式
    no_root_squash 客户端挂载NFS共享目录后,root用户不受约束,权限很大
    root_squash 与上面选项相对,客户端上的root用户收到约束,被限定成某个普通用户
    all_squash 客户端上全部用户在使用NFS共享目录时都被限定为一个普通用户
    anonuid/anongid 和上面几个选项搭配使用,定义被限定用户的uid和gid
    保存配置文件后,执行以下准备操做
    mkdir /home/nfstestdir
    chmod 777 /home/nfstestdir
    systemctl start rpcbind
    systemctl start nfs
    systemctl enable rpcbind
    systemctl enable nfsasync

  2. 客户端挂载
    yum install -y nfs-utils
    showmount -e 192.168.86.131 //该ip为NFS服务端ip
    mount -t nfs 192.168.86.131:/home/nfstestdir /mnt 挂载到/mnt目录
    touch /mnt/slx.txt
    ls -l /mnt/slx.txt //能够看到文件的属主和属组都为1000ide

  3. exportfs命令经常使用选项-a 所有挂载或者所有卸载-r 从新挂载-u 卸载某一个目录-v 显示共享目录如下操做在服务端上vim /etc/exports //增长/tmp/ 192.168.86.0/24(rw,sync,no_root_squash) 不限制root时就不会转变为特定uid,所以不须要定义uidexportfs -arv //不用重启nfs服务,配置文件就会生效如下操做在客户端mkdir /slxmount -t nfs -onolock 192.168.86.131:/tmp /slxtouch /slx/test.txt
相关文章
相关标签/搜索
本站公众号
   欢迎关注本站公众号,获取更多信息