不是root,但你可以挂载!
2016-09-28 19:28
225 查看
这里主要介绍 NFS 客户端映射网络 NFS 目录的方法,这种自动挂并不通过 /etc/fstab
进行。
一 环境信息
NFS Server 192.168.1.36 RHEL6.2 ( 主机名:redhatB )
NFS Client 192.168.1.35 RHEL6.2 ( 主机名:redhat6 )
二 NFS 服务端搭建
之前的 BLOG 里详细介绍了了 NFS 服务搭建,为了实验需要,这里简单介绍下步骤。--2.1 修改 /etc/exports,添加以下
--2.2 创建共享目录并创建文件
--2.3 开启 nfs 服务
--2.4 设置 NFS 开机自启动
三 NFS 客户端配置
--3.1 开启 autofs 服务
--3.2 设置 autofs 开机自启动
备注:autofs 服务可以按需挂载 NFS 文件系统,不活动时间间隔为 5 分钟,这个配置在
文件 /etc/sysconfig/autofs 中的参数 TIMEOUT 参数设置。
--3.3 查看 NFS 服务端共享的目录列表
备注:上面只是准备工作,真正的映射步骤如下。
四 方法一: 使用 /net 目录访问 NFS 文件系统 当 NFS Client 端开启 autofs 服务时,有个特殊映射目录 /net,平常这个目录为空,
当访问 /nfs/nfsserver.domain 时,会自动创建目录并 mount,并显示 NFS 服务共享
目录的文件,如下所示:--4.1 进入 /net 目录
备注:开始进入 /net 目录显示为空,当进入相应 NFS 服务器目录时,自动 mount NFS 文件系统。
五 方法二:自定义目录访问 NFS 文件系统 除了使用 /net 目录映射 NFS 文件系统,还可以自定义目录映射 NFS 文件系统,这些配置需要在
配置文件 /etc/auto.master 进行配置。
--5.1 修改 /etc/auto.master 配置文件 ( NFS 客户端上操作) 修改配置文件,增加红色字体内容
备注:配置两项,第一项为挂载的目录,第二项为挂载的配置文件,即 NFS 映射匹配表。 --5.2 复制配置文件 /etc/auto.misc
--5.3 修改配置文件 /etc/auto.francs 增加以下内容
备注:在配置文件 /etc/auto.francs 中定义明细的 nfs 文件系统挂载点。 --5.4 创建新的挂载目录
--5.5 重启 autofs
--5.6 测试
备注:在新的目录 /francs 下可以访问 nfs 文件系统了。
进行。
一 环境信息
NFS Server 192.168.1.36 RHEL6.2 ( 主机名:redhatB )
NFS Client 192.168.1.35 RHEL6.2 ( 主机名:redhat6 )
二 NFS 服务端搭建
之前的 BLOG 里详细介绍了了 NFS 服务搭建,为了实验需要,这里简单介绍下步骤。--2.1 修改 /etc/exports,添加以下
/nfs 192.168.0.0/16(ro,sync) |
mkdir -p /nfs [root@redhatB ~]# cd /nfs [root@redhatB nfs]# touch a.txt [root@redhatB nfs]# ll total 4 -rw-r--r--. 1 root root 5 Aug 4 21:00 a.txt |
[root@redhatB nfs]# service nfs restart Shutting down NFS mountd: [ OK ] Shutting down NFS daemon: [ OK ] Shutting down NFS quotas: [ OK ] Shutting down NFS services: [ OK ] Starting NFS services: [ OK ] Starting NFS quotas: [ OK ] Starting NFS daemon: [ OK ] Starting NFS mountd: [ OK ] |
[root@redhatB nfs]# chkconfig nfs on |
--3.1 开启 autofs 服务
[root@redhatB nfs]# service autofs restart Stopping automount: [ OK ] Starting automount: [ OK ] |
[root@redhatB nfs]# chkconfig autofs on |
文件 /etc/sysconfig/autofs 中的参数 TIMEOUT 参数设置。
--3.3 查看 NFS 服务端共享的目录列表
[root@redhat6 nfs]# showmount -e 192.168.1.36 Export list for 192.168.1.36: /nfs 192.168.0.0/16 |
四 方法一: 使用 /net 目录访问 NFS 文件系统 当 NFS Client 端开启 autofs 服务时,有个特殊映射目录 /net,平常这个目录为空,
当访问 /nfs/nfsserver.domain 时,会自动创建目录并 mount,并显示 NFS 服务共享
目录的文件,如下所示:--4.1 进入 /net 目录
[root@redhat6 net]# cd /net [root@redhat6 net]# ls[root@redhat6 net]# cd 192.168.1.36 [root@redhat6 192.168.1.36]# ll total 0 drwxr-xr-x. 2 root root 0 Aug 4 20:43 nfs[root@redhat6 192.168.1.36]# cd nfs [root@redhat6 nfs]# ll total 4 -rw-r--r--. 1 root root 5 Aug 4 21:00 a.txt |
五 方法二:自定义目录访问 NFS 文件系统 除了使用 /net 目录映射 NFS 文件系统,还可以自定义目录映射 NFS 文件系统,这些配置需要在
配置文件 /etc/auto.master 进行配置。
--5.1 修改 /etc/auto.master 配置文件 ( NFS 客户端上操作) 修改配置文件,增加红色字体内容
# Sample auto.master file # This is an automounter map and it has the following format # key [ -mount-options-separated-by-comma ] location # For details of the format look at autofs(5). # /misc /etc/auto.misc /francs /etc/auto.francs |
[root@redhat6 nfs]# cp /etc/auto.misc /etc/auto.francs |
test_nfs -ro,soft,intr 192.168.1.36:/nfs |
[root@redhat6 nfs]# mkdir -p /francs |
[root@redhat6 francs]# service autofs stop Stopping automount: [ OK ] [root@redhat6 francs]# cd /net [root@redhat6 net]# ls [root@redhat6 net]# cd / [root@redhat6 /]# service autofs start Starting automount: [ OK ] |
[root@redhat6 /]# cd /francs [root@redhat6 francs]# ls [root@redhat6 francs]# cd test_nfs [root@redhat6 test_nfs]# ls a.txt |
相关文章推荐
- Android判断SD卡是否已经挂载的方法
- typecho插件编写教程(四):插件挂载
- Linux系统下如何挂载FAT32的U盘
- Linux挂载img镜像文件
- centos 5.6 挂载ntfs
- 独立服务器使用IPMI安装系统图文教程
- 新建磁盘 分区 格式化 挂载
- linux 制作大容量文档解决容量过大的问题
- 问题:# mount –t ntfs /dev/sdb1 /mnt/ 解决办法
- 新硬盘挂载目录后文件消失解决办法
- 格式化和挂载数据盘
- linux的mount(挂载)命令详解
- Centos 下轻松挂载NTFS 分区。
- CentOS 挂载 exfat 和 FAT32格式的U盘
- CentOS系统下的数据盘挂载
- Centos挂载硬盘
- VMware Tools安装
- 六、挂载命令
- 阿里云CentOS服务器挂载数据盘
- CentOS 挂载NTFS磁盘