一.NFS文件详解

1. /data/            表示需要共享的目录。

2. IP                表示允许哪个客户端访问。

3. IP                后括号里的设置表示对该共享文件的权限。

4. ro                只读访问

5. rw                读写访问

6. sync              所有数据在请求时写入共享

7. all_squash         共享文件的UID和GID映射匿名用户anonymous,适合公用目录。

8. no_all_squash      保留共享文件的UID和GID(默认)

9. root_squash        root用户的所有请求映射成如anonymous用户一样的权限(默认)

10. no_root_squash    root用户具有根目录的完全管理访问权限

二. NFS服务器搭建与autofs自动挂载

(1).安装NFS服务器

1 yum install nfs-utils -y   #安装nfs

2 systemctl start nfs        #开启nfs服务

3 systemctl enable nfs       #开机自启动

(2).配置NFS服务器

1 mkdir /westos

2 echo 'hello,world' > /westos/hello  # 建立目录 /westos, 在其中创建测试文件hello

(3).通过修改NFS配置,共享/data/share/目录

[root@nfsserver ~]# mkdir /data/share

[root@nfsserver ~]# vim /etc/exports 
shared data for bbs by oldboy at 20160825
#/data/share           192.168.100.0/24(rw,sync,hide)
/data/share           192.168.100.0/24(rw,sync,anonuid=555,anongid=555,all_squash)

(4).客户端安装NFS客户端及autofs并启动相关服务

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

[root@nfsclient ~]# yum install autofs -y

[root@nfsclient ~]# /etc/init.d/rpcbind start

[root@nfsclient ~]# /etc/init.d/autofs start

(5).服务器测试

1 showmount -e 192.168.1.152

2 Export list for 192.168.1.152:

3 /westos *

(6).配置客户端自动挂载(autofs)NFS服务端共享目录

[root@nfsclient ~]# vim /etc/auto.master 
     # Sample auto.master file

# This is a 'master' automounter map and it has the following format:

# mount-point [map-type[,format]:]map [options]

# For details of the format look at auto.master(5).

#/misc   /etc/auto.misc

/mnt    /etc/auto.misc  timeout=60#/mnt为挂载点   /etc/auto.misc为挂载动作

[root@nfsclient ~]# vim /etc/auto.misc

# This is an automounter map and it has the following format

# key [ -mount-options-separated-by-comma ] location

# Details may be found in the autofs(5) manpage

cd  -fstype=iso9660,ro,nosuid,nodev :/dev/cdrom
# the following entries are samples to pique your imagination

#linux  -ro,soft,intr ftp.example.org:/pub/linux

#boot  -fstype=ext2   :/dev/hda1

#floppy -fstype=auto   :/dev/fd0

#floppy  -fstype=ext2   :/dev/fd0

#e2floppy  -fstype=ext2  :/dev/fd0

#jaz -fstype=ext2  :/dev/sdc1

#removable -fstype=ext2  :/dev/hdd

nfsdata  -fstype=nfs  192.168.100.100:/data/share

(7).重新启动autofs服务,并检查自动挂载文件是否生效

[root@nfsclient ~]# /etc/init.d/autofs restart

[root@nfsclient ~]# cd /mnt/nfsdata

[root@nfsclient nfsdata]# ls - total 0
        -rw-r--r-- 1 oldgirl oldgirl 0 Aug 27 00:14 andy

-rw-r--r-- 1 oldgirl oldgirl 0 Aug 27 00:10 oldboy

-rw-rw-r-- 1 oldgirl oldgirl 0 Aug 27 00:10 oldgirl

[root@nfsclient nfsdata]# df –h

Filesystem  Size  Used Avail Use% Mounted on

Filesystem   /dev/mapper/vg_muban-moban_root  38G 1.9G 34G  6% /

tmpfs  491M    0 491M  0%/

dev/shm/dev/sda1       194M  29M 155M 16%/boot

192.168.100.100:/data/share  38G  1.9G   34G   6% /mnt/nfsdata

三.用以上方式完成NFS服务器搭建与autofs自动挂载

最新文章

  1. shortcuts on Windows and MacOS
  2. 【转】Private Libraries、Referenced Libraries、Dependency Libraries的区别
  3. [php]如何更改wamp默认的mysq空密码?
  4. C# 解析XML格式的字符串
  5. java RSA加密解密--转载
  6. 关于.ToList(): LINQ to Entities does not recognize the method ‘xxx’ method, and this method cannot be translated into a store expression.
  7. [转] 在React Native中使用ART
  8. Reverse Nodes in k-Group 解答
  9. Symfony命令大全
  10. MySQL之增删改查
  11. pta编程总结2
  12. git操作本地仓库基本使用教程
  13. 学习官方示例 - TForm.BorderIcons
  14. WEB开发常用软件集合
  15. Android进程和线程(Android开发指南--译)
  16. HDU 2561 第二小整数 (排序)
  17. id=%d是什么意思呢?
  18. Android Study 之 初识ButterKnife(8.5.1)及简单运用
  19. django中ModelForm解决多表单组合显示问题
  20. Eclipse+Tomcat实现热部署/热加载配置,修改java代码无需重启tomcat

热门文章

  1. java反射基础知识整理
  2. 饮料换购【第六届蓝桥杯省赛C++A/C组,第六届蓝桥杯省赛JAVAB组】
  3. [cocos2d-x]关于动画
  4. 通过Docker启动Solace,并在Spring Boot通过JMS整合Solace
  5. 亲测有效! TG Pro 实时温度工具 V2.7.6 for mac 破解版
  6. visual studio(vs2017、vs2019)离线安装包下载、制作
  7. 数字列表number,目标值target,找到number中两个不同数字之和等于target的数字,输出下标并顺序排列 ----笔试题记录扩展
  8. ElasticSearch7.6入门
  9. 【ACR2015】持续临床缓解的RA患者能停用TNF拮抗剂吗?
  10. 电子辅助的个体化严密控制策略比常规方法更有效地帮助早期RA实现全面控制病情[EULAR2015_THU0122]