麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 學院 > 操作系統(tǒng) > 正文

NFS簡介

2024-07-26 00:29:56
字體:
供稿:網(wǎng)友
大家好 :
        下面是小弟寫的一些介紹 NFS 的文章, 由於想?yún)⑴c網(wǎng)路管理的工作學長指派這一個主題給我報告, 由於本身對這方面并不太懂, 只是找一些書籍隨便拼拼湊湊, 不知道有沒有寫到重點,或是一些要點沒有提到,因此post出來希望熟悉NFS 的高手們能花一點時間看看我的文章  然後mail給我,指出錯誤的地方,或者直接reply也可以, 謝謝 !
        E-mail : [email protected]
===========================================================================
    ◎ What is NFS ?


         Network        File        System    

          NFS 是由SUN公司發(fā)展, 并於1984年推出, NFS是一個RPC service ,
     它使我們能夠達到檔案的共享, 它的設(shè)計是為了在不同的系統(tǒng)間使用, 所
     以它的通訊協(xié)定設(shè)計與主機及作業(yè)系統(tǒng)無關(guān).當使用者想用遠端檔案時只
     要用"mount"就可把remote檔案系統(tǒng)掛接在自己的檔案系統(tǒng)之下,使得遠端
     的檔案使用上和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底下的目錄, 否則會發(fā)生錯誤



   □ 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 這一個檔是否
      存在, 并且賦予正確的權(quán)限給所有export出去的 file hierarchies .
          但須注意的是,只有server所export出去的路徑,NFS client才能夠mount
     , 同樣的當啟動client時 , 系統(tǒng)會自動去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 的參數(shù)
         4. 寫出 /etc/exports  (一般系統(tǒng)都有一個default exports)
         5. 重新boot NFS server or 用指令 exportfs -a 輸出所有的
            directories 并且用 nfsd 8 & 啟動 nfsd守護程式,常駐在背景

    ※ ps. 一些細節(jié)
         1. 檢查 /etc/exports 輸出路徑的權(quán)限,確定只有root能修改,
            all user只能read
         2. 用exportfs 去增加或刪除directories
            exportfs -o access=engineering,ro=dancer /usr
            exportfs -u /usr
         3. 假如你的機器沒有NIS(YP server)的服務(wù),當更改資料時記得修改
               /etc/passwd
               /etc/group
               /etc/hosts
               /etc/ethers
         4. 為你自己的network 設(shè)置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
                設(shè)定dancer 這臺client 對 /usr 為read only ,且只有
                oak這一個 group 能做read


           /etc/exports  檔的□例

    ●  syntax : directory          -option[,option]
                                     (設(shè)定兩個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有權(quán)力rw)

   □ Setting Up a NFS Client

        1. 宣告機器為沒有磁碟機或沒有資料的Client,在使用SunInstall之前
        2. 編輯好 /etc/fstab 這一個檔,確定要mount的路徑都在fstab中
        3. 依照fstab所設(shè)的內(nèi)容,在Client上設(shè)定好Mount points
           (mount_points 就是用mkdir 設(shè)exports所輸出的路徑)
        4. 確定我們所要mount的路徑,都有出現(xiàn)在 /etc/exports 中
        5. 可以啟動mount去連結(jié)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的設(shè)定為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   : 當?shù)谝淮握埱蟛怀晒?第二次的mount將放到背景執(zhí)行
             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      卸下所有已經(jīng)mount上的路徑


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


   ◎ How NFS Work ?

        當我們啟動 NFS file server 時,/etc/rc.local 會自動啟動exportfs這
    一個程式,指定可以export的檔案或目錄,而我們所能mount的也只能是其所指定
    的目錄.


   □  NFS 架設(shè)在 XDR/RPC的協(xié)定之上

     XDR : (eXternal Data RePResentation)  外部資料表示法
      XDR(eXternal Data Representation) 提供一種方法把資料從一種格式轉(zhuǎn)換
      成另一種標準資料格式表示法,確保在不同的電腦,作業(yè)系統(tǒng)及電腦語言中,所
      有資料代表的意義都是相同的

     RPC : (Remote Procedure Calls) 遠端程序呼叫
      RPC(Remote Procedure Calls) 遠端程序呼叫, 請求遠端電腦給予服務(wù). 委
      托器(client)就會透過網(wǎng)路傳送RPC到遠端電腦,請求服務(wù).
      (一般 local machine : client     remote machine : server )



   □ NFS 如何運用 RPC 傳送資料


                客戶端process               主服務(wù)端process
                 ┌————┐               ┌—————┐
                 │ 客戶端 │               │ 主服務(wù)站 │
                 │routines│               │ routines │
                 └—┬——┘               └┬————┘
     本地程序呼叫    │  《                   │      《
                 (1) │  │ (10)          (6) │      │ (5)
                     》  │                   》      │
                 ┌———┴┐               ┌————┴┐
                 │ 客戶端 │               │ 主服務(wù)端 │
                 │  stub  │               │   stub   │
                 └—┬——┘               └┬————┘
     系統(tǒng)呼叫        │  《                   │      《
                (2)  │  │ (9)           (7) │      │ (4)
                     》  │                   》      │
                 ┌———┴┐       (8)     ┌————┴┐
                 │network │ <——————┤ network  │
                 │routines├——————> │ routines │
                 └————┘       (3)     └—————┘
               本地系統(tǒng)核心     網(wǎng)路通訊      遠端系統(tǒng)核心

     (1) client 送出訊息,請求服務(wù)
     (2) client stub (客戶株) 把client 送出的參數(shù)轉(zhuǎn)換成XDR---標準資料
         格式并用系統(tǒng)呼叫(system call) 把訊息送到網(wǎng)路上
     (3) 訊息經(jīng)過網(wǎng)路送達遠端主機系統(tǒng)
     (4) 遠端主機將接受到的訊息傳給server stub (服務(wù)站株)
     (5) 把XDR形式的資料,轉(zhuǎn)換成符合主機端的格式,取出client發(fā)出的服務(wù)
         請求參數(shù),送給server
     (6) -- (10) 則是逆向而行 , server 送出服務(wù)給 client



   □ rc.local 啟動守護程式

      一個NFS server 要 inet , portmap , nfs , mount 此四個守護程式,保
   持在背景執(zhí)行的狀態(tài)下才能運作. (if running NIS must add ypbind daemon)

   ◆  當啟動 NFS file server 時,

      the   /etc/rc.local script   會做如下的動作
          1. 執(zhí)行exportfs , 讀取server's /etc/exports 告訴kernel
             所要輸出的file hierarchies 和 存取的權(quán)限
              ( 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. 執(zhí)行 mount -vat nfs 讀取client's /etc/fstab 并且 mount 所
             有屬於 NFS-type 的files


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

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

    nfsd :   依client 對檔案系統(tǒng)的需求情況, 而啟動
                  " file system request daemon "
             應付client 的需求,而一般file system request daemon 的數(shù)目
             是 " 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正在mount 哪一個file system,并回
            應client 所要mount 的路徑
            (mountd處理的過程可用 showmount 來看)

    inetd : inetd (Internet services daemon) , 當系統(tǒng)啟動時rc.local
            會啟動inetd 讀取 inetd.conf 這一個 configuration-file ,
            讀取網(wǎng)路上所有 server's address , 連結(jié)啟動inetd.conf中所
            有的server , 當client 請求服務(wù)時, inetd 就會為clinet 啟動
            相關(guān)的server daemon 負責任務(wù), 如user 用 telnet 時 , 則
            inetd 啟動telnetd 迎合user telnet 的需求, 其馀像 ftp ,
            finger , rlogin 之類的應用程式 , inetd 也都會啟動相對應的
            daemons, ftpd, fingerd, rloingd
    portmap :  portmap 是一臺server , 主要功能 轉(zhuǎn)換 TCP/IP 通訊協(xié)定的
               port number 變成 RPC program number , 因為這樣clinet才能
               做RPC calls

               一般 RPC server 是被inetd 所啟動的, 所以portmap 必須
               在inetd之前啟動, 否則無法做 RPC call



   □ NFS 的網(wǎng)路安全的

          NFS 使server上的檔案能被client所取用, 乍看之下好像server 上
      的檔案任何人都可取用沒什麼保護性, 其實不是如此的. 一開始server
      要 exportfs 之前在 /etc/exporrc 中就已經(jīng)設(shè)定了檔案的使用權(quán)限, 像
          /usr/src -access=engineering:accounting
      就是限定只有 rcgineering 和 accounting 這兩臺 client 才能 mount
      /usr/src
          /usr/src  -access=oak,root=oak
      這是說只有 oak 這臺 cilent 能 mount這一個路徑 且只有 oak client's
      superuser 才能行使 read & write 的權(quán)力

         另外管理者為了維護 exported 和 mounted 的安全, 一定要建
     立公共(public)和私人(secret)的 key(passWord), 然而這些安全性
     問題是要建立在 NIS (network infomation system) 上的, 有一個
     /etc/publickey檔 ,里面記錄了public and secret keys , 而這些key
     是依照 machine_name 和 user_name ,以16 進位碼表示出來的, 管理
     者可在有NIS的機器上用
         newkey -u username     給予user login 權(quán)力
         newkey -h hostname     造出login 此機器時所需的password

         在NFS剛安裝時  user 是 "nobody" 任何人都可以進入, 所以管理者
     一定要做修改, 以保護資料的安全.

     當使用者為 nobody 時 publickey 的內(nèi)容
         netname   user's public key    : user's secret key
          nobody  3d91f44568fbbefada5a7:7675cd9b8753b5db09dabf12

        在管理者給予user權(quán)力之後, user 就可使用 chkey 修改自己的
     secret key 創(chuàng)造自己的帳號路口,

        willow% chkey
        Generating new key for username
        password  : 
        Sending key change request to server ...
        Done.
        willow%

         所設(shè)定的password 是使用者位於 NIS 中的加密鍵 , 當我們login 時
     NIS 就會將此密碼解開,(因為publickey中是以16進位碼記錄) , 存放到
     keyserv 里加以保管, 再將加密鍵傳給client , 當client 發(fā)出請求時 ,
     此鍵會附在每個NFS 請求上一起送到 NFS server 上, 當加密鍵和server上
     所保存的keyserv核對無錯後, 請求就會被接受





    □ When fail to  mount server

         1. 用 rpcinfo -p server_name 去查看此server是否存在
         2. 用 rpcinfo -u server_name mount 查看mountd daemon 是否有
            在server上執(zhí)行
         3. 假如server 都沒問題,檢查 server 和 client 之間的
            Ethernet connetions
         4. 在client 上 用 ps ax 看portmap and several biod daemons
            running or not !
            (rpcinfo : 用來對 RPC server 做 RPC 呼叫,回傳遠端程序呼叫
                       過程中的訊息)

       一些mount 失敗的錯誤訊息

       1.  /etc/mtab :  No such file or directory
               mtab 這一個路徑或是檔案必須存在,在mount之前
       2.  mount : ... Block device required
               遠端的機器名稱可能打錯了
       3.  mount: ... not found in /etc/fstab
               fstab 一定要存在,client 上 /etc下
       4.  ... not in hosts database
               /etc/hosts 沒有這一個 hosts database , 或是
               NIS 的daemon, ypbind 沒有在執(zhí)行
       5.  Must be root to use mount
                一般都只有 root 才能mount ,所以mount之前先成
                為superuser
       6.  Stale NFS file handle
                當我們已經(jīng)mount 上的file or directory  ,在server
                上突然被remove or unexport ,就會出現(xiàn)此訊息
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: av在线电影网站 | 91成人亚洲 | lutube成人福利在线观看污 | 免费久久久 | 在线免费日本 | 羞羞视频免费观看入口 | 精品国产一区二区三区四区在线 | 素人视频在线观看免费 | 国产精品自在线拍 | a黄在线观看 | 青青草成人免费视频在线 | 色污视频| 黄网站免费入口 | www.com香蕉 | 在线播放一区二区三区 | 成人小视频免费在线观看 | 国产成人精品区一区二区不卡 | 色中色激情影院 | 伊人在线 | 久久成人综合视频 | 香蕉视频h | 精品国产91久久久久久浪潮蜜月 | 久国久产久精永久网页 | 久久亚洲国产精品 | 黄视频网站免费在线观看 | 久久精品成人影院 | 爱高潮www亚洲精品 国产精品一区自拍 | 99在线免费观看视频 | 香蕉秀| 久久91久久 | 久草视频福利在线观看 | 久久国产精品网 | 99riav视频一区二区 | www.17c亚洲蜜桃| 日韩中文字幕一区二区三区 | 久久色在线 | 中国美女一级黄色大片 | 黄色片免费在线 | 91福利社在线 | 国产亚洲精品久久久久久大师 | 国产精品视频成人 |