nfs-文件共享搭建

12次阅读

共计 906 个字符,预计需要花费 3 分钟才能阅读完成。

1. 安装 rpcbind ,nfs-tools

参考该链接
rpm -qa rpcbind nfs-tools// 检查是否已安装次工具

yum install rpcbind nfs-tools -y

yum install net-tools lsof -y // 安装端口检查和服务的工具

2. 启动 rpcbind

systemctl status rpcbind
systemctl start rpcbind

lsof -i :111 // 查看 rpcbind 111 端口是否开启

netstat -tulnp | grep rpcbind // 检查 rpcbind 服务 

2.1 查看 nfs 服务向 rpc 注册的端口信息

rpcinfo -p localhost 此时 nfs 还没开启,所以没太多的注册端口信息

检查 rpcbind 是否开机启动
systemctl is-enabled rpcbind

3. 开启 nfs

systemclt start nfs

systemclt status nfs

3.1 创建共享目录

mkdir /data
chown -R nfsnobody:nfsnobody /data

3.2 服务端 nfs 配置

vim /etc/exprots

/data 192.168.100.0/24(rw,sync)
`ps:` 该 ip 为 nfs 客户端的 ip 


`exports -rv` 让配置生效

`cat /var/lib/nfs/etab` 查看 nfs 开始的参数,包含默认的参数

3.3 测试服务端能否自己挂载

mkdir /data2
mount -t nfs 192.168.100.128:/data /data2
df -h 

3.4 查看 nfs 服务器连接了哪些客户端

cat /var/lib/nfs/rmtab

4. 客户端连接 nfs 服务端

yum install rpcbind nfs-tools -y

systemctl start rpcbind

yum install showmount -y

showmount -e 192.168.100.128 // 查看客户端是否有权限连接 nfs 服务端机器

ps: 这里要提前关闭 nfs 服务端的防火墙,该命令为

systemctl stop firewalld

4.1 挂载

mount -t nfs 192.168.100.128:/data /data2

查看 df -h

正文完
 0