NFS
NFS
tips for Linux client
# prepare for Debian-Like
apt-get install nfs-common
sudo mount.nfs -o nfsvers=4,async,soft,rw,port=12049 192.168.1.1:/portainer /data/nas/nfs# fstab
192.168.96.7:/volume1/nfs /data/nas/nfs nfs nfsvers=4,async,soft,rw 0 0options reference:
https://docs.fedoraproject.org/en-US/Fedora/14/html/Storage_Administration_Guide/s1-nfs-client-config-options.html
tips for Windows client
REM 挂载/卸载
mount -o nolock anon 10.34.5.x:/mnt/Main/test X:
umount -a
REM 大小写敏感
nfsadmin client config casesensitive=yesREM 遇到停止后无法启动
REM Stop NFS Redirector
sc stop NfsRdr
REM Then start NFS client service
nfsadmin start client
REM Use 'nfsadmin client stop' to correctly shut down both the Client for NFS service and the Client for NFS Redirector.REM 超时/重试设置
nfsadmin client config timeout=30
nfsadmin client config retry=5提示
除了Win 2012,都只支持NFSv3,且不支持UTF-8
tips for FreeBSD server
choose version
rc.conf
nfs_server_enable="yes" nfsv4_server_enable="yes"
# 确定存在
sysctl vfs.nfsd.server_max_nfsvers=4
# 不确定是否存在
sysctl vfs.nfsd.server_min_nfsvers=4fsid
在nfs的配置文件/etc/exports中,fsid作为一个共享参数,具体含义如下:
syntax:
fsid=num|root|uuid
paraphrase:
NFS needs to be able to identify each filesystem that it exports.
Normally it will use a UUID for the filesystem (if the filesystem has such a thing) or the device number of the device holding the filesystem (if the filesystem is stored on the device).
As not all filesystems are stored on devices, and not all filesystems have UUIDs,
it is sometimes necessary to explicitly tell NFS how to identify a filesystem.
This is done with the fsid= option.
For NFSv4, there is a distinguished filesystem which is the root of all exported filesystem.
This is specified with ==fsid=root== or ==fsid=0== both of which mean exactly the same thing.
Other filesystems can be identified with a small integer, or a UUID which should contain 32 hex digits and arbitrary punctuation.
提示
如果要实现NFS高可用,必须配置fsid
要通过NFS共享一个目录,首先需要在/etc/exports文件中定义这个目录,并且使用fsid=0的参数。
(使用fsid=0选项的时候只能共享一个目录,这个目录将成为NFS服务器的根目录。)
squash选项
no_root_squash: 不做映射,如果是root身份则保持root身份,极不安全
root_squash: 如果是root身份则映射成指定用户,通常是nobody,其它身份则不变
all_squash: 一律映射成指定用户