NFS Server 很常用,但是坑也是巨大的。之前在京东运维 Hadoop 集群的时候碰到过脑裂,原因就是 NFS 引起的。
关键 NFS 是内核态的,一旦崩溃,那么客户端的所有命令,ls、df、du等等,统统无反应,结果是很悲剧的。
下面要推荐一下 nfs-ganesha ,它是用户态的nfs-server,支持v3和v4,而nfs缺省是内核态的v3。
强烈推荐大家用这个,而不是用内核态的,并且 nfs-ganesha 还是支持 glusterFS 的。
yum install -y centos-release-nfs-ganesha30.noarch
vi /etc/ganesha/ganesha.conf
%include /etc/ganesha/exports/gv0.conf
vi /etc/ganesha/exports/gv0.conf
EXPORT{
Export_Id = 1 ; # Export ID unique to each export
Path = "/mnt/upload";
Pseudo = /upload;
FSAL {
name = VFS;
}
Access_type = RW; # Access permissions
Squash = No_root_squash; # To enable/disable root squashing
Disable_ACL = TRUE; # To enable/disable ACL
Protocols = "4" ; # NFS protocols supported
Transports = "UDP","TCP" ; # Transport protocols supported
SecType = "sys"; # Security flavors supported
}
#启动
systemctl restart nfs-ganesha
#手动mount的方法
mount -t nfs -o soft,intr,rsize=8192,wsize=8192,timeo=900,proto=tcp,vers=4 192.168.31.2:/upload /mnt/nfs-upload
#自动mount的方法
cat /etc/fstab
192.168.31.2:/upload /mnt/nfs-upload nfs rw,vers=4,addr=192.168.31.2,clientaddr=192.168.31.8 0 0
注意id对齐问题可能要用到rpcidmapd