about NFS

2006. 12. 28. 06:43IT/OS

NFS에 대하여

CONTENTS:
1.NFS의 개념
2.NFS Environment
1) NFS Resources
2) NFS Server
3) NFS Client
4) Daemon
3.Sharing File Resources
1) Syntax
2) Command
4.Mounting File Resources
1) Syntax
5.Share and Mount examples
1) Solaris 2.x에서의 share and mount
2) Solaris 1.x에서의 mount
3) Booting시마다 NFS Resource를 자동으로 mount 하고자 할때
4) hard와soft option의 차이
6.NFS Troubleshooting
1) General Information on NFS Troubleshooting
2) NFS server에서의 check사항
3) Clearing Remote Mounting Problems

DESCRIPTION:

1.NFS의 개념

* NFS는 다른 system architecture와 다른 Operating System간의 네트웍을 통한
resources를 공유할 수 있는 서비스이다.( from MS-DOS to VMS)
* NFS는 remote system의 사용자에게 local files 또는 directory를 마치 local
machine의 사용자 처럼 쓸수 있도록 한다.

2.NFS Environment

1) NFS Resources
NFS resources는 Network을 통해서 공유할 수 있는 자원을 말하며 file system 또는 file system 내의 paration을 의미.

2) NFS Server

* NFS server는 자신의 file system또는 partition을 remote machine이 네트웍
을 통하여 공유 할 수 있도록 해 주는 시스템을 의미한다.
* NFS server는 네트웍상에 자신의 NFS resources를 share해 주어야 한다.
/etc/dfs/dfstab 화일내에는 nfs server의 share list를 등록할 수 있으며
이 화일내의 등록된 share list는 시스템 booting 시에 자동으로 네트웍상에
share된다.

3) NFS client

* NFS client는 네트웍을 통하여 remote system이 share해준 Network Resources
를 mount해서 사용하는 시스템을 의미한다.
* NFS client는 mount 명령어를 이용하여 share된 자원을 사용할 수 있으며
/etc/vfstab에 NFS를 통해 mount할 list를 기록함으로써 booting시 자동으로
NFS Resources를 mount 할 수 있다.

4) Daemons

* Server
- /usr/lib/nfs/nfsd : client의 file system request를 처리하여 NFS service가
가능하도록 해줌.
run level 3에서 S15nfs.server에 의해 수행됨.
- /usr/lib/nfs/mountd : mountd는 RPC service로서 client의 file system
mount request를 처리한다.
client로의 요청시 /etc/dfs/sharetab을 참조 해당
filesystem을 client가 mount할 수 있도록 해줌.

* Client
- /usr/lib/nfs/statd : locked daemon과 인터페이스하여 NFS에서의 locking servi -ce를 위한 crash 또는 recovery기능 제공.
- /usr/lib/nfs/lockd : kernel에서 발생된 lock 처리나 또는 remote의 다른 lock
daemon의 lock 처리 담당
lockd가 lock request를 RPC/XDR을 통하여 전달한 lockd
가 lock request를 RPC/XDR을 통하여 전달한 후에는
status monitor daemon에 request를 보내어 statd daemon
이 monitor service가 가능하도록 함.

3.Sharing File Resources

1) Syntax

share [-F nfs] {-o specific option] [-d description] pathname

-o speific option:

rw : 지정된 path내의 디렉토리를 read/write permission으로 share해줌.
ro : 지정된 path내의 디렉토리를 read-only permission으로 share해줌.
ro=client[:client] : 지정된 client들은 read-only permission으로 share
rw=client[:client] : 지정된 client들은 read/write permission으로 share
root=host[:host] : 지정된 host들은 uid 0 이며 root permission으로 해당
디렉토리를 사용할수 있다.
anon=uid : 다른 uid를 가지고 client들이 access 가능도록 해줌.
만약 client가 uid=0로 access시 root permission으로 해당되는
디렉토리를 사용할 수 있다.

2) Command

