NFS
- nfs链接linux-nfs.orgnfs · ArchLinux NFS · 参考 · NFS 性能调优 · 组件 · rpc.nfsd · rpc.idmapd · rpc.mountd - NFS mount daemon · -p 32767 · rpc.statd - NSM service daemon笔记:NFS
- ArchLinux NFS链接wiki.archlinux.org/index.php/NFSnfs · ArchLinux NFS · 参考 · NFS 性能调优 · 组件 · rpc.nfsd · rpc.idmapd · rpc.mountd - NFS mount daemon · -p 32767 · rpc.statd - NSM service daemon笔记:NFS
- 参考
- NFS 性能调优链接www.cyberciti.biz/faq/linux-unix-tuning-nfs-server-client-performancenfs · ArchLinux NFS · 参考 · NFS 性能调优 · 组件 · rpc.nfsd · rpc.idmapd · rpc.mountd - NFS mount daemon · -p 32767 · rpc.statd - NSM service daemon笔记:NFS
- 组件
- rpc.nfsd
- rpc.idmapd
- rpc.mountd - NFS mount daemon
- -p 32767
- rpc.statd - NSM service daemon
- A daemon that listens for reboot notifications from other hosts, and manages the list of hosts to be notified when the local system reboots
- -p 32765 -o 32766
- 锁服务
- 挂载可使用 nolock 指定不启用锁
- sm-notify - A helper program that notifies NFS peers after the local system reboots
- rpc.gssd - gss-api generic security api to provide security for protocols using rpc
- rpc.svcgssd
- rpc.rquotad - remote quota server
| conf | for | demo |
|---|---|---|
| /etc/exports | 对外暴露的文件 | /usr/local 192.168.0.1(ro) 192.168.0.2(ro)/home 192.168.0.0/255.255.255.0(rw) |
| /etc/hosts.allow | 允许访问的主机 | portmap:ALL |
| /etc/hosts.deny | 禁止访问的主机 | lockd: 192.168.0.1 , 192.168.0.2 |
| /var/lib/nfs/etab | 导出的主表 | |
| /var/lib/nfs/rmtab | 访问服务端的客户端 |
- 允许本地访问远程文件
- 使用 C/S 结构在
*nix之间分享文件 - 两个机器之间不需要允许相同的操作系统
- 可使用 NSF 指定中心存储解决方案
- 用户不需要关系文件的物理位置
- 不需要手动刷新来显示文件
- 新版本的 NFS 也支持 ACL
- 可用过防火墙和 Kerberos 来保证安全
- 默认 2049 端口
- 使用 Kerberos 可使用密码进行验证
- showmount
-e显示本地共享-e <server-ip or hostname>显示远程共享-d例举所有子目录
- exportfs
-v例举共享的文件和选项-a导出所有/etc/exports中的共享配置-u取消共享/etc/exports中的配置-r在修改/etc/exports后刷新服务共享列表
- AlpineLinux Setting up a nfs-server
- /etc/exports
- kodi.wiki/view/NFS链接kodi.wiki/view/NFSnfs · ArchLinux NFS · 参考 · NFS 性能调优 · 组件 · rpc.nfsd · rpc.idmapd · rpc.mountd - NFS mount daemon · -p 32767 · rpc.statd - NSM service daemon笔记:NFS
- ArchLinux NFS链接wiki.archlinux.org/index.php/NFSnfs · ArchLinux NFS · 参考 · NFS 性能调优 · 组件 · rpc.nfsd · rpc.idmapd · rpc.mountd - NFS mount daemon · -p 32767 · rpc.statd - NSM service daemon笔记:NFS/简体中文
- NFS 本身没有授权访问机制, 基本只能限制 IP, 和 Kerberos 配合是可以的
- help.ubuntu.com/community/NFSv4Howto
- cifs 相比 NFS 有授权
- SMB vs NFS authentication
- NFS 如果感觉有问题,可以尝试使用 v3 版本
-o v3
- 避免 NAT 使用 nfs - 部分服务可能有问题,例如 statd
apk add nfs-utils
# 启动
service nfs start
# 开机启动
rc-update add nfs
# 导出所有定义的共享
# 将 /etc/exports 定义输出到 /var/lib/nfs/etab
exportfs -a
# 取消所有共享 - 清除 /var/lib/nfs/etab
exportfs -au
# 查看服务提供的共享
showmount -e localhost
# NFSv4 可以挂在根目录
mount server:/ /mountpoint/on/client
# 挂载单个目录
mount -t nfs -o vers=4 servername:/srv/nfs/music /mountpoint/on/client
# fstab
# servername:/music /mountpoint/on/client nfs defaults,timeo=900,retrans=5,_netdev 0 0# 安装
apk add nfs-utils
# 开机前启动服务
rc-update add nfs
rc-update add nfsmount
# 立即启动服务
rc-service nfs start
rc-service nfsmount start
# 共享该目录
sudo mkdir -p /share
# 赋予当前用户共享目录权限
sudo chown $USER /share
# Linux
# ========
echo '/nfsshare 192.168.0.101(rw,sync,no_root_squash)' | sudo tee /etc/exports
# 如果想让客户端非 root 访问服务端 root 信息, 则可以
# all_squash,anonuid=0,anongid=0
# 使所有用户都作为匿名用户,而匿名用户则默认为 root
# 也可以指定为特定的用户,例如 id asterisk
# macOS
# ==========
echo '/share -network 192.168.0.0 -mask 255.255.0.0' | sudo tee /etc/exports
nfsd enable
nfsd start
nfsd status
nfsd checkexport
# 如果修改了 exports 文件
nfsd update
showmount -e
# 查看共享目录
showmount -e 192.168.34.120
mount -t nfs 192.168.0.100:/share /mnt/nfsshare
umount 192.168.0.100:/share
# 关闭 nfs
nfsd stop
nfsd disable
# 如果 mac 下 mount 出现 Operation not permitted, 则添加 -o resvport
mount -t nfs -o resvport 192.168.1.1:/ ~/mnt/alpine/Awesome
- nfs-ganesha/nfs-ganeshaGitHubnfs-ganesha/nfs-ganesha
- C
- NFSv3,v4,v4.1 fileserver
- willscott/go-nfsGitHubwillscott/go-nfs
- golang NFSv3 server
nfs-utils
- /proc/fs/nfsd
- /proc/fs/nfs
- /etc/exports
- 共享目录定义
- /usr/sbin/exportfs
- 管理共享的目录 -
/var/lib/nfs/etab -a导出所有 - 将/etc/exports同步到/var/lib/nfs/etab- 更新内核的导出表-u移除一个导出-au移除所有导出-f移除所有
- 管理共享的目录 -
- /sbin/rpc.statd
- 从其它主机监听重启通知
- 当本地系统重启,管理被通知的主机列表
- /usr/sbin/sm-notify
- 发送重启通知到 NFS 端
- /sbin/mount.nfs
- /sbin/umount.nfs
- /sbin/umount.nfs4
- /sbin/mount.nfs4
- /usr/sbin/showmount
- 查看挂载信息
/sbin/nfsdcld /sbin/nfsdcltrack nfs-utils edge main x86_64
/usr/sbin/showmount nfs-utils edge main x86_64 /usr/sbin/rpc.nfsd nfs-utils edge main x86_64 /usr/sbin/nfsidmap nfs-utils edge main x86_64 /usr/sbin/start-statd nfs-utils edge main x86_64 /usr/sbin/mountstats nfs-utils edge main x86_64 /usr/sbin/rpc.svcgssd nfs-utils edge main x86_64 /usr/sbin/blkmapd nfs-utils edge main x86_64 /usr/sbin/nfsiostat nfs-utils edge main x86_64 /usr/sbin/rpc.idmapd nfs-utils edge main x86_64 /usr/sbin/rpc.gssd nfs-utils edge main x86_64 /usr/sbin/nfsstat nfs-utils edge main x86_64 /usr/sbin/rpc.mountd nfs-utils edge main x86_64 nfs-utils edge main x86_64 /usr/sbin/rpcdebug nfs-utils edge main x86_64
/usr/sbin/nfsconf nfs-utils edge main x86_64 /var/lib/nfs/rmtab nfs-utils edge main x86_64 /var/lib/nfs/etab nfs-utils edge main x86_64 /var/lib/nfs/state
CacheFS
How can I cache NFS shares on a local disk? askubuntu.com/a/4578/267103
FS-Cache & CacheFS: Caching for Network File Systems www.linux-mag.com/id/7378
Wikipedia:CacheFSWikipediaCacheFS pkgs.alpinelinux.org/package/v3.7/community/x86_64/cachefilesd
CacheFiles /var/fscache CacheFS block 级别
FS-Cache 接口
netfs nfs,afs,isofs
/proc/fs/fscache/stats
/proc/fs/fscache/histogram
Ports
program vers proto port
100000 2 tcp 111 portmapper,rpcbind
100000 2 udp 111 portmapper
100005 1 udp 950 mountd
100005 3 udp 950 mountd
100005 1 tcp 884 mountd
100005 3 tcp 884 mountd
100003 2 udp 2049 nfs
100003 3 udp 2049 nfs
100003 2 tcp 2049 nfs
100003 3 tcp 2049 nfs
100024 1 udp 644 status
100024 1 tcp 918 status
100021 0 udp 630 nlockmgr
100021 1 udp 630 nlockmgr
100021 3 udp 630 nlockmgr
100021 4 udp 630 nlockmgr
100021 0 tcp 917 nlockmgr
100021 1 tcp 917 nlockmgr
100021 3 tcp 917 nlockmgr
100021 4 tcp 917 nlockmgrexports
关联信息
反向链接、本文链接的其他页面和外部资料。
参考资料
GitHub2 条
- nfs-ganesha/nfs-ganeshagithub.com/nfs-ganesha/nfs-ganesha
- willscott/go-nfsgithub.com/willscott/go-nfs
Wikipedia1 条
- CacheFSWikipedia:CacheFS
其他外链15 条
- wiki.archlinux.org/index.php/NFSwiki.archlinux.org/index.php/NFS
- access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/5/html/Deployment_Guide/s1-nfs-server-config-exports.htmlaccess.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/5/html/Deployment_Guide/s1-nfs-server-config-exports.html
- askubuntu.com/a/4578/267103askubuntu.com/a/4578/267103
- git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/filesystems/caching/fscache.txtgit.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/filesystems/caching/fscache.txt
- git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/filesystems/caching/netfs-api.txtgit.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/filesystems/caching/netfs-api.txt
- help.ubuntu.com/community/NFSv4Howtohelp.ubuntu.com/community/NFSv4Howto
- kodi.wiki/view/NFSkodi.wiki/view/NFS
- linux-nfs.orglinux-nfs.org/
- linux.die.net/man/5/exportslinux.die.net/man/5/exports
- pkgs.alpinelinux.org/package/v3.7/community/x86_64/cachefilesdpkgs.alpinelinux.org/package/v3.7/community/x86_64/cachefilesd
- serverfault.com/q/597254/190601serverfault.com/q/597254/190601
- wiki.alpinelinux.org/wiki/Setting_up_a_nfs-serverwiki.alpinelinux.org/wiki/Setting_up_a_nfs-server
- wiki.archlinux.org/index.php/NFS_(简体中文)wiki.archlinux.org/index.php/NFS_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)
- www.cyberciti.biz/faq/linux-unix-tuning-nfs-server-client-performancewww.cyberciti.biz/faq/linux-unix-tuning-nfs-server-client-performance
- www.linux-mag.com/id/7378www.linux-mag.com/id/7378