当前位置:   article > 正文

centos8配置nfs教程本机系统mac_centos8通过本地yum源安装nfs

centos8通过本地yum源安装nfs

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

  1. yum install -y nfs-utils rpcbind
  2. mkdir -p /data/nfs
  3. chown -R nfsnobody:nfsnobody /data/nfs

2 配置权限

vim /etc/exports

文件写入

  1. #nfs dir /data/nfs
  2. /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 优先将数据保存到内存,然后再写入硬盘;这样效率更高,但可能会丢失数据

启动配置

  1. service rpcbind start #启动服务
  2. 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 - 博客园


 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/煮酒与君饮/article/detail/974170
推荐阅读
相关标签
  

闽ICP备14008679号