免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1194 | 回复: 0
打印 上一主题 下一主题

NFS [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-08-14 10:50 |只看该作者 |倒序浏览


NFS=Network File System

What is NFS

A network file system developed by Sun Microsystem Since 1980, and is available almost for all kinds of UNIX systems now.

A distributed file system that provide transparent access to remote disks. User access remote disks as if they are local.

Allows centralized administration of disks usage.

Proveide File system consistency, because there is only one copy of each file on the network.

NFS for Linux Since kernel 1.0.

NFS是一個通用於各種UNIX平台間的檔案分享協定。
 

NFS Server & NFS Client

An NFS server is a host that owns one or more file systems and makes them available on the network for  other machines.

A NFS client mount filesystems from one or more servers.
 

提供NFS服務的三個程式(On the server)

rpc.portmapper

Convert Remote Procedure Call (RPC) program numbers into Internet Protocol port numbers. Needed also in NIS (YP) service. The name of this daemon depends on the UNIX vender! On linux it's“portmap”.portmap本身並不提供NFS服務,他的工作是將其他電腦的呼叫正確的對應到NFSNIS程式。

RPC Portmapper (portmap)是一個server程式,功能是將RPC program number轉換為TCP/IP Port Number。

所有透過RPC機構運作的Client/Server程式,都必須由RPC portmapper提供轉換的服務。(例如NFS、NIS)

標準的RPC Server通常由inetd負責,因此RPC portmapper通常必須先inetd啟動。

確定系統中RPC portmapper是否啟動的方法:
(1).
nmc:~#
ps aux|grep port
bin 62 0.0 0.2 976 376 ? S 12:40 0:00 /usr/sbin/rpc.portmap
root 3990 0.0 0.2 1052 368 p2 S 08:36 0:00 grep port
(2).
nmc:~#
rpcinfo -p
program vers proto port
100000 2 tcp 111 portmapper
100000 2 udp 111 portmapper
100005 1 udp 669 mountd
100005 2 udp 669 mountd
100005 1 tcp 672 mountd
100005 2 tcp 672 mountd
100003 2 udp 2049 nfs
100003 2 tcp 2049 nfs
100007 2 udp 721 ypbind
100007 2 tcp 723 ypbind


rpc.mountd
Answer file system mount requests. Read the /etc/exports file to determine which file system are available to which machines and which users. The name of this daemon depends on the UNIX vender! On linux it's "rpc.mountd"
rpc.mountd提供遠端電腦架設(mount)及卸載(umount)檔案系統的服務

rpc.nfsd
Handle file requests from clients. How many nfsd to be started depends on the load expected on that server. To start n nfsds just enter"nfsd n". Duplicated nfsds can serve multiple files request concurrently ! The name of this daemon depends on the UNIX vender! On linux the name is  "rpc.nfsd".
rpc.nfsd會將對NFS的要求轉換成為本地檔案系統的實際要求。
 

啟動NFS Server

/etc/rc.d/init.d/nfs startor just type /usr/sbin/mountd; /usr/sbin/nfsd 8
 


停止NFS Server

/etc/rc.d/init.d/nfs stop
 


Monitor NFS Server Status

/etc/rc.d/init.d/nfs status


NFS Server 組態設定(/etc/exports)

/etc/exports define the access control list (ACL) for file systems which are exported to NFS clients

NFS檔案分享(export)最小單位為"directory"

Format of /etc/exports
/directory/to/export    host1(permission)    host2(permission) ...
hostx 的格式可以是:

*
"*"代表所有主機皆可存取

主機名稱
主機名稱應定義在DNS、/etc/hosts或NIS中

IP Address[/netmask]
140.120.2.0/24  (相當於140.120.2.0/255.255.255.0)
140.120.2.0/16  (相當於140.120.2.0/255.255.0.0)
permission代表hostx對分享的目錄存取權限:

rw
有讀寫存取權

ro
唯讀

noaccess
拒絕存取,通常用在表示分享目錄下的例外。

no_root_squash
承認Client 端root的絕對權限。未指定此選項,Client端的root會以"nobody"的身分對NFS檔案存取。

/etc/exports一經修改必須讓rpc.mountd及rpc.nfs重讀該檔案。方法有二:一為重新啟動NFS By : /etc/rc.d/init.d/nfs restart ,另一個則是By指令"exportfs -a"
 

Example
   /home    nmc1(rw)    nmc2(ro)    nmc3(rw,no_root_squash)


mount NFS file system

指令格式:    mount -o 參數  server_name:/exported/dir    /local/dir/to_mount   
server_name
        NFS Server
/exported/dir
        
NFS Server /etc/exports中export的directory
/local/dir/to_mount
        這是local mount point,通常是一個已經存在的空目錄
參數

rw           讀寫

ro            read only

bg           background mount (mount process go to background in case of mount fail !)

soft         soft mount(default NFS mount is "hard mount",hard mount will keep on trying till mount completed,soft mount will return error code after number of unsuccessful trying specified in "retrans"

retrans     max retry of soft mount

wsize      write size(default is 8192 Bytes)

rsize        read size(default is 8192 Bytes)

Example
mount -o soft,bg    nmc:/home /home

NFS File System in /etc/fstab

Format:    server_name:/exported/dir    /local/dir/to_mount    nfs    NFS參數     fs_freq    fs_passno  

Example
        nmc:/home    /home    nfs    rw,bg,soft    0    0

NFS其他相關議題

慎選NFS參數

NFS Tunning

慎防NFS Cross Mount

Security in NFS


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/22239/showart_155152.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP