天天看点

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