1. 서버 설정
1.1. NFS 서버를 위한 패키지 프로그램 설치
apt-get install nfs-common nfs-kernel-server rpcbind portmap
1.2. 공유할 폴더 생성
mkdir /mnt/data chmod -R 777 /mnt/data
1.3. NFS 설정 수정
설정 파일은 /etc/exports
파일이다.
아래는 NFS를 걸 폴더는 /mnt/data이고, 172.31.0.0/16에 대해 다 열겠다는 뜻이다.
/mnt/data 172.31.0.0/16(rw,sync,no_subtree_check)
- rw: read and write operations
- sync: write any change to the disc before applying it
- no_subtree_check: prevent subtree checking
1.4. 반영
exportfs -a systemctl restart nfs-kernel-server
2. 클라이언트
2.1. NFS 클라이언트를 위한 패키지 프로그램 설치
apt-get install nfs-common
2.2. NFS 마운트할 폴더 생성
mkdir /public_data
2.3. 마운트
NFS 서버 IP가 172.31.2.2라고 하면,
mount 172.31.2.2:/mnt/data /public_data