nfs共享目录搭建(本地共享)

现在有三台服务器,需要搭建共享目录:

172.31.196.34  i-c5f6cd9e  Red Hat Enterprise Linux Server release 7.4 (Maipo)
172.31.3.72  i-33D24D56  Red Hat Enterprise Linux Server release 6.5 (Santiago)
172.31.3.73  i-B56C455B  Red Hat Enterprise Linux Server release 6.7 (Santiago)

计划吧34作为服务端,吧服务器上的磁盘共享给客户端72和73服务器使用。

步骤:

一、服务检查:rpm -qa nfs 和 rpm -qa rpcbind

[root@i-B56C455B ~]# rpm -qa|grep -E 'nfs|rpcbind'
nfs-utils-1.2.3-78.el6_10.1.x86_64
nfs-utils-lib-1.1.5-11.el6.x86_64
rpcbind-0.2.0-16.el6.x86_64
nfs4-acl-tools-0.3.3-7.el6.x86_64
[root@i-B56C455B ~]# 

二、配置

1、服务端配置

vim /etc/exports

a、增加:/data/lwj/sharedir 172.31.3.72(insecure,rw,no_root_squash,sync)

b、扫描配置文件(若配置文件作了更改,不需要重启rpcbind和nfs服务,重新扫描下配置即可)

[root@i-c5f6cd9e ~]# exportfs -rv
exporting 172.31.3.72:/data/lwj/sharedir
exporting 172.31.3.73:/data/lwj/sharedir
[root@i-c5f6cd9e ~]# 

c、重启nfs服务(默认服务是开启的,若要手动重启需要先启动rpcbind再启动nfs服务,这样才能确保nfs成功注册到rpcbind服务中)

[root@i-B56C455B ~]# service nfs restart

d、查看是否成功

[root@i-c5f6cd9e ~]# exportfs 
/data/lwj/sharedir
        172.31.3.72
/data/lwj/sharedir
        172.31.3.73
[root@i-c5f6cd9e ~]# 

2、客户端配置

a、直接挂载

mount 172.31.196.34:/data/lwj/sharedir/ /mnt/vie61jiexiang/share/

b、查看是否挂载成功

[root@i-33D24D56 ~]# df -h
Filesystem                         Size  Used Avail Use% Mounted on
/dev/vda1                           30G  9.3G   19G  34% /
tmpfs                               16G  3.1G   13G  20% /dev/shm
/dev/vdb                           197G  139G   49G  75% /home
172.31.196.34:/data/lwj/sharedir/  493G   78G  390G  17% /mnt/vie61jiexiang/share
[root@i-33D24D56 ~]#

c、进入验证

72服务器:

[root@i-33D24D56 ~]# cd /mnt/vie61jiexiang/share/
[root@i-33D24D56 share]# ll
总用量 16
drwxr-xr-x 4 root root 4096 4月  24 15:49 DMS
drwxr-xr-x 6 root root 4096 4月  16 09:47 TASK
drwxr-xr-x 3 root root 4096 4月  16 10:17 voice
drwxr-xr-x 2 root root 4096 4月  15 18:58 voice_temp
[root@i-33D24D56 share]#

73服务器:

[root@i-B56C455B ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/vda2              55G   47G  5.4G  90% /
tmpfs                  16G   72K   16G   1% /dev/shm
/dev/vdb              197G   77G  110G  42% /mnt
172.31.196.34:/data/lwj/sharedir/
                      493G   78G  390G  17% /mnt/vie61jiexiang/share
[root@i-B56C455B ~]#

在72新建文件:

[root@i-33D24D56 share]# touch a.txt

直接查看73共享目录,发现已经看得到共享文件了:

[root@i-B56C455B ~]# cd /mnt/vie61jiexiang/share
[root@i-B56C455B share]# ll
总用量 16
-rw-r--r-- 1 root root    0 4月  25 10:16 a.txt
drwxr-xr-x 4 root root 4096 4月  24 15:49 DMS
drwxr-xr-x 6 root root 4096 4月  16 09:47 TASK
drwxr-xr-x 3 root root 4096 4月  16 10:17 voice
drwxr-xr-x 2 root root 4096 4月  15 18:58 voice_temp
[root@i-B56C455B share]# 

完成。。。

 

问题:

1、若客户端无法正常展示挂载情况,或者df -h无法正常显示结果

  a、先使用mount命令直接查看挂载情况

  b、先检查客户端nfs服务是否正常

  c、查看服务端nfs服务是否正常、共享目录是否被误删等

  d、重新挂载

 

  

 

posted @ 2019-04-25 10:25  唐大侠的小迷弟  阅读(5613)  评论(0编辑  收藏  举报