ºìÁªLinuxÃÅ»§
Linux°ïÖú

NFS-UNIX ÖеÄÍøÂçÎļþϵͳ

·¢²¼Ê±¼ä:2006-03-03 00:20:27À´Ô´:ºìÁª×÷Õß:linux110.com
NFS£¨Network File System£©ÊÇÓÉSun´´½¨µÄÍøÂçЭÒ飬Ö÷Òª¹©²»Í¬µÄUNIXÖ÷»úÖ®¼ä¹²ÏíÎļþϵͳ£¬ÓÉÓÚ´æÔÚһЩ°²È«Òþ»¼£¬SunºóÀ´ÓÖ·¢Õ¹³öÁËNIS£¬NIS+£¬ÕâЩЭÒéµÄʹÓÃÔÚUNIXµÄÊÀ½çÀïÃæÊ®·ÖÆձ飬Sun»¹¿ª·¢ÁËPC-NFS£¬¹©Óû§´ÓPCÉÏÔËÐÐNFSЭÒ飬¹²ÏíUNIXµÄ×ÊÔ´¡£¶ÔÓÚLinuxÀ´Ëµ£¬ÓÉÓÚÓÐSambaµÄ´æÔÚ£¬ËùÒÔ´ó¶àÊýÈ˲»ºÜÊìϤNFS£¬ÆäʵÔÚ¶ą̀LinuxÖ÷»úÖ®¼ä¹²ÏíÎļþϵͳ£¬NFSÈÔÈ»²»Ê§ÎªÒ»ÖÖ¼òµ¥Ò×ÓõÄÑ¡Ôñ¡£ÏÂÃæÎÒÃǾÍÒԽ϶̵Äƪ·ù£¬¼òµ¥µØ½éÉÜÒ»ÏÂNFSÒÔ¼°ÈçºÎʵÏÖ¡£
Òª°Ñ×Ô¼ºµÄÎļþϵͳ¹²Ïí³öÈ¥£¬Ê×Ïȱ£Ö¤×Ô¼ºµÄ»úÆ÷ÉÏÆô¶¯ÁËNFS·þÎñ£¬¿ÉÒÔÓãº
# ps -ef| grep nsfd
²é¿´Ò»ÏÂnfsdÊÇ·ñÒѾ­ÔËÐУ¬Èç¹ûûÓУ¬ÇëÆô¶¯Ëü£¬Æô¶¯ºÍÍ£Ö¹NFSÈçÏÂ:
# /etc/rc.d/init.d/nfs start
# /etc/rc.d/init.d/nfs start
Ò²¿ÉÒÔµ÷ÓÃntsysvÃüÁ½«nfs·þÎñÉèÖÃΪ×Ô¶¯ÔËÐС£
È»ºó£¬½«ÄãÒª¹²Ïí³öÈ¥µÄÎļþϵͳ£¬ÐèÒªÓÃexportfsÃüÁÄãÒ²¿ÉÒÔͨ¹ýÉèÖÃ/etc/exportsÎļþ£¬ÔÚϵͳÆô¶¯µÄʱºò£¬×Ô¶¯½«×ÊÔ´¹²Ïí³öÈ¥¡£¾ßÌåÓ÷¨Çë²é¿´exportfsµÄÊÖ²áÒ³¡£
ÒªÅäÖÃNFS£¬¾ÍÊÇÒªÐÞ¸Ä/etc/fstab£¨¿Í»§¶Ë£©ºÍ/etc/exports£¨·þÎñÆ÷¶Ë£©£¬exportsÎļþÔÚ·þÎñÆ÷¶ËÖ¸¶¨ÒªÓëÄÄЩ¿Í»§¹²ÏíÄÄЩĿ¼ÒÔ¼°Ã¿¸ö¿Í»§µÄ·ÃÎÊȨÏÞ£»fstabÎļþÔÚ¿Í»§¶ËÓÃÀ´Ö¸¶¨Ó¦¸ÃÁª½ÓÄÄЩĿ¼ÒÔ¼°°ÑËüÃÇ·ÅÔÚ±¾µØĿ¼µÄÄÄÒ»¸öλÖá£
1£® ·þÎñÆ÷¶ËÅäÖÃ/etc/exportsÎļþ
ÎļþµÄ¸ñʽÈçÏ£º
----------------------------------------------------------------------------------------------------------------
#Òª¹²ÏíµÄĿ¼ Ö÷»úÃû1£¨È¨ÏÞ£© Ö÷»úÃû2£¨È¨ÏÞ£© Ö÷»úÃû3£¨È¨ÏÞ£©¡£¡£¡£¡£¡£¡£
/dir/exports host1(rw) host2(rw)
----------------------------------------------------------------------------------------------------------------
Èç¹ûÒ»ÐÐÌ«³¤£¬Ó÷ûºÅ¡°¡±Á¬½Óµ½ÏÂÒ»ÐС£¹ØÓÚȨÏÞ£¬¿É¹©Ñ¡ÔñµÄÊÇ£º
rw ¿ÉÒÔ¶ÁºÍд
ro Ö»¶Á
no_root_squash ³ÐÈϲ¢ÐÅÈοͻ§¼ÇµÃrootÕ˺Å
µ±ÉèÖÃÍê/etc/exportsÎļþºó£¬ÔËÐÐÏÂÃæµÄÃüÁîÈù²ÏíÉúЧ£º
# exportfs -a
2£® Òª¹²Ïí×ÊÔ´µÄÖ÷»úÔËÐÐmount
ÎÒÃÇ¿ÉÒÔ¼òµ¥µØʹÓÃmountÃüÁî°²×°NFS·þÎñÆ÷µÄÎļþϵͳ£¬ÔÚmountÔ¶³ÌÎļþϵͳʱ£¬ºÍmount±¾µØµÄÎļþϵͳʱһÑùµÄ£¬Î¨Ò»µÄ²»Í¬ÊÇÒªÔÚÎļþϵͳµÄÃèÊöÇ°Ãæ¼ÓÉÏÔ¶³ÌÎļþϵͳµÄÖ÷»úÃû³Æ£¬Èç¹û¸ÃÖ÷»úÔÚ/etc/hostsÖгöÏÖÁË£¬ÄÇôÔÚÃüÁîÖÐʹÓÃÖ÷»úÃû×־ͿÉÒÔ£¬·ñÔòҪʹÓÃIPµØÖ·¡£Óï·¨Ò»°ãÊÇ£º
# mount servername:/exported_dir /dir_to_mount -t nfs
ÀýÈ磬Ö÷»újwÔËÐÐÁËNFS£¬½«×Ô¼ºµÄ/exportĿ¼¹²ÏíÁË£¬ÄÇô¿Í»§»úlidfÓ¦¸ÃÕâÑù£º # mount jw:/export /home/inport -t nfs
¿Í»§»úÔÚmount·þÎñÆ÷µÄ×ÊԴʱ£¬¿ÉÒÔ´«µÝһЩÃüÁîÑ¡ÏÈ磺
# mount jw:/export /home/inport -o ro -t nfs
±íʾ°ÑjwÖ÷»úµÄ/exportĿ¼¹ÒÔÚ±¾µØµÄ/home/inportĿ¼Ï£¬Ö»¶Á¡£ÆäËûÑ¡ÏîÈçÏ£º
rw ¿ÉÒÔ¶Áд
bg ºǫ́°²×°£¨±ÜÃâÒòΪ°²×°²»ÉÏ·þÎñÆ÷×ÊÔ´¶øµ¼ÖÂϵͳͣ¶Ù£©
intr ³öÏÖÎÊÌâÊÇ£¬¿ÉÒÔÖжÏ
soft ÔÊÐí¾­¹ýretrans´Î³¢ÊÔºó£¬Í£Ö¹°²×°£¬·µ»Øʧ°ÜÐÅÏ¢
retrans ΪsoftÖ¸¶¨³¢ÊÔ´ÎÊý
µ±ÒªÐ¶ÔØ·þÎñÆ÷µÄÎļþϵͳʱ£¬ºÍ±¾µØÒ»Ñù£¬Ê¹ÓÃumountÃüÁî¡£
# umount /home/inport
¸ü¾ßÌåµÄ²ÎÊýʹÓÃÇë²é¿´mountµÄÊÖ²áÒ³ºÍNFS-HOWTO¡£
3£®ÀûÓÃ/etc/fstabÎļþ£¬ÔÚÆô¶¯Ê±×Ô¶¯¹ÒÔØÔ¶³ÌÖ÷»úµÄÎļþϵͳ
/etc/fstabÎļþ°üº¬ÁËÒÔÄÄÖÖ·½Ê½¹ÒÔØÄÄÖÖÎļþϵͳµÄÐÅÏ¢¡£¶ÔÓÚNFSµÄmount£¬Ëü°üÀ¨ÁË·þÎñÆ÷Ãû×Ö¡¢ÊÍ·Å£¨export£©µÄ·þÎñÆ÷Ŀ¼¡¢±¾µØµÄ¹ÒÔص㣨mount point£©ºÍ¿ØÖƹÒÔصÄһЩѡÏî¡£
ÏÂÃæÊÇÒ»¸ö/etc/fstabÎļþµÄÀý×Ó£º
#device mount_point filesystem_type option fsck
/dev/hda5 / ext2 defaults 1 1
/dev/hda6 /usr ext2 defaults 1 2
/dev/hda9 /usr/local ext2 defaults 1 2
/dev/hda8 swap swap defaults 0 0
/dev/fd0 /mnt/floppy ext2 noauto 0 0
/dev/cdrom /mnt/cdrom iso9660 noauto,ro 0 0
none /proc proc defaults 0 0
none /dev/pts devpts mode=0622 0 0
jw:/usr/local/pub /pub nfs rsize=8192,wsize=8192,timeo=14,intr
ÎļþϵͳÁ˸÷ÖÖÎļþϵͳµÄÐÅÏ¢£¬Ã¿Ò»¸öÎļþϵͳµ¥¶ÀÒ»ÐУ¬Ã¿ÐеÄÓòµÄÐÅÏ¢ÒÔ¿Õ¸ñ»òÕßtab·Ö¿ª¡£ÔÚfstabÎļþÖУ¬ÐеÄÇ°ºó˳ÐòÊǺÜÖØÒªµÄ£¬ÒòΪÕâ¿ÉÄܶÔfsck¡¢mountºÍumountµÈÃüÁîÓÐÓ°Ïì¡£
¹ØÓÚÕâ6¸öÓòµÄ½âÊÍ£¬Çë²é¿´½éÉÜfstabµÄ²¿·Ö¡£
ÎÒÃÇ×¢Òâµ½£¬°´ÕÕ×îºóÒ»ÐУ¬ÏµÍ³ÔÚÆô¶¯µÄʱºò»á³¢ÊÔ¹ÒÔØÖ÷»újwµÄ/usr/local/pubµ½±¾µØµÄ/pub£¬ÎļþϵͳÀàÐÍÊÇnfs£¬×îºóÁ½¸ö¹©fsckʹÓõIJÎÊý²»Ì±íʾ²»½øÐмì²é¡£
×¢ÒâNFS·þÎñÆ÷ºÍ¿Í»§»úÊÇÏà¶ÔµÄ£¬Ò»¸öÌṩ¹²Ïí×ÊÔ´µÄNFS·þÎñÆ÷£¬Ò²¿ÉÒÔ¹²ÏíÆäËûNFS·þÎñÆ÷µÄ×ÊÔ´¡£
ÒªÔÚϵͳÆô¶¯µÄʱºò¾ÍmountÆäËûNFS·þÎñÆ÷µÄ×ÊÔ´£¬ÎÒÃÇ¿ÉÒÔÐÞ¸Ä/etc/fstabÎļþ£º
4£® ÅäÖÃÎļþʾÀý
Ò»¸öÍêÕûµÄ/etc/exportsÎļþ
----------------------------------------------------------------------------------------------------------------------
ÒýÓÃ:
#
# /etc/exports for jw
#
# Share the following directory
/export/home lidf(rw) syy(rw) caibb(rw) zhougj(ro) eagle(ro)
#
# Share local software
#
/export/usr/local lidf(rw,no_root_squash)
syy(rw,no_root_squash)
caibb(rw,no_root_squash)
zhougj(ro)
eagle(ro)

----------------------------------------------------------------------------------------------------------------------
Ò»¸öÍêÕûµÄ/etc/fstabÎļþ
----------------------------------------------------------------------------------------------------------------------
ÒýÓÃ:
#
# /etc/fstab for lidf
#
/dev/hda1 / ext2 rw 1 1
/dev/hda2 swap swap
/dev/hda3 /usr ext2 rw 0 0
/dev/hda4 /var ext2 rw 0 0
jw£º/export/home /home nfs rw£¬bg£¬intr£¬soft 0 0
jw£º/export/usr/local /usr/local nfs rw£¬bg£¬intr£¬soft 0 0

-------------------------------------------------------------
ÎÄÕÂÆÀÂÛ

¹²ÓÐ 0 ÌõÆÀÂÛ