* share - Network상에 NFS server의 Resources를 share해주거나 또는 자신이
network상에 share한 resources를 display 해줌.
* unshare - share 해준 NFS Resources 에 대한 service 중단.
* shareall - /etc/dfs/dfstab에 등록된 모든 list를 network상에 share해줌.
* unshareall - /etc/dfs/dfstab의 모든 share list에 대한 서비스를 중단함.
* /etc/dfs/dfstab - system booting시에 자동적으로 NFS resources를 network
상에 share시에 등록해줌.

4.Mounting File Resources

1) Syntax

mount [-F nfs] [-r] [-m] [-o specific_options] mount point

-r : read-only permission으로 mount
-m : /etc/mntab table에 entry를 append 시키지 않고 mount
-o specific_options :

rw|ro : resource is mountd read-write or read-only
Default is rw
suid|nosuid : Setuid exexution allowed or disabled.
Default is suid
retry=n : The number of times to retry the mount
rsize=n : Set the read buffer size to n bytes.
The default value is 8192
wsize=n : Set the write buffer size to n bytes.
The default value is 8192
soft|hard : Return an error if the server does not respond,or
continue the retry request until the server responds.
The default value is hard
intr|nointr : Allow(do not allow)keyboard interrupts to kill a process
that is hung while waiting for a response on a hard-mounted
file system.The default is intr.
bg|fg : If the first attempt fails,retry in the background,or in the foreground.
The default is fg.

Background 와 Foreground의 차이
- background option은 client server의 NFS resources를 mount시 server의
mount daemon이 응답을 하지 않을 경우 background로 mount수행.
(retry=n option을 사용할 경우 지정한 번호대로 retry)
- mount시 soft option을 사용하면 mount 실패시 message를 return시킴.
- mount시 hard option을 사용하면 mount실패시 warning message를 printing후
계속적인 retry를 시도함.

2) Command

* mount : remote NFS server로부터 NFS resources를 local로 가져옴.
또는 현재 mount되어 있는 목록을 보여줌.
* umount : mount되어 있는 NFS resource를 제거시킴.
* showmount : NFS server로부터 어떤한 자원이 share되었는지 display해줌.
* dfshares : remote 또는 local system의 NFS resource를 display해줌.

5.Share and Mount 예제

0) Environment

------------------------------------
| nfs server : hostname : candy |
| ip : 203.240.159.39 |
| OS : SUNOS 5.4 |
| nfs client : hostname : hyundai3 |
| ip : 203.240.159.35 |
| OS : SUNOS 5.4 |
| nfs client : hostname : hyundai2 |
| ip : 203.240.159.34 |
-----------------------------------

1) Solaris 2.x에서의 share and mount

* share NFS resources from the NFS server

candy# mkdir /home/disk1 /home/disk2 /home/disk3 /home/disk4
candy# ls -alsd /home/disk*
2 drwxr-xr-x 2 root other 512 3월 19일 13:55 /home/disk1
2 drwxr-xr-x 2 root other 512 3월 19일 13:55 /home/disk2
2 drwxr-xr-x 2 root other 512 3월 19일 13:55 /home/disk3
2 drwxr-xr-x 2 root other 512 3월 19일 13:55 /home/disk4
candy# vi /etc/dfs/dfstab

# place share(1M) commands here for automatic execution
# on entering init state 3.
#
# share [-F fstype] [ -o options] [-d ""] [resource]
# .e.g,
# share -F nfs -o rw=engineering -d "home dirs" /export/home2
share -F nfs -o rw /home/disk1
share -F nfs -o root=hyundai3:hyundai2 /home/disk2
share -F nfs -o anon=0 /home/disk3
share -F nfs -o ro,rw=hyundai3 /home/disk4

candy# shareall
candy# /etc/init.d/nfs.server start
candy# cat /etc/dfs/dfstab

# place share(1M) commands here for automatic execution
# on entering init state 3.
#
# share [-F fstype] [ -o options] [-d ""] [resource]
# .e.g,
# share -F nfs -o rw=engineering -d "home dirs" /export/home2
share -F nfs -o rw /home/disk1
share -F nfs -o root=hyundai3:hyundai2 /home/disk2
share -F nfs -o anon=0 /home/disk3
share -F nfs -o ro,rw=hyundai3 /home/disk4

candy# dfshares
RESOURCE SERVER ACCESS TRANSPORT
candy:/home/disk1 candy - -
candy:/home/disk2 candy - -
candy:/home/disk3 candy - -
candy:/home/disk4 candy - -

* mount NFS Resource from the NFS server

hyundai3# mkdir /home/userA /home/userB /home/userC /home/userD
hyundai3# dfshares candy
RESOURCE SERVER ACCESS TRANSPORT
candy:/home/disk1 candy - -
candy:/home/disk2 candy - -
candy:/home/disk3 candy - -
candy:/home/disk4 candy - -
hyundai3# mount -F nfs candy:/home/disk1 /home/userA
hyundai3# mount -F nfs candy:/home/disk2 /home/userB
hyundai3# mount -F nfs candy:/home/disk3 /home/userC
hyundai3# mount -F nfs candy:/home/disk4 /home/userD
hyundai3# mount
/ on /dev/dsk/c0t3d0s0 read/write/setuid on 수 2월 14 07:52:38 1996
/usr on /dev/dsk/c0t3d0s6 read/write/setuid on 수 2월 14 07:52:38 1996
/proc on /proc read/write/setuid on 수 2월 14 07:52:38 1996
/dev/fd on fd read/write/setuid on 수 2월 14 07:52:38 1996
/tmp on swap read/write on 수 2월 14 07:53:09 1996
/home on /dev/dsk/c0t3d0s7 setuid/read/write on 수 2월 14 07:53:09 1996
/opt on /dev/dsk/c0t3d0s5 setuid/read/write on 수 2월 14 07:53:09 1996
/user on /dev/dsk/c0t1d0s6 setuid/read/write on 수 2월 14 07:53:09 1996
/pcfs on /dev/diskette setuid/read/write on 수 2월 14 07:55:00 1996
/home/userA on candy:/home/disk1 read/write/remote on 월 3월 18 15:00:10 1996
/home/userB on candy:/home/disk2 read/write/remote on 월 3월 18 15:00:31 1996
/home/userC on candy:/home/disk3 read/write/remote on 월 3월 18 15:00:55 1996
/home/userD on candy:/home/disk4 read/write/remote on 월 3월 18 15:01:44 1996

hyundai3# cd /home/userA
hyundai3# touch test_userA
touch: test_userA를 만들수 없음
---> rw option인데도 write가 되지 않음.이것은 server의 /home/disk1의
permission이 755이기 때문이다.
chmod 777 /home/disk1을 실행하면 rw됨.
hyundai3# !!
touch test_userA
hyundai3# ls -al
총 4
drwxrwxrwx 2 root other 512 1995년 3월 19일 .
drwxr-xr-x 25 root root 512 3월 18일 14:51 ..
-rw-r--r-- 1 nobody other 0 1995년 3월 19일 test_userA
hyundai3# cd /home/userC
hyundai3# touch test_userC
hyundai3# ls -al
총 4
drwxr-xr-x 2 root other 512 1995년 3월 19일 .
drwxr-xr-x 25 root root 512 3월 18일 14:51 ..
-rw-r--r-- 1 root other 0 1995년 3월 19일 test_userC

2) Solaris 1.x mount

NFS server가 share해준 NFS resources를 mount

hyundai2# showmount -e candy
export list for candy:
/home/disk1 (everyone)
/home/disk2 (everyone)
/home/disk3 (everyone)
/home/disk4 (everyone)

hyundai2# mkdir /home/disk4
hyundai2# mount -t nfs candy:/home/disk4 /home/disk4
------ -> Solaris 2.x(-F nfs)와 다른 부분
hyundai2# mount
/dev/sd0a on / type 4.2 (rw)
/dev/sd0g on /usr type 4.2 (rw)
/dev/sd0h on /home type 4.2 (rw)
/dev/sd4h on /DATA1 type 4.2 (rw)
/dev/sd5h on /DATA2 type 4.2 (rw)
/dev/sd6h on /DATA3 type 4.2 (rw)
/dev/sd7h on /PC type 4.2 (rw)
candy:/home/disk4 on /home/disk4 type nfs (rw)

hyundai2# cd /home/disk4
hyundai2# ls -al
total 2
drwxr-xr-x 2 root 512 Mar 19 1995 .
drwxr-xr-x 15 root 1024 Mar 18 15:35 ..
hyundai2# touch tets_disk4
touch: cannot create tets_disk4: Read-only file system
hyundai2# mount -t nfs candy:/home/disk3 /home/disk3
hyundai2# mount
/dev/sd0a on / type 4.2 (rw)
/dev/sd0g on /usr type 4.2 (rw)
/dev/sd0h on /home type 4.2 (rw)
/dev/sd4h on /DATA1 type 4.2 (rw)
/dev/sd5h on /DATA2 type 4.2 (rw)
/dev/sd6h on /DATA3 type 4.2 (rw)
/dev/sd7h on /PC type 4.2 (rw)
candy:/home/disk3 on /home/disk3 type nfs (rw)
candy:/home/disk4 on /home/disk4 type nfs (rw)
hyundai2# cd /home/disk3
hyundai2# touch test_disk3
hyundai2# ls -al
total 2
drwxr-xr-x 2 root 512 Mar 19 1995 .
drwxr-xr-x 16 root 1024 Mar 18 15:38 ..
-rw-r--r-- 1 root 0 Mar 19 1995 test_disk3

3) Booting시마다 NFS Resources를 자동적으로 mount 하고자 할때

hyundai3# vi /etc/vfstab
#device device mount FS fsck mount mount
#to mount to fsck point type pass at boot options
#
#/dev/dsk/c1d0s2 /dev/rdsk/c1d0s2 /usr ufs 1 yes -
/proc - /proc proc - no -
fd - /dev/fd fd - no -
swap - /tmp tmpfs - yes -

/dev/dsk/c0t3d0s0 /dev/rdsk/c0t3d0s0 / ufs 1 no
-
/dev/dsk/c0t3d0s6 /dev/rdsk/c0t3d0s6 /usr ufs 1 no
-
/dev/dsk/c0t3d0s7 /dev/rdsk/c0t3d0s7 /home ufs 2 yes
-
/dev/dsk/c0t3d0s5 /dev/rdsk/c0t3d0s5 /opt ufs 2 yes
-
/dev/dsk/c0t3d0s1 - - swap - no -
/dev/dsk/c0t1d0s6 /dev/rdsk/c0t1d0s6 /user ufs 2 yes
-
candy:/home/disk1 - /home/userA nfs - yes bg,soft,intr
:wq

hyundai3#

4) hard 와 soft option의 차이

* NFS server의 down시 (bg,soft,intr,option으로 mount 시도)
booting중에 다음과 같은 message가 나타남.

nfs mount: candy::RPC:Rpcbind failure -RPC: Timed out
nfs mount: backgrounding:/usr/nfs

booting이 끝난 후에 process상태를 보면
hyundai3# ps -ef | more
root 138 1 8 02:43:53 ? 0:00 mount -o bg,soft,intr candy:/home/disk1 /usr/nfs

위와 같은 processor가 background로 running중임을 알수 있음.
NFS server가 다시 booting된 후에는 background로 도는 process에 의해 정상인
경우적인 NFS mount 수행

* mount option을 fg,hard,intr option을 사용시
위의 경우는 rebooting도중 hangup상태로 계속 NFS server측으로 retrying시도.

NFS server가 정상적인 상태로 돌아오면 다음과 같은 메세지가 나타남.
NFS mount:candy:RPC: Rpcbind fauliure -RPC : Timed out
NFS mount:retrying:/home/nfs
nfs mount:/home/userA: mounted ok

위와 같이 mount를 끝낸후 booting procedure를 꼐속 진행함.

6. NFS Troubleshooting

NFS에서의 장애가 발생시 원인은 NFS server 또는 NFS client 그리고 NFS client
그리고 네트웍 자체의 문제의 하나로 볼수 있다.

NFS server system에는 mountd,nfsd daemon이 반드시 running 되어야 하고
/etc/dfs/dfstab에 entry가 있으면 booting시 자동적으로 nfsd,mountd를
running하게 되어 있다.
(/etc/rc3.d/S15nfs.server script에 의해 실행됨)

1) General Information on NFS Troubleshooting.

* NFS server not responding,still trying
hard mountd의 경우 NFS server의 fail시 display됨.
* NFS server ok
NFS server가 정상적으로 NFS resource를 share시 위와 같은 message가
나타남.
* intr option은 default mount option으로 server로 부터의 응답이 없을때
Ctrl-C key를 입력 interrupt을 수행할 수가 있다.

2) NFS server에서의 check사항

* 다음과 같이 candy system의 procedure를 check

candy# ps -ef | grep mountd
root 169 1 15 08:34:31 ? 0:00 /usr/lib/autofs/automountd
root 984 890 5 18:02:52 pts/4 0:00 grep mountd
root 756 1 40 14:00:56 ? 0:00 /usr/lib/nfs/mountd
candy# ps -ef | grep nfsd
root 986 890 5 18:03:29 pts/4 0:00 grep nfsd
root 754 1 8 14:00:56 ? 0:00 /usr/lib/nfs/nfsd -a 16

* nfsd의 option
-a : Start a NFS daemon over all available connectionless transports
8 : Number of daemon in server
Solaris 2.4에서는 default:16

* 다음과 같이 NFS server의 네트웍 상태를 점검한다.

client에서
# /usr/sbin/rpcinfo -u nfs
- 정상인 경우
hyundai3# rpcinfo -u candy nfs
program 100003 version 2 ready and waiting
- 비정상인 경우
rpcinfo: RPC : Program not registered
program 100005 is not available

client에서
# /usr/sbin/rpcinfo -u mountd
- 정상인 경우
hyundai3# rpcinfo -u candy nfs
program 100005 version 1 ready and waiting
program 100005 version 2 ready and waiting
- 비정상인 경우
rpcinfo: RPC : Program not registered
program 100005 is not available

3) Clearing Remote Mounting Probelms

* Example (1)
- NFS client에서 NFS server의 resource를 mount하고자 할때 다음과
같은 error가 발생되면,
mount:...., server not responding:RPC_PMAP_FAILURE - RPC TIMED OUT

- 조치
위의 경우는 nfs server의 sharing list down 또는 wrong run level,
또는 rpcbind가 dead or hang상태 일때 발생하며 다음과 같은 조치.

candy# who -r
. run-level 2 3월 19 08:34 3 0 S
run level checking:
run level 3에서 nfsd,mountd daemon이 running 됨.
만약 run level이 2 가 아니면 run level 3으로 전환하거나 시스템을
rebooting시켜서 rpcbind daemon을 restart시킴.

candy# init 3 ---> run level 3 으로 전환

* Examples (2)
- mount: ... server not responding: RPC_PROG_NOT_REGISTERED

-원인 /해결
mount 명령어가 server의 rpcbind까지는 실행이 되었으나 mountd daemon
이 running 되지 않는 경우

candy# /usr/sbin/rpcinfo -u mountd

* Example(3)
- mount: ... No such file or directory

-원인
remote directory 또는 local directory가 존재하지 않을 경우임.

* Example(4)
-mount: ..... : Permission denied

-원인
nfs server의 share list에 client가 등록되지 않는 경우

'IT > OS' 카테고리의 다른 글

TCP Wrapper  (0) 2006.12.28
[Linux] 일반계정 su 사용 제한  (3) 2006.12.28
Solaris CPU,MEM,NET 상태  (0) 2006.12.28
fuser, 강제로 umount...  (0) 2006.12.28
Linux Network  (0) 2006.12.28
[Linux] Linux IP체계  (0) 2006.12.28
[Solaris] Signals and Meanings  (0) 2006.12.28
[Solaris] Remote CD-Rom Mount  (0) 2006.12.28