NFS服務器

服務器端配置

  1. 安裝NFS+rpcbind服務器組件
rpm -qa nfs-utils rpcbind
nfs-utils-1.3.0-0.54.el7.x86_64
rpcbind-0.2.0-38.el7.x86_64
  1. 安裝

    yum install -y nfs-utils rpcbind
    
  2. 配置需要掛載的文件

    mkdir -p /data/share
    chmod 666 /data/share
    

    修改NFS配置文件/etc/exports

    vim /etc/exports

    添加

    /data/share 192.168.77.0/24(rw,sync,insecure,no_subtree_check,no_root_squash)
    
    
    參數 說明
    ro 只读访问
    rw 读写访问
    sync 所有数据在请求时写入共享
    async nfs 在写入数据前可以响应请求
    insecure nfs 通过 1024 以上的端口发送
    wdelay 如果多个用户要写入 nfs 目录,则归组写入(默认)
    no_wdelay 如果多个用户要写入 nfs 目录,则立即写入,当使用 async 时,无需此设置
    hide 在 nfs 共享目录中不共享其子目录
    no_hide 共享 nfs 目录的子目录
    subtree_check 如果共享 /usr/bin 之类的子目录时,强制 nfs 检查父目录的权限(默认)
    no_subtree_check 不检查父目录权限
    all_squash 共享文件的 UID 和 GID 映射匿名用户 anonymous,适合公用目录
    no_all_squash 保留共享文件的 UID 和 GID(默认)
    root_squash root 用户的所有请求映射成如 anonymous 用户一样的权限(默认)
    no_root_squash root 用户具有根目录的完全管理访问权限
    anonuid=xxx 指定 nfs 服务器 /etc/passwd 文件中匿名用户的 UID
    anongid=xxx 指定 nfs 服务器 /etc/passwd 文件中匿名用户的 GID

    ​ rpcinfo -p localhost

   		 program vers proto   port  service
         100000    4   tcp    111  portmapper
         100000    3   tcp    111  portmapper
         100000    2   tcp    111  portmapper
         100000    4   udp    111  portmapper
         100000    3   udp    111  portmapper
         100000    2   udp    111  portmapper
         100024    1   udp  33745  status
         100024    1   tcp  36980  status
         100005    1   udp  20048  mountd
         100005    1   tcp  20048  mountd
         100005    2   udp  20048  mountd
         100005    2   tcp  20048  mountd
         100005    3   udp  20048  mountd
         100005    3   tcp  20048  mountd
         100003    3   tcp   2049  nfs
         100003    4   tcp   2049  nfs
         100227    3   tcp   2049  nfs_acl
         100003    3   udp   2049  nfs
         100003    4   udp   2049  nfs
         100227    3   udp   2049  nfs_acl
         100021    1   udp  38960  nlockmgr
         100021    3   udp  38960  nlockmgr
         100021    4   udp  38960  nlockmgr
         100021    1   tcp  38362  nlockmgr
         100021    3   tcp  38362  nlockmgr
         100021    4   tcp  38362  nlockmgr
  1. 檢查文件掛載

    showmount -e localhost

    Export list for localhost:
    /data/share 192.168.77.0/24
    

客戶端配置

  1. yum install nfs-utils

    扫描二维码关注公众号,回复: 10367872 查看本文章
  2. 查看遠程的可掛載文件

    showmount -e 192.16877.86

    Export list for 192.168.77.86:
    /data/share 192.168.77.0/24
    
  3. 本地創建掛載點

    mkdir /share

    mount 192.168.77.86:/data/share /share

    查看掛載

    df -h

    檢查

    在服務器端添加文件,寫入文字,在客戶端也寫入,刪除

发布了9 篇原创文章 · 获赞 8 · 访问量 211

猜你喜欢

转载自blog.csdn.net/Skyeee000/article/details/105231838