赞
踩
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 只读 |
启动配置
- 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
=========================================================================
yum install nfs-utils nfs-utils-lib -y
如果出现上述错误请安装lvm2
yum install -y lvm2
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 #此选项可防止子树检查
exportfs -a
可以使用-r刷新
exportfs -r
/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
service nfs-server start
service rpcbind start
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 - 博客园
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。