NFS共享文件系统搭建

分享个人觉得写的不错的NFS相关介绍 点击跳转即可

  • server端
    安装
yum install -y nfs-utils

修改配置文件

vim /etc/exports
/home/share/ 192.168.1.0/24(rw,sync,fsid=0)
#/home/share/ 192.168.1.1(rw,sync,fsid=0) 192.168.1.2(rw,sync,fsid=0)

测试

exportfs -v
exportfs: /etc/exports:1: syntax error: bad option list

出现上述错误,一般为格式不正确,中英文、空格等 请自行校对

正确显示

exportfs -v
/home/share
		192.168.1.0/24(rw,sync,fsid=0)(sync,wdelay,hide,no_subtree_check,fsid=0,sec=sys,rw,secure,root_squash,no_all_squash)
		

启动服务

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

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

查看rpc服务

rpcinfo -p
program vers proto   port  service
    100000    4   tcp    111  portmapper
    100000    3   tcp    111  portmapper
    100000    2   tcp    111  portmapper
    100000    4   udp    111  portmapper
    100000    3   udp    111  portmapper
    100000    2   udp    111  portmapper
    100024    1   udp  44004  status
    100024    1   tcp  49625  status
    100005    1   udp  20048  mountd
    100005    1   tcp  20048  mountd
    100005    2   udp  20048  mountd
    100005    2   tcp  20048  mountd
    100005    3   udp  20048  mountd
    100005    3   tcp  20048  mountd
    100003    3   tcp   2049  nfs
    100003    4   tcp   2049  nfs
    100227    3   tcp   2049  nfs_acl
    100003    3   udp   2049  nfs
    100003    4   udp   2049  nfs
    100227    3   udp   2049  nfs_acl
    100021    1   udp  58956  nlockmgr
    100021    3   udp  58956  nlockmgr
    100021    4   udp  58956  nlockmgr
    100021    1   tcp  39716  nlockmgr
    100021    3   tcp  39716  nlockmgr
    100021    4   tcp  39716  nlockmgr

开启对应的防火墙端口

[root@test home]# firewall-cmd  --zone=public --add-port=111/tcp 
success
[root@test home]# firewall-cmd  --zone=public --add-port=2049/tcp 
success
[root@test home]# firewall-cmd  --zone=public --add-port=2049/udp
success
[root@test home]# firewall-cmd  --zone=public --add-port=111/udp 
success
[root@test home]# firewall-cmd  --zone=public --add-port=20048/udp 
success
[root@test home]# firewall-cmd  --zone=public --add-port=20048/tcp 
success
[root@test home]# firewall-cmd  --zone=public --add-port=35248/tcp 
success
[root@test home]# firewall-cmd  --zone=public --add-port=38535/udp
success

重启服务

systemctl restart rpcbind.service 
systemctl restart nfs-server.service
  • 客户端client
    client只需安装nfs模块无需启动nfs
yum install nfs-utils

启动rpc服务

 systemctl enable rpcbind.service
Created symlink from /etc/systemd/system/multi-user.target.wants/rpcbind.service to /usr/lib/systemd/system/rpcbind.service.
systemctl start rpcbind.service 

测试:

showmount -e 192.168.1.10
clnt_create: RPC: Port mapper failure - Unable to receive: errno 113 (No route to host)

出现此错误 一般是端口未成功开放,到nfs服务端开启端口

成功测试

[root@test home] ~]$ showmount -e 192.168.1.10
Export list for 192.168.1.10:
/home/share 192.168.1.0/24

你可能感兴趣的:(Linux,linux,nfs)