zoukankan      html  css  js  c++  java
  • NFS服务配置2

    目录

    1.服务端配置NFS

    2.客户端挂载

    3.命令exportfs

    NFS服务配置

    1.服务端配置NFS

    # yum install -y nfs-utils      //并且一并安装rpcbind
    # vim /etc/exports
    /home/nfstestdir 192.168.188.0/24(rw,sync,all_squash,anonuid=1000,anongid=1000)

    第二部分为允许访问的IP(或IP段)

    rw:读写

    ro:只读

    sync:同步模式,表示内存中的数据实时写入磁盘

    async:非同步模式,表示把内存中的数据定期写入磁盘

    no_root_squash:root用户对共享的目录有至高权限

    root_squash:root用户只有普通用户的权限

    all_squash:表示不管使用NFS的用户是谁,其身份都会被限定为一个指定普通用户身份

    anonuid/anongid:要和root_squash以及all_squash选线一同使用,用于指定使用NFS的用户被限定后的uid和gid,但前提是本机的/etc/passwd中存在相应的uid和gid。

    # mkdir /home/nfstestdir
    # systemctl start rpcbind
    # systemctl start nfs
    # systemctl enable rpcbind
    # systemctl enable nfs

    在启动NFS服务之前,需要先启动rpcbind服务(CentOS的老版本中为portmap)

    2.客户端挂载

    客户端:192.168.188.129

    # yum install -y nfs-utils
    # showmount -e 192.168.188.128
    Export list for 192.168.188.128:
    /home/nfstestdir 192.168.188.0/24

    # mount -t nfs 192.168.188.128:/home/nfstestdir

    -t 挂载类型

    测试:

    # df -h
    # cd /mnt/
    # touch aminglinux.txt
    //权限不够

    # chmod 777 /home/nfstestdir/
    # cd /mnt/
    # ls -l
    -rw-r--r-- aming aming
    # id aming
    uid=1000(aming) gid=1000(aming) 组=1000(aming),10(wheel)

    创建的新文件aminglinux.txt所有者和所属组为aming,其uid和gid为1000。

    3.命令exportfs

    exportfs命令的常用选项-a、-r、-u、-v,

    • -a:全部挂载或卸载

    • -r:重新挂载

    • -u:卸载某一个目录

    • -v:显示共享的目录

       

    当改变/etc/exports配置文件后,使用exportfs命令挂载不需要再重启NFS服务,修改服务端(.128)

    # vim /etc/exports      //增加一行
    //...
    /tmp/ 192.168.188.0/24(rw,sync,no_root_squash)

    # exportfs -arv
    exporting 192.168.188.0/24:/tmp
    exporting 192.168.188.0/24:/home/nfstestdir

    上节使用到mount命令。mount挂载NFS服务也有讲究,-t nfs指定挂载类型为nfs。另外挂载NFS服务时,常用-o nolock选项(即不加锁)。

    如在客户端上(.129)执行

    # mkdir /aminglinux
    # mount -t nfs -o nolock 192.168.188.128:/tmp/ /aminglinux/

    # vim /etc/fstab
    192.168.188.128:/tmp/ /aminglinux nfs defaults,nolock 0 0
    # umount /aminglinux
    # mount -a
    //这样操作以后开机会自动挂载NFS。
    # cd /aminglinux/
    # touch 1.txt
    # ls -l 1.txt
    -rw-r--r-- 1 root root 0 4月 2 17:22 1.txt

     

    出处:《跟阿铭学Linux》

    配置若有遗漏或错误,请评论留言。
  • 相关阅读:
    WordPress主题开发实例:查询单篇文章
    WordPress基础:get_page_link获取页面地址
    WordPress主题开发:优化标题
    React中的的JSX
    WordPress主题开发:WP_Query常用参数
    WordPress基础:wp_list_pages显示页面信息列表
    WordPress基础:常用分类列表wp_list_categories
    SQL Server 2008 安装教程
    XCODE调试时不显示变量值/指针地址的解决方案
    android iOS 编码问题害死人!
  • 原文地址:https://www.cnblogs.com/BrokenEaves/p/14426951.html
Copyright © 2011-2022 走看看