配置nfs服務


服務端以只讀方式配置共享目錄是/nfs1 ,且只允許172.25.0.0/24域中主機訪問,客戶端實現自動掛載,掛載目錄為/mnt/nfs1.

   94  yum -y install nfs-utils-*    這個包包括基本nfs命令和監控程序。
   95  mkdir /nfs1      
   96  vim /etc/exports    編輯配置文件

/nfs1   172.25.0.0/24(ro,sync)    


   97  systemctl enable rpcbind    在啟動nfs服務之前,會先啟用rpcbind服務程序。
   98  systemctl restart rpcbind
   99  systemctl enable nfs-server   將nfs-server服務開機自動啟動
  100  systemctl restart  nfs-server
  101  showmount -e 172.25.0.11    測試是否能看到
  102  firewall-cmd --permanent --add-service=nfs
  103  firewall-cmd --reload

 

客戶端配置

   19  mkdir /mnt/nfs1
   20  vim /etc/fstab

172.25.0.11:/nfs1 /mnt/nfs1 nfs defaults 0 0


   21  mount -a

 

在服務器上配置安全的nfs服務,以讀寫的模式共享/nfs2,僅允許172.25.0.0/24的主機訪問,且/nfs2/private的目錄所有者是haha,haha能寫入文件到/mnt/nfs2/private中。

  120  yum -y install nfs-utils-*
 
  122  mkdir /nfs2            這個目錄默認其他人只可讀
  123  mkdir /nfs2/private
  124  chown haha /nfs2/private

  124  vim /etc/sysconfig/nfs

# Optional arguments passed to rpc.nfsd. See rpc.nfsd(8)
RPCNFSDARGS="-V 4.2"                                                       修改 nfs 配置文件,強制使用 V4.2


  125  wget -O /etc/krb5.keytab http://classroom.example.com/pub/keytabs/desktop0.keytab     下載安全證書。必須先有證書服務才能起來
  126  vim /etc/exports

/nfs2   172.25.0.0/24(rw,sync,sec=krb5p)                        以讀寫方式共享/nfs2。。。 
  127  systemctl enable nfs-secure-server      使這個服務端的證書生效
  128  systemctl restart nfs-secure-server
 
  130  systemctl restart nfs-server.service       起來這個服務是為了讀取/etc/exports中的配置文件
 
  132  showmount -e 172.25.0.11          測試是否出現共享目錄。

 

客戶端配置

   34  mkdir /mnt/nfs2
   35  wget -O /etc/krb5.keytab http://classroom.example.com/pub/keytabs/desktop0.keytab    下載客戶端的安全證書
   36  systemctl enable nfs-secure.service    啟動這個安全選項使客戶端的證書生效
   37  systemctl restart nfs-secure.service
   38  vim /etc/fstab

172.25.0.11:/nfs2 /mnt/nfs2 nfs defaults,v4.2,sec=krb5p 0 0    


   39  mount -a

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM