Autofs自动挂载服务

简介:

一.环境准备

Xuegod63.cn                 服务端

Xuegod64.cn                 客户端

二.搭建服务

服务端配置:

安装NFS 服务:

[root@xuegod63 ~]# yum -y install nfs-utils

创建共享区域:

[root@xuegod63 ~]# mkdir -p /opt/abc123

修改配置文件:

[root@xuegod63 ~]# vim /etc/exports

/opt/abc123  *(rw)                                   #共享区域   所有人读写的权限

[root@xuegod63 ~]# service nfs restart

关闭 NFS 守护进程:                                        [失败]

关闭 NFS mountd:                                          [失败]

关闭 NFS quotas:                                          [失败]

启动 NFS 服务:                                            [确定]

关掉 NFS 配额:                                            [确定]

启动 NFS mountd:                                          [确定]

启动 NFS 守护进程:                                        [确定]

正在启动 RPC idmapd:                                     [确定]

客户端配置:

autofs软件包要实现自动挂载涉及到两个文件,auto.master和auto.misc

安装autofs,默认已经安装

[root@xuegod64 ~]# yum -yinstall autofs

/etc/auto.master 文件定义本地挂载点.

/etc/auto.misc 配置文件是用来设置需要挂载的文件系统类型和选项

创建挂载点:

[root@xuegod64 ~]# mkdir /tmp/abc

修改配置文件

[root@xuegod64 ~]# vim /etc/auto.master

/tmp/abc        /etc/auto.nfs --timeout=60 #挂载点   超过设置超过60S断开

测试服务端是否可以挂载

[root@xuegod64 ~]#showmount  -e  172.16.30.39

Export list for 172.16.30.39:

/opt/abc123 *

修改配置文件

[root@xuegod64 nfs]# vim /etc/auto.nfs  #文件可以自定义这里我使用的是auto.nfs
nfs -fstype=nfs 172.16.30.39:/opt/abc123     #指定文件类型   目标地址:opt/abc123目标目录

[root@xuegod64 ~]# service autofs restart     #重启autofs服务

 

三.登录测试:

[root@xuegod64 tmp]# cd /tmp/abc/nfs   #必须要登录到nfs 这个文件夹才能进行自动挂载。

[root@xuegod64 nfs]# df -h

Filesystem                Size  Used Avail Use% Mounted on

/dev/vda2                  26G  4.0G  21G  17% /

tmpfs                     940M   72K 940M   1% /dev/shm

/dev/vda1                 194M   34M 151M  19% /boot

172.16.30.39:/opt/abc123   36G 6.8G   27G  21% /tmp/abc/nfs

四.  错误篇:

1.  如:[root@xuegod64 ~]# showmount -e 172.16.30.39

clnt_create: RPC: Port mapperfailure - Unable to receive: errno 113 (No route to host) NFS           #端口映射失败——不能接受:errno 113(没有通往主机)

解决方法: 服务端 防火墙没有关闭

[root@xuegod63 ~]# service iptables stop

iptables:将链设置为政策 ACCEPT:filter                    [确定]

iptables:清除防火墙规则:                                 [确定]

iptables:正在卸载模块:                                   [确定]

2.  [root@monitor ~]# showmount -e  172.16.30.39

-bash: showmount: command notfound               #客户端没有showmount 命令

解决方法:安装showmount命令

[root@monitor ~]# yum  -y install showmount

3.      如果没有自动生成没有有nfs目录,建议:重新卸载nfs autofs 重新安装,客户端配置完以后要重启autofs服务。



本文转自 Innocence_caosm 51CTO博客,原文链接:http://blog.51cto.com/innocence/1782600,如需转载请自行联系原作者
相关文章
|
2月前
|
存储 Linux
Linux Autofs自动挂载服务详解
Linux Autofs自动挂载服务详解
21 0
|
10月前
|
Linux
Linux系统之使用autofs自动挂载nfs共享
Linux系统之使用autofs自动挂载nfs共享
119 1
|
监控 测试技术 开发工具
|
网络协议 安全 Shell