1 / 35

第十四章

第十四章. 网络文件系统. 第十四章 网络文件系统. 第十四章 网络文件系统 (2). 本章要点. 理解什么是网络文件系统 掌握 NFS 的守候进程以及它们的角色 掌握如何配置 NFS 服务器 掌握如何管理 NFS 客户端. 14.1.1 什么是 NFS. NFS : Network File System ,网络文件系统 NFS 用于 UNIX 系统时,类似 Windows 中网上邻居的功能,可实现网络共享。但比网上邻居配置更灵活配置,安全性更好 基于 RPC(Remote Procedure Call) 协议. 什么是 NFS(2).

meg
Download Presentation

第十四章

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 第十四章 网络文件系统

  2. 第十四章 网络文件系统

  3. 第十四章 网络文件系统(2) 本章要点 理解什么是网络文件系统 掌握NFS的守候进程以及它们的角色 掌握如何配置NFS服务器 掌握如何管理NFS客户端

  4. 14.1.1 什么是NFS NFS:Network File System ,网络文件系统 NFS用于UNIX系统时,类似Windows中网上邻居的功能,可实现网络共享。但比网上邻居配置更灵活配置,安全性更好 基于RPC(Remote Procedure Call)协议

  5. 什么是NFS(2) NFS协议是stateless的。服务端是没有跟踪记录客户端对目录操作的状态,服务端只是记录有哪些客户机在操作 要求客户端是主动和智能的,即由客户端提出对服务端的共享文件的mount方式,比如,服务端宕机,客户机如何处理等

  6. 14.1.2 NFS 的守候进程 NFS服务端需要的守候进程(daemon) : • portmap • nfsd • rpc.mountd • rpc.statd • rpc.lockd

  7. NFS 的守候进程(2) NFS客户端需要的守候进程(daemon) : • portmap • biod • rpc.statd • rpc.lockd 查看NFS守候进程状态命令: # lssrc –g nfs

  8. NFS 的守候进程(3) rpc.mountd 进程 运行在服务端客户端,响应客户端发送的mount请求,并查看是否有所需的共享目录 nfsd 进程 运行于服务端,和biod配合完成NFS的文件读写操作

  9. NFS 的守候进程(4) biod 进程 运行于客户端,和nfsd配合完成NFS的文件读写操作 rpc.lockd and rpc.statd 进程 客户端和服务端都要运行,用来监控和锁定NFS文件的操作

  10. NFS 的守候进程(5) portmap 进程 用来给基于RPC协议的服务分配一个通讯端口 基于RPC协议的服务必须先从portmap得到分配的的端口,之后才能对外正常服务 NFS服务是基于RPC通信,所以无论是客户端还是服务端,都要在启动RPC其他相关子进程之前,先启动pormap进程

  11. NFS 的守候进程(6)

  12. NFS 的守候进程(7)

  13. 14.2.1 配置NFS服务器 配置方式: 手动修改配置文件和手工启动服务 用smit工具配置和启动服务 只有root才能配置NFS

  14. 手工配置NFS服务器 手动修改配置文件/etc/exports 执行exportfs –a,使配置文件内容生效 用startsrc –g nfs 启动NFS相关子进程

  15. /etc/exports文件 此文件列出要共享的内容,示例: # cat /etc/exports /tmp/thomasc -access=server1:server2:server4 /tmp/thomasc/testfs /usr/man –ro 用命令# exportfs –a读取此文件,才能把内容共享出去,使其他机器的用户可以使用本机的文件

  16. /etc/exports文件(2) access 只允许server1、server2和server3访问/tmp/thomasc目录,其他机器不允许访问 ro /usr/man目录被设置为只读,若无任何参数,则默认为rw

  17. /etc/rmtab文件 当服务器的rpc.mountd进程接收到一个来自客户端的mount请求后,在/etc/rmtab文件中记录客户端主机名和mount的目录 当客户端把共享的目录umount后,/etc/rmtab中的记录会自动去除 可以通过命令 showmount -a 来查看此文件内容

  18. /etc/xtab文件 列出系统有哪些共享的内容 rpc.moutd接受到来自客户端的请求,先去查看/etc/xtab这个文件,看是否有用户所需要的

  19. 使用smit配置NFS服务器 # smit mknfsexp

  20. 使用smit配置NFS服务器(2) 在“PATHNAME of directory to export”选项设定要共享的目录 “MODE to export directory” 选项设定共享目录的访问权限 “EXPORT directory now,system restart or both” 选项设定是否现在启动NFS子进程等

  21. 14.2.2 管理NFS客户端 需要启动nfs客户端的守候进程 执行mount命令,共享服务端的目录 示例: # mount server3:/tmp/testnfs /mntpoint (把主机名为server3上的/tmp/testnfs 目录挂到本机的/mntpoint 目录下) 执行 umount命令,卸载NFS共享的目录

  22. Mount命令 # mount node mounted mounted over vfs date options -------- --------------- --------------- ------ ------------ --------------- /dev/hd4 / jfs Apr 26 20:42 rw,log=/dev/hd8 /dev/hd9var /var jfs Jun 14 14:11 rw,log=/dev/hd8 ……. /dev/hd10opt /opt jfs Apr 26 20:43 rw,log=/dev/hd8 p610 /usr/man /testfs nfs3 May 02 15:39 ---------- Node列就是远程NFS server的主机名

  23. 自动mount 配置远程文件系统为自动mount后,该远程文件系统不会马上mount,当有用户访问时,系统将自动mount该文件系统,此功能可以节省系统开支,并简化操作 自动mount分为两种: • indirect-automount • direct-automount 需要启动automound,#startsrc –s automountd

  24. indirect-automount 1、先在/tmp下创建一个indirect-automoun的map文件,该文件定义好mount点的相对路径,如下: # more /tmp/indirect.map testfs -rw server3:/tmp/testfs 2、因为已经定义了mount点的相对路径,执行下面命令后,会在/tmp/limhai目录下创建testfs目录,并把server3服务器的/tmp/testfs目录mount此目录: # automount -m /tmp/limhai /tmp/indirect.map

  25. direct-automount 1、先在/tmp下创建一个direct-automoun的map文件,该文件定义好mount点的绝对路径,如下: # more /tmp/direct.map /home/remote server3:/home 2、因为已经定义了mount点的绝对路径,所以执行automount命令就不需要具体指定mount点,这是和indirect map不一样的,如下所示, : # automount -m /- /tmp/direct.map

  26. 14.2.3 NFS 相关命令 rcpinfo 命令 nfso 命令 nfsstat showmount

  27. rpcinfo命令 查看RPC服务的状态信息 # rpcinfo -p server3 program vers proto port service ……….. 100003 2 udp 2049 nfs 100005 1 udp 40212 mountd …….. (查阅/etc/rpc文件,nfsd (100003和100005对应的RPC服务是nfsd和mountd,也就是说portmap注册了这两个服务)

  28. nfso 命令 查看系统有关NFS的内核参数 # nfso –a portcheck= 0 udpchecksum= 1 nfs_socketsize= 60000 nfs_tcp_socketsize= 60000 修改NFS的内核某个参数 # nfso -o nfs_tcp_socketsize=80000

  29. nfsstat命令 查看NFS通信状态,可用来监控NFS性能 # nfsstat –s ……….. Server rpc: Connection oriented: calls badcalls nullrecv 0 0 0 ………..

  30. showmount命令 查看某台机器共享出的目录有哪些 # showmount -e server3 export list for server3: /tmp/thomasc server1,server2,server4 /tmp/thomasc/testfs (everyone) 查看当前有那些机器共享本机目录 # showmount –a

  31. 14.2.4 测试题(1) 1、Administartor now wishes to mount the exported file systems from pluto onto mars. Which of the following commands will she use to view the export list of 'pluto'? • exportlist pluto • rpcinfo -p pluto • showmount -e mars • showmount -e pluto

  32. 测试题(2) 2、Which of the following actions should be performed by the system administrator to give Server B access to Server A's file system? • Run the chfs command on Server A • Run the chfs command on Server B • Run the exportfs command on Server A • Run the exportfs command on Server B

  33. 测试题(3) 3、When a RPC (remote procedural call) server starts up, it registers itself with which of the following daemons? • yp daemons • nfs daemons • inetd daemons • portmap daemon

  34. 测试题(4) 4、哪些不是NFS服务器必需的守候进程? • nfsd • biod • rpm.mountd • pormap

  35. 测试题(4) 答案 1、D 2、C 3、D 4、B

More Related