天天看點

nfs部署和優化

NFS  就是 network file system 網絡檔案系統

在網絡上共享檔案

服務端 yum install -y nfs-utils rpcbind

vim /etc/exports

/mnt 192.168.1.105(rw,sync)                 #  192.168.1.* 可表示整個網段

/etc/init.d/rpcbind start

/etc/init.d/nfs start

用戶端:

yum install nfs-utils

showmount -e 192.168.1.16

顯示共享的資訊ll

mount -t nfs 192.168.1.16:/mnt /opt

進行挂載

df -h 

顯示挂載資訊

服務端:

ls -ld /mnt/

顯示/mnt/權限

cd /opt/

touch 1.txt

不能建立檔案

cd /mnt/

chmod 777 .

可建立檔案

ls -l

顯示檔案1.txt 使用者為 nfsnobody

需更改使用者 ll

cat /etc/passwd

顯示使用者 weifeng 500

/mnt 192.168.1.105(rw,sync,all_squash,anonuid=500,anongid=500)

exportfs -arv

cd

umount -l /opt/

mount -t nfs -onolock,nfsvers=3 192.168.1.16:/mnt /opt

touch 2.txt

顯示建立檔案使用者名 weifeng

/mnt 192.168.1.105(rw,sync,no_root__squash)

cd

umount /opt/

rm -rf ./*

touch 111

顯示建立檔案使用者名 root