본문 바로가기
컴퓨터 & IT (Computer & IT)/Linux

[Linux] NFS (Networking File System) 서버 설치

by Physics 2020. 11. 15.
728x90

1. NFS란?

SUN사가 개발한 RPC(Remote Procedure Call)기반 시스템으로, NFS 서버의 특정 디렉토리를 클라이언트에서 마운트(mount)하여 자신의 파일 시스템처럼 사용함 (Server/Client 기반 응용 프로그램) 
※ File System이 존재하지 않는 Client 시스템 (Diskless Client)에서 원격의 Host 시스템의 특정 디렉토리를 공유

※ NFS를 통해서, 여러 컴퓨터들의 관리 및 사용이 편리해지는 대신에 보안이 상대적으로 약화되기 때문에 주의해야 함

2. NFS를 사용하는 목적: 

Client node들이 Master node의 파일 시스템에 접근할 수 있도록 하기 위해서 

3. NFS 관련 데몬 

1) NFS는 rpc.mountdrpc.nfsd 두 데몬을 가지고 있다. /etc/rc.d/init.d/nfs를 실행시키면, 두 데몬이 실행된다.
2) NFS 관련 데몬

관련 데몬 설명
Netfs 삼바, NFS, NCP등을 마운트하거나 언마운트해주는 데몬으로 NFS 서버데몬을 띄우기 전에 미리 실행시켜야 함
Nfs NFS서비스를 해주는 데몬이다. 참고로 이 데몬을 실행시키려면 먼저 /etc/exports 파일을 설정해야 함
Portmap RPC연결에 관여하는 데몬으로 NFS, NIS을 사용할 때 필요함으로 실행시켜야 함
Nfslock 파일잠금을 제공하는데 이것은 동시에 여러 사람들이 동일한 파일을 수정하는 것을 막는다.

 

4. NFS설치 및 명령어

Master node에만 설치 Master & Client 노드에 설치
$sudo apt-get install nfs-kernel-server portmap $sudo apt-get install nfs-common portmap

1) portmap
 • RPC (Remote Procedure Call) 연결에 관여하는 데몬으로 NFS, NIS를 사용할 때 필요
 • RPC 프로그램을 port(tcp/udp)에 매핑을 시켜주는 데몬

2) NFS 클라이언트 설정 (/etc/exports 수정 후)

#mount	-t nfs -o nolock  <host name or IP address>:<shared directory> 	<mount point>
$mount	-t nfs -o nolock 192.168.0.32:/home/beloved/nfs			nfs

 

3) 기타 명령어
• NFS 서버 재시작: $sudo service nfs-kernel-server restart
 호스트의 포트맵 출력: rpcinfo -p
 NFS 포트맵 재시작: #sudo /etc/init.d/portmap restart

5. 순서

상황: 192.168.0.1서버의 /home/share/nfs 파일을 192.168.0.2 클라이언트 컴퓨터가 NFS를 통해 /mnt/nfs 마운트하여 사용을 할 경우

- 192.168.0.1 server --------------------------------------------------------------------
$mkdir /home/share/nfs			#NFS에 사용될 디렉토리 생성 및 권한 부여 - 1
$chmod -R 777 /home/share/nfs 		#NFS에 사용될 디렉토리 생성 및 권한 부여 – 2
$vim /etc/exports			#(서버) NFS 설정 파일 변경: /etc/exports 파일 수정
/home/share/nfs	192.168.0.2(rw,no_root_sqaush)
$exportfs -rv
$systemctl restart nfs-kernel-server	#NFS 서버 재시작 
$systemctl restart portmap		#Portmap 재시작
- 192.168.0.2 client -------------------------------------------------------------------- 
$mkdir /mnt/nfs                		#(클라이언트) 클라이언트가 마운트하여 사용할 디렉토리 생성 
$mount -t nfs -o nolock 192.168.0.1:/home/share/nfs	/mnt/nfs
         					#(클라이언트) NFS 서버와 마운트
이후, 클라이언트의 /mnt/nfs에 192.168.119.140의 /home/share/nfs/가 마운트되어 사용된다

 

이때, 클라이언트 노드에서 영구적으로 192.168.0.1의 /home/share/nfs를 마운트 시킬 경우, 클라이언트의 /etc/fstab을 편집한다.

- 192.168.0.2 client -------------------------------------------------------------------- 
$vim /etc/fstab  #(클라이언트) /etc/fstab 편집 
192.168.0.1:/home/share/nfs	/mnt/nfs		nfs	intr	0	0 

Reference
[1] http://www.fun25.co.kr/blog/linux-ubuntu-16-04-nfs-setting/?page=5
[2] https://mintnlatte.tistory.com/372
[3] https://darksoulstory.tistory.com/9
[4] https://blog.naver.com/songariq/80033573576

728x90

'컴퓨터 & IT (Computer & IT) > Linux' 카테고리의 다른 글

[Linux] sed 편집기  (0) 2021.03.29
Shell script 명령어  (0) 2021.02.05
[Linux] /etc/fstab  (0) 2020.11.15
[Linux] /etc/exports  (0) 2020.11.14
[Linux] Daemon 및 xinetd  (0) 2020.11.13

댓글