centos8配置nfs教程本机系统mac

1 在服务器端 安装nfs 以及 rpcbind

yum install -y nfs-utils  rpcbind

mkdir  -p /data/nfs

chown -R nfsnobody:nfsnobody /data/nfs 

2 配置权限

vim /etc/exports

文件写入

#nfs dir /data/nfs

/data/nfs  192.168.1.0/24(rw) #客户端ip(rw,sync,insecure) #不加insecure会connect refuse

nfs 服务命令配置参数

ro 只读
rw 读写
root_squash 当NFS客户端以root管理员访问时,映射为NFS服务器的匿名用户
no_root_squash 当NFS客户端以root管理员访问时,映射为NFS服务器的root管理员
all_squash 无论NFS客户端使用什么账户访问,均映射为NFS服务器的匿名用户
sync 同时将数据写入到内存与硬盘中,保证不丢失数据
async 优先将数据保存到内存,然后再写入硬盘;这样效率更高,但可能会丢失数据

启动配置

service rpcbind start #启动服务
systemctl enable rpcbind #设置开机启动

 查询nfs挂载,showmount  -e  192.168.1.24 后面可以接ip来查看

 3 客户端连接

mount -t nfs 192.168.85.131:/data/nfs/sunshine  /Users/apple/Documents/share-nfs/    #挂载nfs server的/data/nfs 到/nfs

=========================================================================

服务端安装nfs

1、使用yum安装nfs

yum install nfs-utils nfs-utils-lib -y

如果出现上述错误请安装lvm2

yum install -y lvm2


2、编辑文件exports

vim /etc/exports

加入代码,如:

/home *(insecure,rw,sync,no_root_squash)

#参数详解

ro #只读共享

rw #读写共享

sync #同步写操作

async #异步写操作

wdelay #延迟写操作

root_squash #屏蔽远程root权限

no_root_squash #不屏蔽远程root权限

all_squash #屏蔽所有远程用户的权限

no_subtree_check #此选项可防止子树检查

3、运行导出

exportfs -a

 可以使用-r刷新

exportfs -r

4、开启端口

/sbin/iptables -I INPUT -p tcp -s 192.168.0.41 --dport 111 -j ACCEPT

/sbin/iptables -I INPUT -p tcp -s 192.168.0.41 --dport 2049 -j ACCEPT

/sbin/iptables -I INPUT -p tcp -s 192.168.0.41 --dport 30001 -j ACCEPT

/sbin/iptables -I INPUT -p tcp -s 192.168.0.41 --dport 30002 -j ACCEPT

/sbin/iptables -I INPUT -p tcp -s 192.168.0.41 --dport 30003 -j ACCEPT

/sbin/iptables -I INPUT -p tcp -s 192.168.0.41 --dport 30004 -j ACCEPT

或者简单粗暴 关闭防火墙

查看状态

systemctl status firewalld.service

打开防火墙

systemctl start firewalld.service

关闭防火墙

systemctl stop firewalld.service

开启防火墙

systemctl enable firewalld.service

禁用防火墙

systemctl disable firewalld.service

5、启动nfs和rpc服务

service nfs-server start

service rpcbind start

客户端安装nfs

1、安装nfs

yum install nfs-utils -y

2、使用mount远程共享

mount -t nfs 192.168.0.41:/memory/a1 /home

3、开机自动挂载

vi /etc/fstab

192.168.0.41:/memory/a1 /home ext4 defaults 0 0

扩展功能

以只读的方式挂载

mount -t nfs  -o ro,bg,soft,nolock 192.168.0.41:/tmp /nfs/tmp

以写的方式挂载

mount -t nfs  -o rw,bg,soft,nolock 192.168.0.41:/tmp /nfs/tmp

卸载

umount 192.168.0.41:/memory/a1

Linux 搭建NFS文件服务器实现文件共享 - oldmonk - 博客园


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值