NFS Server 很常用,但是坑也是巨大的。之前在京东运维 Hadoop 集群的时候碰到过脑裂,原因就是 NFS 引起的。
关键 NFS 是内核态的,一旦崩溃,那么客户端的所有命令,ls、df、du等等,统统无反应,结果是很悲剧的。
下面要推荐一下 nfs-ganesha ,它是用户态的nfs-server,支持v3和v4,而nfs缺省是内核态的v3。
强烈推荐大家用这个,而不是用内核态的,并且 nfs-ganesha 还是支持 glusterFS 的。
1yum install -y centos-release-nfs-ganesha30.noarch
2
3vi /etc/ganesha/ganesha.conf
4%include /etc/ganesha/exports/gv0.conf
5
6vi /etc/ganesha/exports/gv0.conf
7EXPORT{
8 Export_Id = 1 ; # Export ID unique to each export
9 Path = "/mnt/upload";
10 Pseudo = /upload;
11 FSAL {
12 name = VFS;
13 }
14 Access_type = RW; # Access permissions
15 Squash = No_root_squash; # To enable/disable root squashing
16 Disable_ACL = TRUE; # To enable/disable ACL
17 Protocols = "4" ; # NFS protocols supported
18 Transports = "UDP","TCP" ; # Transport protocols supported
19 SecType = "sys"; # Security flavors supported
20}
21
22#启动
23systemctl restart nfs-ganesha
24
25#手动mount的方法
26mount -t nfs -o soft,intr,rsize=8192,wsize=8192,timeo=900,proto=tcp,vers=4 192.168.31.2:/upload /mnt/nfs-upload
27
28#自动mount的方法
29cat /etc/fstab
30192.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