⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nfs介绍.htm

📁 很好的参考书
💻 HTM
📖 第 1 页 / 共 2 页
字号:
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>NFS介绍</title>
<meta name="GENERATOR" content="Microsoft FrontPage 3.0">
<meta name="Microsoft Border" content="none">
</head>

<body background="../images/waybkgnd.gif" text="#C0C0C0" link="#00FF00" vlink="#C0C0C0">
<font size="6">

<p><font color="#0080FF"><u><strong>NFS介绍</strong></u></font></font></p>

<pre>===========================================================================

</pre>

<pre>   ◎ What is NFS ?

</pre>

<pre>         Network        File        System    
</pre>

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

<pre>           machine  A                        machine  B
                /                               /

      bin     etc     usr               bin     etc      usr
                      man                          man     share     local


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

<pre>         mount  machine_name:/usr/man  /usr/home
</pre>

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


</pre>

<pre>   □ Servers &amp; Clients</pre>

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


</pre>

<pre>   □ Server's Exporting &amp; Client's Mounting</pre>

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

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

<pre>    /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
</pre>

<pre>   ★ Noted :</pre>

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


</pre>

<pre>   □ Setting Up a NFS Server</pre>

<pre>         1. 定义机器为 NFS file server</pre>

<pre>         2. 划分server's disk ,定义哪一些partitions 是要提供出来作为
            client 所共享的file system</pre>

<pre>         3. 在 Client Form 上定义每一台client 的参数</pre>

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

<pre>         5. 重新boot NFS server or 用指令 exportfs -a 输出所有的
            directories 并且用 nfsd 8 &amp; 启动 nfsd守护程式,常驻在背景
</pre>

<pre>    ※ ps. 一些细节</pre>

<pre>         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
</pre>

<pre>    exportfs的语法</pre>

<pre>      /usr/etc/exportfs   [ -avu ]   [ -o option ]  [ directory ]</pre>

<pre>          -a     : 把 /etc/exports 中所有路径export出去</pre>

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

<pre>          -o option :  如 exportfs -o ro /usr ,所有人对/usr 都为read only</pre>

<pre>                       option 还有 root = hostname , access = client</pre>

<pre>                                   access = netgroup
</pre>

<pre>    For example :</pre>

<pre>              exportfs -a  把exports中的路径全部export出去</pre>

<pre>              exportfs -o access=engineering:other  /usr</pre>

<pre>                /usr 这路径export後只有engineering and other 这两个
                group 能够 read &amp; write</pre>

<pre>              exportfs -o access=oak,ro=dancer  /usr</pre>

<pre>                设定dancer 这台client 对 /usr 为read only ,且只有
                oak这一个 group 能做read

</pre>

<pre>           /etc/exports  档的□例
</pre>

<pre>    ●  syntax : directory          -option[,option]</pre>

<pre>                                     (设定两个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</pre>

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

<pre>   □ Setting Up a NFS Client
</pre>

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

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

<pre>        3. 依照fstab所设的内容,在Client上设定好Mount points
           (mount_points 就是用mkdir 设exports所输出的路径)</pre>

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

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

</pre>

<pre>        /etc/fstab   档的□例</pre>

<pre>    ● syntax  filesystem  directory  type  options  freq  pass</pre>

<pre>        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


</pre>

<pre>    § mount 的语法
</pre>

<pre>   ● syntax : mount -t type [-rv] -o [option] server:pathname /mount_point</pre>

<pre>   MOUNT :
           mount -a     把/etc/fstab 中所列的路径全部挂上</pre>

<pre>           mount -o ro,soft,bg dancer:/usr/local /usr/local/dancer</pre>

<pre>                  把dancer server 的/usr/local mount 到 client的
                  /usr/local/dancer 并且是read only
</pre>

<pre>          -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 请求时,允许用键盘中断
</pre>

<pre>      mount 成功时的message</pre>

<pre>                  NFS server hostname ok</pre>

<pre>    &lt;hard&gt;   mount fail</pre>

<pre>                NFS server hostname not responding, still trying</pre>

<pre>    &lt;soft&gt;     . . .hostname server not reponding:  RPC: Timed out

</pre>

<pre>    § UNMOUNT :
</pre>

<pre>            umount mount_point</pre>

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

</pre>

<pre>==========================================================================

</pre>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -