Linux配置NFS

1.安装NFS服务 yum install nfs-utils

2.在NFS服务器上创建NFS文件共享目录
[root@localhost ~]# mkdir /nfsfile
[root@localhost ~]# chmod -Rf 777 /nfsfile
[root@localhost ~]# echo “test NFS” >> /nfsfile/test.txt

3.NFS服务程序的配置文件为/etc/exports
格式 : 共享目录路径 允许访问NFS客户端 (共享权限参数)
vim /etc/exports
/nfsfile 192.168.0.*(rw,sync,root_squash)
注意:*号后无空格

4.启动(NFS服务进行文件共享之前,需要使用RPC(远程调用)服务将NFS服务器的IP地址和端口号等信息发送给客户端,因此还需启动rpcbind服务程序)
[root@localhost ~]# systemctl restart rpcbind
[root@localhost ~]# systemctl enable rpcbind //加入开机启动项
[root@localhost ~]# systemctl start nfs-server
[root@localhost ~]# systemctl enable nfs-server //加入开机启动项

[root@localhost ~]# systemctl reload nfs-server //修改/etc/exports后重新加载配置文件

客户端:
1.查看
[root@localhost ~]# showmount -e 192.168.0.5 查看挂载目录

2.磁盘挂载
[root@localhost ~]# mkdir /client_nfs
mount -t 挂载文件系统的类型 服务器ip:共享文件目录 挂载到本地系统目录
[root@localhost ~]# mount -t nfs 192.168.0.5:/nfsfile /client_nfs/
NFS磁盘卸载
umount -l /client_nfs
选项 –l 在该目录空闲后再umount。

扩展:
1)希望NFS文件共享服务一直有效,在客户端的/etc/fstab文件中写入即可
192.168.0.5:/nfsfile /clinet_nfs nfs default 0 0

autofs自动挂载(用户在使用挂载到本地的磁盘时,自动完成挂载操作.节省远程NFS服务器资源)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值