2009. 1. 23. 10:54

NFS 서버 구축관리

■ NFS 서버 구축관리

■ NFS 패키지 준비
# rpm -qa portmap
portmap-4.0-65.2.2.1
# rpm -qa nfs-utils
nfs-utils-1.0.9-24.el5
만약 없다면
# yum install portmap nfs-utils

■ NFS 서버의 공유목록 관리
# vi /etc/exports
/share          192.168.10.30(rw,sync)  
#/share 폴더를 해당 아이피에만 read write할 수 있게 .

■ /etc/exports 파일 설정 형식
[형식]
공유디렉토리        접근 호스트(옵션)
[옵션]
rw : 읽기 쓰기
ro : 읽기만 가능
secure : 클라이언트 마운트 요청시 포트를 1024 이하
noaccess : 엑세스 거부
root_squach : 클라이언트의 root가 서버의 root권한을 획득하는 것을 막는다.
sync : 파일 시스템 변경시 즉시 동기화

■ NFS 사용
# /etc/init.d/portmap start
portmap (을)를 시작 중:                                    [  OK  ]
# /etc/init.d/nfs start
NFS 서비스를 시작 중:                                      [  OK  ]
NFS 쿼터를 시작 중:                                        [  OK  ]
NFS 데몬을 시작 중:                                        [  OK  ]
NFS mountd를 시작 중:                                      [  OK  ]

■ NFS 부팅시 자동시작
# chkconfig nfs on
# chkconfig --list | grep nfs
nfs             0:off   1:off   2:on    3:on    4:on    5:on    6:off

■ 공유목록 확인
# exportfs -v
/share          192.168.10.30(rw,wdelay,root_squash,no_subtree_check,anonuid=65534,anongid=65534)
[exportfs 사용법]
nfs 서버 다시 시작않고 공유목록 수정
-a : /etc/exports 파일 load
-r  : /etc/exports 파일 reload
-u IP:/디렉토리 : 입력한 디렉토리를 공유목록에서 제외
-v : 현재의 공유목록 확인

■ 클라이언트에서 확인
[nfs server]
# touch /share/hello.txt
[client]
# mkdir /mnt/nfs
# mount -t nfs 192.168.10.10:/share /mnt/nfs
# ls /mnt/nfs
hello.txt

■ 마운트 확인
# cat /etc/mtab
192.168.10.10:/share /mnt/nfs nfs rw,addr=192.168.10.10 0 0        < 정상 마운트 >
 
부팅시 자동마운트 하고 싶다면
#vi /etc/fstab에 추가 해주면 된다.