NFS的具体配置流程

NFS Server端的配置

1)、安装NFS相关软件包
安装nfs-utils和rpcbind
[root@linuxserver ~]# yum install -y nfs-utils rpcbind

查看已安装版本
[root@linuxserver ~]# rpm -qa | grep nfs


(2)、配置NFS共享目录
编辑/etc/exports文件:

[root@linuxserver ~]# vim /etc/exports
​添加以下内容​(按需调整):
/webdata *(sync,rw,all_squash)
/tmp     *(rw,no_root_squash)
/home/share  192.168.1.*(rw,root_squash)   *(ro)
/opt/data   192.168.1.18(rw)​执行如下命令,使配置生效:
[root@linuxserver ~]# exportfs -rv ###生效配置文件
#启动并启用NFS服务
[root@linuxserver ~]# systemctl start nfs-server
[root@linuxserver ~]# systemctl start rpcbind
#设置开机自启
[root@linuxserver ~]# systemctl enable nfs-server
[root@linuxserver ~]# systemctl enable rpcbind
#查看服务状态
[root@linuxserver ~]# systemctl status nfs-server
[root@linuxserver ~]# systemctl status rpcbind
#关闭防火墙和selinux
[root@linuxserver ~]# systemctl stop firewalld
[root@linuxserver ~]# systemctl disable firewalld
[root@linuxserver ~]# setenforce 0

NFS客户端的设定


客户端系统也是linux,首先需要在客户端安装nfs-utils和rpcbind两个服务:

[root@localhost ~]# yum -y install nfs-utils
[root@localhost ~]# systemctl start rpcbind
[root@localhost ~]# systemctl enable rpcbind

关闭NFS Server上开启了防火墙:

[root@NFS Server ~]# systemctl stop firewalld
[root@NFS Server ~]# systemctl disable firewalld

客户端要使用NFS Server提供的共享资源,使用mount命令挂载就可以了:
挂载的格式:

[root@localhost ~]#mount -t nfs Hostname(orIP):/directory /mountpoint
Hostname:用来指定NFS Server的地址,可以是IP地址或主机名。
/directory:表示NFS Server共享出来的目录资源。
/mountpoint:表示客户端主机指定的挂载点。通常是一个空目录。

例如:

[root@localhost ~]#mount -t nfs 192.168.60.133:/mydata /data/nfs(临时挂载)

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注