NFS相关.docx

上传人:b****8 文档编号:12396070 上传时间:2023-06-05 格式:DOCX 页数:9 大小:22.60KB
下载 相关 举报
NFS相关.docx_第1页
第1页 / 共9页
NFS相关.docx_第2页
第2页 / 共9页
NFS相关.docx_第3页
第3页 / 共9页
NFS相关.docx_第4页
第4页 / 共9页
NFS相关.docx_第5页
第5页 / 共9页
NFS相关.docx_第6页
第6页 / 共9页
NFS相关.docx_第7页
第7页 / 共9页
NFS相关.docx_第8页
第8页 / 共9页
NFS相关.docx_第9页
第9页 / 共9页
亲,该文档总共9页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

NFS相关.docx

《NFS相关.docx》由会员分享,可在线阅读,更多相关《NFS相关.docx(9页珍藏版)》请在冰点文库上搜索。

NFS相关.docx

NFS相关

NFS相关

作者:

风长风  发表于:

2004-03-2008:

35:

21

NFS 是由SUN公司发展, 并於1984年推出, NFS是一个RPC service ,它使我们能够达到档案的共享, 它的设计是为了在不同的系统间使用, 所以它的通讯协定设计与主机及作业系统无关.当使用者想用远端档案时只要用"mount"就可把remote档案系统挂接在自己的档案系统之下,使得远端的档案使用上和local机器的档案没两样.

           machine  A                        machine  B

                /                               /

      bin     etc     usr               bin     etc      usr

                      man                          man     share     local

     假如我们在机器A上, 要把机器B上的 /usr/man 挂接到machine A 的/usr/man只要下

         mount  machine_name:

/usr/man  /usr/home

     就可mount过来.而我们不只是可以mount目录,就是一个档也是可以的.在挂接之後我们只能对档案做reading (or writing) 的动作,而不能在remote machie上把此档或目录move,delete掉 , 但须注意的是如我们 mount /usr 後 , 不能再mount /usr底下的目录, 否则会发生错误

□ Servers & Clients

          NFS就是促使Servers上的档案能被其他的机器mount,而达到资源共享,享用这些档案的机器就可称为Client,一个client可以从server上mount一个档或是一个层次的目录(file hierarchies) . 然而事实上任何一台机器都可以做NFS server or NFS client ,甚至同时为NFS server and NFS client 也可以.

□ Server''s Exporting & Client''s Mounting

          NFS server 所export 出来的档案或目录都记录在 /etc/exports 这一个档中,当我们启动NFS server 时 在 /etc/rc.local 的这一个script会自动的启动 exportfs 这一个程式 , 搜寻 /etc/exports 这一个档是否存在, 并且赋予正确的权限给所有export出去的 file hierarchies .

          但须注意的是,只有server所export出去的路径,NFS client才能够mount , 同样的当启动client时 , 系统会自动去mount所有server export的路径,而mount到的所有路径都会记录在 /etc/fstab 下 , 类似如下的fstab档

    /dev/sd0a  /      4.2 rw 1 1

    /dev/sd0h  /tmp   4.2 rw 1 3

    /dev/sd0g  /usr   4.2 rw 1 2

    /dev/fd0   /pcfs  pcfs rw,noauto 0 0

    sparc20:

/swap /swap nfs rw,intr,bg,soft 0 0

    sparc17:

/home /home nfs rw,intr,bg,soft 0 0

    sparc17:

/home3 /home3 nfs rw,intr,bg,soft 0 0

    sparc14:

/home4 /home4 nfs rw,intr,bg,soft 0 0

    sparc20:

/home2 /home2 nfs rw,intr,bg,soft 0 0

    sparc20:

/var/spool/mail /var/spool/mail nfs rw,intr,bg,soft 0 0

    rs970:

/home1 /home1 nfs rw,intr,bg,soft 0 0

★ Noted :

         当client mount 到一个路径,绝对不是说copy server上的这一个路径到local的机器上,我们可以用 cd 进入这一个mount到的路径,就如同是使用local directory一样

