Linux中的NFS

NFS

Net File System

NFS基本信息

  • 安裝包:nfs-utils
  • 服務腳本:nfs-server
  • 共享配置文件:/etc/exports

NFS的啓用

  • systemctl start nfs-server開啓服務
  • firewall-cmd --permanent --add-service=rpc-bind
  • firewall-cmd --permanent --add-service=mountd
  • firewall-cmd --permanent --add-service=nfs
  • firewall-cmd --reload設置火牆
    在這裏插入圖片描述
  • rpc-bind----->mountd----->nfs-server(流程)
  • rpc-bind:分配端口
  • nfs:驗證你的客戶端是由有資格共享文件
    測試:
  • showmount -e 192.168.1.20192.168.1.20是本主機的ip
    在這裏插入圖片描述

NFS配置

  • vim /etc/exports 此文件更改後生效exportfs -rv這裏不使用restart的方式
  • 共享目錄 共享給誰(共享參數)
  • /westosdir *(ro)
    在這裏插入圖片描述
  • 測試:
  • mount 192.168.1.20:/westosdir /mnt/
    在這裏插入圖片描述

NFS配置參數

  • anonuid=1000,anongid=1000 指定用戶身份(uid和gid可通過id 用戶名 查看)
  • sync 更改生成後同步數據到服務器
  • async 時時同步數據到服務器
  • rw 讀寫
  • ro 只讀
  • no_root_squash root用戶掛載不轉換身份
    在這裏插入圖片描述
    在這裏插入圖片描述
    在這裏插入圖片描述

nfs+autofs

  • 參看autofs章節內容
  1. vim /etc/auto.master(在客戶端)
    在這裏插入圖片描述
  2. vim /etc/auto.nfs
 nfs 192.168.0.30:/westosdir

在這裏插入圖片描述

  • 注意:nfs格式與samba不同
  • nfs: nfs 192.168.1.20:/westosdir
  • samba -fstype=cifs,username=westos,password=westos://192.168.1.30/
    westosdir
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章