[RHCE] NFS 파일 공유
16장. NFS를 사용한 파일 공유
*서버
=====
- /etc/exports 파일에 파일 시스템을 정의함
- 2048/TCP를 사용함.
example)
/shared/current 192.168.0.0/24(rw,sync) /shared/archive 192.168.0.0/24(ro,sync) |
- restart없이 변경사항 적용
#exportfs -r
- 모든 공유디렉토리를 표시
#exportfs -v
(Note) 파일 소유권과 권한이 제대로 작동하려면 NFS를 사용하는 사용자와 그룹이 존재해야 하고, 각각의 사용자와 그룹이 클라이언트와 NFS서버에서 동일한 UID와 GID를 사용하도록 맵핑되어야 한다.
NFS 클라이언트의 루트의 사용자는 NFS 서버에서 nfnobody로 처리됨. 이 보호를 비활성화하려면 no_root_squash를 옵션으로 추가해야한다.
/exports/root 192.168.0.1(rw, no_root_squash) |
*클라이언트
===========
*일시적으로 마운트 하기
# mount- t nfs server1.example.com:/ /mnt
*영구적으로 마운트하기(/etc/fstab )
Structure)
nfsserver:/exports /mount-point nfs default(soft) 0 0 ==>soft : NFS 요청이 시간을 초과하면 3번 더 시도하고 오류메시지 발생 후 다음으로 넘어감. |
Example)
desktop1.example.com:/share/current /sales/current nfs rw 0 0 desktop1.example.com:/share/archieve /sales/archieve nfs ro 0 0 |
*마운트 가능한 nfs 포인트 확인
============================
#showmoutn -e desktop1.example.com ==> nfs3
Export list for desktop1.example.com:
/share/archives 192.168.0.0/24
/share/current 192.168.0.0/24
#mount desktop1.example.com:/ /mnt ===> nfs4
이 경우 /mnt 밑으로 바로 /share 가 마운트된다. 따라서 fstab에 원하는 파일시스템을 추가하고 마운트를 다시 해야한다.
#mount -at nfs