□ Setting Up a NFS Server

         1. 定义机器为 NFS file server

         2. 划分server''s disk ,定义哪一些partitions 是要提供出来作为

            client 所共享的file system

         3. 在 Client Form 上定义每一台client 的参数

         4. 写出 /etc/exports  (一般系统都有一个default exports)

         5. 重新boot NFS server or 用指令 exportfs -a 输出所有的

            directories 并且用 nfsd 8 & 启动 nfsd守护程式,常驻在背景

    ※ ps. 一些细节

         1. 检查 /etc/exports 输出路径的权限,确定只有root能修改,

            all user只能read

         2. 用exportfs 去增加或删除directories

            exportfs -o access=engineering,ro=dancer /usr

            exportfs -u /usr

         3. 假如你的机器没有NIS(YP server)的服务,当更改资料时记得修改

               /etc/passwd

               /etc/group

               /etc/hosts

               /etc/ethers

         4. 为你自己的network 设置security

    exportfs的语法

      /usr/etc/exportfs   [ -avu ]   [ -o option ]  [ directory ]

          -a     :

 把 /etc/exports 中所有路径export出去

          -u     :

 把 export出去的路径卸下 , 如 exportfs -u /usr

          -o option :

  如 exportfs -o ro /usr ,所有人对/usr 都为read only

                       option 还有 root = hostname , access = client

                                   access = netgroup

    For example :

              exportfs -a  把exports中的路径全部export出去

              exportfs -o access=engineering:

other  /usr

                /usr 这路径export後只有engineering and other 这两个

                group 能够 read & write

              exportfs -o access=oak,ro=dancer  /usr

                设定dancer 这台client 对 /usr 为read only ,且只有

                oak这一个 group 能做read

           /etc/exports  档的□例

    ●  syntax :

 directory          -option[,option]

                                     (设定两个group能rw)

      /usr                     -access=engineering:

accounting

      /home                    -access=engineering:

accounting

      /var/spool/mail                -access=engineering:

accounting

      /export/exec/sun3              -access=engineering:

accounting

      /export/exec/sun3.sunos.4.1    -access=engineering:

accounting

      /export/exec/kvm/sun3.sunos.4.1  -access=engineering:

accounting

      /export/root/birch          -access=birch,root=birch

      /export/swap/birch          -access=birch,root=birch

      /export/root/oak          -access=oak,root=oak

      /export/swap/oak          -access=oak,root=oak

      /export/root/willow         -access=willow,root=willow

      /export/swap/willow         -access=willow,root=willow

      /export/root/pine           -accsee=pine,root=pine

      /export/swap/pine           -accsee=pine,root=pine

   (access=client , root=hostname 如此只有这一台client的superuser有权力rw)

□ Setting Up a NFS Client

        1. 宣告机器为没有磁碟机或没有资料的Client,在使用SunInstall之前

        2. 编辑好 /etc/fstab 这一个档,确定要mount的路径都在fstab中

        3. 依照fstab所设的内容,在Client上设定好Mount points

           (mount_points 就是用mkdir 设exports所输出的路径)

        4. 确定我们所要mount的路径,都有出现在 /etc/exports 中

        5. 可以启动mount去连结server上的directories   ( mount -a )

        /etc/fstab   档的□例

    ● syntax  filesystem  directory  type  options  freq  pass

        oak:

/export/root/boomer  /  nfs  rw  0  0

                                            ^^^

                                      因为档案在server上,not on client

                                      所以client的设定为0

        oak:

/export/exec/sun3           /usr  nfs  ro  0  0

        oak:

/export/exec/kvm/sun3       /usr/kvm nfs ro  0  0

        oak:

/usr/share                  /usr/share  nfs  ro  0  0

        oak:

/home/oak           /home/oak  nfs  rw,bg  0  0

    § mount 的语法

   ● syntax :

 mount -t type [-rv] -o [option] server:

pathname /mount_point

   MOUNT :

           mount -a     把/etc/fstab 中所列的路径全部挂上

           mount -o ro,soft,bg dancer:

/usr/local /usr/local/dancer

                  把dancer server 的/usr/local mount 到 client的

                  /usr/local/dancer 并且是read only

          -t type :

 你所要mount的型别, 如 nfs or 4.2

              -r  :

 所mount的路径定为read only

              -v  :

 mount过程的每一个动作,都有messages 传回到萤幕上

             hard :

 重复要求,直到server回应为止,但如server一直不回应

                   the server may be down !

             soft :

 当client的请求得不到回应,retry one time 後 传回

                   error message

             bg   :

 当第一次请求不成功,第二次的mount将放到背景执行

             fg   :

 retries mount 都一直在提示符号下进行

            intr  :

 当正在进行 NFS 请求时,允许用键盘中断

      mount 成功时的message

                  NFS server hostname ok

       mount fail

                NFS server hostname not responding, still trying

         . . .hostname server not reponding:

  RPC:

 Timed out

    § UNMOUNT :

            umount mount_point

            umount -a      卸下所有已经mount上的路径

