NFS服務(2)服務搭建

 

簡單NFS的實現

NFS服務器端:vim

systemctl enable rpcbind nfs.service
systemctl start rpcbind nfs.service
vim /etc/exports
/data/nfs   192.168.0.0/24(rw,sync,root_squash,no_all_squash)
mkdir -p /data/nfs/
chown nfsnobody /data/nfs/
exportfs -r
exportfs -v
/data/nfs 192.168.0.0/24(rw,sync,wdelay,hide,no_subtree_check,sec=sys,secure,root_squash,no_all_squash)

客戶端:服務器

showmount -e 192.168.0.7
Export list for 192.168.0.7:/data/nfs 192.168.0.0/24
mkdir /mnt/nfsshare
mount -o vers=3,rw,nosuid,fg,hard,intr 192.168.0.7:/data/nfs /mnt/nfsshare/
vim /etc/fstab
192.168.0.7:/data/nfs   /mnt/nfsshare           nfs     vers=3,rw,nosuid,fg,hard,intr 0 0

 

NFS僞根的實現

NFSv4支持經過掛載NFS服務器的共享「根」,從而瀏覽NFS服務器上的共享目錄列表markdown

NFS服務器:ssh

mkdir -p /data/{nfs1,nfs2}
mkdir -p /nfsroot/{nfs1,nfs2}
chown nfsnobody /nfsroot/{nfs1,nfs2}
vim /etc/fstab
/data/nfs1  /nfsroot/nfs1   none    bind    0 0
/data/nfs2  /nfsroot/nfs2   none    bind    0 0
vim /etc/exports
/nfsroot    *(fsid=0,rw,crossmnt)
/nfsroot/nfs1   192.168.0.0/24(rw)
/nfsroot/nfs2   192.168.0.0/24(rw)
exportfs -r
exportfs -v
/nfsroot/nfs1   192.168.0.0/24(rw,sync,wdelay,hide,no_subtree_check,sec=sys,secure,root_squash,no_all_squash)
/nfsroot/nfs2   192.168.0.0/24(rw,sync,wdelay,hide,no_subtree_check,sec=sys,secure,root_squash,no_all_squash)
/nfsroot        <world>(rw,sync,wdelay,hide,crossmnt,no_subtree_check,fsid=0,sec=sys,secure,root_squash,no_all_squash)

NFS客戶端:ide

showmount -e 192.168.0.7
Export list for 192.168.0.7:
/nfsroot      *
/nfsroot/nfs2 192.168.0.0/24
/nfsroot/nfs1 192.168.0.0/24
mount -o rw 192.168.0.7:/ /mnt/
vim /etc/fstab
192.168.0.7:/   /mnt/   nfs rw  0 0
相關文章
相關標籤/搜索