一般准备两台机器,一台server端(服务端),一台client端(客户端)。
**NFS(Network File System)**即网络文件系统,是FreeBSD支持的文件系统中的一种,它允许网络中的计算机之间共享资源。nfs主要应用于linux和linux系统之间,与ftp和samba不同。
rpcbind是一个RPC服务,主要是在nfs共享时候负责du通知客户端,服务器的zhinfs端口号的。简单理解rpc就是一个中介服务。(systemctl start rpcbind是开启rpc服务的命令)
service端:IP(192.16.2.75) centos client端 : IP (192.168.2.76)centos
1.在服务端安装nfs和rpcbind yum install nfs-utils rpcbind -y
2.编译/etc/exports配置文件 vim /etc/exports
exports文件配置如下: /home/public 192.168.2.0/24(ro,async) (上面是配置格式,共享的目录,IP设置,端口,参数)
参数包括: 权限属性: ro:只读 rw:读写 sync:同步,数据同步写到内存与硬盘中 async:异步,数据先暂存内存 root_squash: 将root用户映射为来宾账号(匿名账户) no_root_squash: 有root的权限,不建议使用 all_squash: 全部映射为来宾账号 (匿名账户) anonuid, anongid: 指定映射的来宾账号(匿名账户)的UID和GID
3.启动nfs服务 systemctl start nfs
1.安装nfs和rpcbind yum install nfs-utils rpcbind -y
2.先启动rpcbind,然后启动nfs服务 service rpcbind start service nfs start 或 systemctl start rpcbind systemctl start start
1.挂载服务端的public目录到客户端的share目录 mount -t nfs 192.168.2.75:/home/public /share
2.查看挂载内容showmount showmount -e 192.168.2.75
3.也可以卸载umount umount /public(需要卸载的目录)