==========================================================================

◎ How NFS Work ?

        当我们启动 NFS file server 时,/etc/rc.local 会自动启动exportfs这一个程式,指定可以export的档案或目录,而我们所能mount的也只能是其所指定的目录.

□  NFS 架设在 XDR/RPC的协定之上

     XDR :

 (eXternal Data Representation)  外部资料表示法

      XDR(eXternal Data Representation) 提供一种方法把资料从一种格式转换成另一种标准资料格式表示法,确保在不同的电脑,作业系统及电脑语言中,所有资料代表的意义都是相同的

     RPC :

 (Remote Procedure Calls) 远端程序呼叫

      RPC(Remote Procedure Calls) 远端程序呼叫, 请求远端电脑给予服务. 委托器(client)就会透过网路传送RPC到远端电脑,请求服务.

      (一般 local machine :

 client     remote machine :

 server )

□ NFS 如何运用 RPC 传送资料

                客户端process               主服务端process

                 ┌————┐               ┌—————┐

                 │ 客户端 │               │ 主服务站 │

                 │routines│               │ routines │

                 └—┬——┘               └┬————┘

     本地程序呼叫    │  《                   │      《

                 

(1) │  │ (10)          (6) │      │ (5)

                     》  │                   》      │

                 ┌———┴┐               ┌————┴┐

                 │ 客户端 │               │ 主服务端 │

                 │  stub  │               │   stub   │

                 └—┬——┘               └┬————┘

     系统呼叫        │  《                   │      《

                

(2)  │  │ (9)           (7) │      │ (4)

                     》  │                   》      │

                 ┌———┴┐       (8)     ┌————┴┐

                 │network │ <——————┤ network  │

                 │routines├——————> │ routines │

                 └————┘       (3)     └—————┘

               本地系统核心     网路通讯      远端系统核心

     

(1) client 送出讯息,请求服务

     

(2) client stub (客户株) 把client 送出的参数转换成XDR---标准资料

         格式并用系统呼叫(system call) 把讯息送到网路上

     (3) 讯息经过网路送达远端主机系统

     (4) 远端主机将接受到的讯息传给server stub (服务站株)

     (5) 把XDR形式的资料,转换成符合主机端的格式,取出client发出的服务

         请求参数,送给server

     (6) -- (10) 则是逆向而行 , server 送出服务给 client

□ rc.local 启动守护程式

      一个NFS server 要 inet , portmap , nfs , mount 此四个守护程式,保持在背景执行的状态下才能运作. (if running NIS must add ypbind daemon)

◆  当启动 NFS file server 时,

      the   /etc/rc.local script   会做如下的动作

          1. 执行exportfs , 读取server''s /etc/exports 告诉kernel

             所要输出的file hierarchies 和 存取的权限

              ( exportfs -a )

          2. 启动 rpc.mountd daemon 和 nfsd daemon (通常是 8 个)

               ( rpc.mountd  -n      nfsd 8 &   echo  -n ''nfsd'' )

◆  当启动 NFS client 时

       rc.local  会做如下的动作

          1. 启动 boid daemons 处理读写的程序

                (biod 8   echo -n '' biod'' )

          2. 执行 mount -vat nfs 读取client''s /etc/fstab 并且 mount 所

             有属於 NFS-type 的files

□ NFS daemons (守护程式) 的功用

    nfsd, biod, rpc.mountd, inetd, portmap  都可在/usr/etc 下找到

    nfsd :

   依client 对档案系统的需求情况, 而启动

                  " file system request daemon "

             应付client 的需求,而一般file system request daemon 的数目

             是 " 8 ", 这也就是我们在rc.local 中写 " nfsd 8 & "的原因了

    biod :

   此指令是在NFS client上用的 , 用来启动

                 " asynchronous block I/O daemon"

             用来建立buffer cache , 处理在client上的读写

    mountd :

 mountd 是一台 RPC server ,启动rpc.mountd daemon後 它会读取

            /etc/xtab 查看哪一台client正在moun

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > IT计算机 > 电脑基础知识

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2