nfs 是什么
FreeBSD支持的文件系统中的一种,它允许网络中的计算机之间通过
TCP/IP网络共享资源
centos安装 NFS 服务
服务端
$ yum install -y nfs-utils rpcbind
客户端
$ yum install -y nfs-utils
启动
我们先启动 RPC 服务
$ service rpcbind start
或者使用如下命令亦可
$ /bin/systemctl start rpcbind.service
查看 NFS 服务项 rpc 服务器注册的端口列表
$ rpcinfo -p localhost
启动 NFS 服务
$ service nfs start
或者使用如下命令亦可
/bin/systemctl start nfs.service
启动 NFS 服务后 rpc 服务已经启用了对 NFS 的端口映射列表
rpcinfo -p localhost
常用命令
service nfs start
service nfs status
service nfs stop
showmount -e 查看本机发布的共享目录
客户端 showmount -e 服务端ip 查看服务器的目录
showmount -e 192.168.43.60
配置文件位置
/etc/exports
修改配置
/nfs 192.168.1.0/24 (rw,sync,no_root_squash)
/nfs #代表共享出来的目录
192.168.1.0/24 #允许192.168.1.0/24的网络访问此共享。 可以直接配置ip或者 (所有网络)或者 192.168.1.
rw #表示权限 读写
sync #表示同步写入
no_root_squash #表示客户机以root访问时赋予本地root权限
多个网络demo
/fns 192.168.1.0/24 (rw,sync,no_root_squash) 192.168.2.0/24 (rw)
客户端配置
#创建共享目录
mkdir /nfs
同步共享(serverip)
mount 192.168.1.1:/nfs /nfs/
挂载后就可以看到服务器的文件了
常见错误
clnt_create: RPC: Program not registered
解决方法:
在服务器端输入
rpc.mountd