NFS服务(2)服务搭建

 

简单NFS的实现

NFS服务器端:

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服务器上的共享目录列表

NFS服务器:

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客户端:

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

 

 
 
posted @ 2018-06-28 13:56  Gmiao  阅读(174)  评论(0编辑  收藏  举报