NFS的简单配置和使用

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/cx55887/article/details/82943459

准备工作:
1.关闭防火

# chkconfig iptables off
# service iptables stop
# service iptables status

2.关闭selinux

 # setenforce 0    <<< 临时关闭selinux
 # getenforce      <<< 查看seLinux的状态
 # sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config

第一步:安装nfs服务端(nfs rpc)

# yum install rpcbind nfs-utils -y

第二步:安装nfs客户端

# yum install rpcbind nfs-utils -y

(客户端仅仅需要安装nfs,不需要配置和启动)

第三步:在服务器端和客户端分别创建一个系统用户(访问nfs时转换的用户)

# groupadd -g 1024 tom
# useradd -u 1024 -r -s  /sbin/nologin -g 1024 tom
【服务器和各个客户端节点都要执行创建】

第四步:启动nfs的服务器端

# service rpcbind start
# chkconfig rpcbind on
# service nfs start
# chkconfig nfs on

第五步:检查rpc中所注册的端口信息

# rpcinfo -p localhost     <<< 从服务器端查看自己的rpc中所注册的端口信息
# rpcinfo -p 192.168.31.200  <<< 从客户端查看远程的nfs上的rpc中所注册的端口信息
注意:rpc服务的端口是111

第六步:共享一个目录

# mkdir  /data
# vim  /etc/exports
	/data  192.168.31.0/24(rw,async,insecure,all_squash,root_squash,anonuid=1024,anongid=102
# service nfs restart

第七步:在客户端挂载nfs所共享的目录
格式: mount -t nfs nfsIP:目录名 挂载点

# mkdir /root/nfsSource/
# mount -t nfs 192.168.31.200:/data /root/nfsSource/

第八步:在客户端使用该目录

# cd /root/nfsSource/
# touch a.txt
  >>> 此时报权限错误
  这是因为通过nfs所共享的目录,在使用这个目录的时候,是以一个特定的用户身份执行的,而不是root身份

解决在方式有两种
第一种:在 nfs 服务器端修改共享目录的权限位777
第二种:在 nfs 服务器端对nfsnobody所单独授权

  # chown 1024.1024 /data

猜你喜欢

转载自blog.csdn.net/cx55887/article/details/82943459
今日推荐