1. 程式人生 > >linux檔案共享NFS詳細操作(企業級)

linux檔案共享NFS詳細操作(企業級)

 

 

服務端

yum install nfs-utils -y

systemctl start nfs-server

/westos     *(sync,ro)    表示共享/westos  後面分別是 實時同步和只讀許可權

exportfs -rv   重新整理

 

 

 

 

客戶端

yum install nfs-utils -y

上面進行完重新整理操作後

showmount -e 172.25.254.113

 

也可以直接掛載

mount 172.25.254.113:/westos  /mnt

 

 

這時安裝自動掛載

yum install autofs.x86_64  -y

systemctl start autofs

cd /net/172.25.254.113/westos 

只要進去一次  就會自動掛載  這時df就會出現

預設過300秒 不訪問掛載的地址時自動umount

這裡進入  /etc/sysconfig/autofs

修改  TIMEOUT=300   ->5  變成五秒無訪問自動取消解除安裝

即可

 

 

設定自動掛載

vim /etc/auto.master

vim /etc/auto.pub

然後

systemctl restart autofs.service

這時候就可以進入     cd  /pub/westos  

就df  就可以顯示自動掛載了

 

修改許可權,限定指定使用者等的操作


vim /etc/exports
  *(sync,rw,no_root_squash)     不指定root使用者
 *(sync,rw,anonuid=1001,anongid=1000)     指定特定使用者,組
  172.25.254.100(sync,rw,anonuid=1001,anongid=1000) *(ro)
  表示100是讀寫,其他人只讀,空格表示分開寫
  *.westos.com(sync,rw,anonuid=1001,anongid=1000)
  這時需要dns解析
 172.25.254.0/24(sync,rw,anonuid=1001,anongid=1000) *(ro)


  表示這個網段的有讀寫許可權,其他人只讀許可權
改完之後  exportfs -rv  重新整理以下配置
 showmount -e 172.25.254.113 檢視狀態
你還需要(如果不能寫檔案)
/etc/auto.master
vim /etc/auto.pub
改為讀寫許可權才行