nfs基本配置

蒜香大龙虾 2024-08-08 01:23:04
Categories: Tags:

nfs基本配置

安装

1
yum install nfs-utils

创建共享文件夹

创建目录

1
2
mkdir /opt/nfs
echo "114514" > /opt/nfs/test.txt

设置共享文件夹

1
2
3
cat > /etc/exports << EOF
/opt/nfs *(rw,sync)
EOF

启动&防火墙

1
2
3
systemctl enable --now nfs-server
firewall-cmd --add-port={111,2049,20048}/{tcp,udp}
firewall-cmd --add-port={111,2049,20048}/{tcp,udp} --per

连接

安装nfs-utils

1
yum install nfs-utils -y

挂载

1
mount -t nfs 172.20.20.11:/opt/nfs /opt/nfs

测试结果

1
2
[root@linux2 opt]# cat /opt/nfs/test.txt 
114514