1. 安装环境
yum update
yum -y install nfs-utils rpcbind
2. 创建共享目录
mkdir -p /data/share
touch /data/share/mynfs.txt # 创建一个文件用于客户端连接测试
chmod 666 /data/share
3. 配置 exports(192.168.2.6为要搭建NFS服务的IP)
echo '/data/share 192.168.2.6/24(rw,no_root_squash,no_all_squash,sync)' >> /etc/exports
exportfs -r
4. 启动NFS和RPCBIND服务
service rpcbind start
service nfs start
5. 测试RPC状态
rpcinfo -p localhost
6. 在本地模拟联机
showmount -e localhost
7. 客户端连接(另一台主机)
- 安装客户端
- 挂载NFS
安装客户端
# Centos yum install -y nfs-utils # Ubuntu apt-get install -y nfs-common
挂载NFS
mount -t nfs 192.168.2.6:/data/share /share -o proto=tcp -o nolock
ll /share # 看是否能够看到 mynfs.txt,并编辑
参考:
https://www.cnblogs.com/liuyisai/p/5992511.html
https://blog.csdn.net/alex_equal/article/details/50405095
浙公网安备 33010602011771号