linux NFS 服务手动挂载nas文件

linux NFS 服务手动挂载nas文件


【服务端server】配置:

nas 服务端配置,安装centos系统时候勾选选择NFS 包,NFS相关工具就都安装了,

也可以手动安装

安装nfs工具

nfs-utils:包含NFS服务端守护进程和NFS客户端的工具

rpcbind:提供RPC的端口映射的守护进程及其相关文档、执行文件等

yum -y install nfs-utils rpcbind


NFS使用/etc/exports定义需要共享的目录及访问对象的控制,默认无,可以自己创建

vim /etc/exports

/app/test/ 192.168.45.0/255.255.255.0(rw,no_root_squash,async)

配置说明:

1、/app/test/:这个是本地要共享出去的目录;

2、*:指的是允许的ip地址指的是【客户机client】,*表示所有;可以是一个IP:10.1.1.0,也可以是一个IP段;

3、(rw,sync,no_root_squash):

1)rw表示可读写,ro只读;

2)sync :同步模式,时时写入磁盘;async :不同步,定期写入磁盘;

3)no_root_squash :加上这个选项后,root用户就会对共享的目录拥有至高的权限控制,就像是对本机的目录操作一样。

不安全,不建议使用;

root_squash:和上面的选项对应,root用户对共享目录的权限不高,只有普通用户的权限,即限制了root;

all_squash:不管使用NFS的用户是谁,他的身份都会被限定成为一个指定的普通用户身份;

4)anonuid/anongid :要和root_squash 以及all_squash一同使用,用于指定使用NFS的用户限定后的uid和gid

,前提是本机的/etc/passwd中存在这个uid和gid。

5)fsid=0表示将/app/eweb整个目录包装成根目录

比如这样配置:/app/test *(rw,sync,no_root_squash,fsid=0)

复杂配置示例:/app/test 192.168.1.8/24(rw,no_root_squash,no_all_squash,sync,anonuid=501,anongid=501)


配置生效

exportfs -arv

设置rpcbind、nfs开机启动

 systemctl enable rpcbind.service
 systemctl enable nfs-server.service


启动命令

systemctl start rpcbind.service    

nfs无需启动

systemctl start nfs.service 
systemctl start nfs-server.service #rock9 


检查NFS服务器是否启动

rpcinfo -p

查看【服务机server】可挂载目录

showmount -e 192.168.45.132

如果报错:clnt_create: RPC: Program not registered   

解决方式一:

systemctl stop rpcbind.service
systemctl start rpcbind.service systemctl start nfs-server.service #rock9k
#开放端口
firewall-cmd --permanent --add-service=rpc-bind
firewall-cmd --permanent --add-service=mountd
firewall-cmd --permanent --add-port=2049/tcp
firewall-cmd --permanent --add-port=2049/udp
firewall-cmd --reload


【客户端client】部署NFS服务


在客户端查看可挂载目录

showmount -e 192.168.45.132

如果报错:clnt_create: RPC: Program not registered   

解决方式一:



systemctl stop rpcbind.service
systemctl start rpcbind.service systemctl start nfs-server.service

设置autoshare 自动挂载:/etc/auto.share

/app/test/  -fstype=nfs,vers=3,rw   192.168.45.132:/app/test/



NFS文件系统挂载与卸载

#挂载格式:mount -t nfs 服务器地址:/共享目录 /本机挂载点

#卸载格式:umount 挂载目标


将【服务器server】共享目录挂载到本地的/app/test目录

mount -t nfs 192.168.45.132:/app/test/ /app/test



  • 发表于 2023-03-07 15:59
  • 阅读 ( 1078 )
  • 分类:linux

0 条评论

请先 登录 后评论
omicsgene
omicsgene

生物信息

658 篇文章

作家榜 »

  1. omicsgene 658 文章
  2. 安生水 328 文章
  3. Daitoue 167 文章
  4. 生物女学霸 120 文章
  5. 红橙子 78 文章
  6. CORNERSTONE 72 文章
  7. xun 67 文章
  8. rzx 67 文章