1.软件安装

2.配置文件

服务端

vi /etc/nfs.conf

#为方便防火墙管理,禁用NFSv2、NFSv3需要依赖rpcbind的服务,只启用NFSv4(只需放行2049端口)
[nfsd]
vers2=n
vers3=n
vers4=y
vers4.0=y
vers4.1=y
vers4.2=y

禁用 rpcbind服务

systemctl stop rpcbind.socket rpcbind.service
systemctl disable rpcbind.socket rpcbind.service

重启服务
systemctl restart nfs-server

放行防火墙
firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="$client_IP" port port="2049" protocol="tcp" accept'

客户端权限分配
vi /etc/exports

#arm-01
/mnt/data/hath-x  $IPv4(rw,sync,no_subtree_check,no_root_squash)
/mnt/data/hath-x  $IPv6(rw,sync,no_subtree_check,no_root_squash)

客户端

为了提升 hath 服务质量,由于我们需要配置 FSC,通过本地缓存加快响应时间

安装 cachefilesd
apt install cachefilesd

由于 cachefilesd会根据 /etc/fstab挂载参数
hath-nfs-server:/data/hath-x /data/hath-x nfs nfsvers=4.1,fsc,rw,_netdev,noatime,nodiratime,rsize=524288,wsize=524288,hard,timeo=100,retrans=3,nconnect=8,acregmax=60,acdirmax=60 0 0

在目录 /var/cache/fscache/cache/下生成 Infs,4.1,a,108………… 的本地缓存目录,为了后续维护方便,我们使用 NFS别名

echo "$ipv4 hath-nfs-server" >> /etc/hosts

启用 cachefilesd
echo "RUN=yes" >>/etc/default/cachefilesd

本地缓存大小以及缓存更新配置
/etc/cachefilesd.conf

启动 cachefilesd

systemctl start cachefilesd
systemctl enable cachefilesd

查看缓存状态
cat /proc/fs/fscache/stats

效果图
image

标签: none

添加新评论