nfs挂载配置

nfs挂载步骤

服务器端

1.安装nfs-utils rpcbind

$sudo yum –y install nfs-utils rpcbind

2.文件开放出去配置/etc/exports

例子:/opt/data IP(rw, no_root_squash,no_all_squash,sync)

3.执行配置文件/etc/exports

$exportfs -r

4.Nfs配置生效并使rpcbindnfs服务开机启动

$sudo systemctl enable rpcbind

$sudo systemctl enable nfs(当报错时可改为: $sudo systemctl enable nfs-server.service)

$sudo systemctl start rpcbind

$sudo systemctl start nfs(当报错时可改为:$sudo systemctl start nfs-server.service)

$sudo systemctl status rpcbind

$sudo systemctl staus nfs(当报错时可改为:$sudo systemctl status nfs-server.service)

5.查看挂载命令

$showmount –e IP

6.客户端挂载步骤

1)安装nfs-utils rpcbind(同上)

2)Nfs配置生效并使rpcbindnfs服务开机启动(同上)

3)挂载命令(IP为服务器端ip地址)

$sudo mount –t nfs IP:/opt/data /opt/data

以下为nfs资料

一、NFS服务器的设定

NFS服务器的设定可以通过/etc/exports这个文件进行,设定格式如下:

分享目录      主机名称或者IP(参数1,参数2)

/arm2410s   10.22.22.*(rw,sync,no_root_squash)

可以设定的参数主要有以下这些:

rw:可读写的权限;
ro:只读的权限;
no_root_squash:登入到NFS主机的用户如果是root,该用户即拥有root权限;
root_squash:登入NFS主机的用户如果是root,该用户权限将被限定为匿名使用者nobody;
all_squash:不管登陆NFS主机的用户是何权限都会被重新设定为匿名使用者nobody。
anonuid:将登入NFS主机的用户都设定成指定的user id,此ID必须存在于/etc/passwd中。
anongid:同anonuid,但是变成group ID就是了!
sync:资料同步写入存储器中。
async:资料会先暂时存放在内存中,不会直接写入硬盘。
insecure:允许从这台机器过来的非授权访问。
例如可以编辑/etc/exports为:
/tmp     *(rw,no_root_squash)
/home/public 192.168.0.*(rw)   *(ro)
/home/test  192.168.0.100(rw)
/home/Linux  *.the9.com(rw,all_squash,anonuid=40,anongid=40)
设定好后可以使用以下命令启动NFS:
/etc/rc.d/init.d/portmap start (在REDHAT中PORTMAP是默认启动的)
/etc/rc.d/init.d/nfs start
exportfs命令
如果我们在启动了NFS之后又修改了/etc/exports,是不是还要重新启动nfs呢?这个时候我们就可以用exportfs命令来使改动立刻生效,该命令格式如下:
exportfs [-aruv]
-a :全部mount或者unmount /etc/exports中的内容
-r :重新mount /etc/exports中分享出来的目录
-u :umount 目录
-v :在 export 的时候,将详细的信息输出到屏幕上。

二、NFS客户端的操作:
1、showmout命令对于NFS的操作和查错有很大的帮助,所以我们先来看一下showmount的用法
showmout
-a :这个参数是一般在NFS SERVER上使用,是用来显示已经mount上本机nfs目录的cline机器。
-e :显示指定的NFS SERVER上export出来的目录。
2、mount nfs目录的方法:
mount -t nfs hostname(orIP):/directory /mount/point

原文地址:https://www.cnblogs.com/jtnote/p/6118612.html