๋กœ์ผ“๐Ÿพ
article thumbnail

EFS์™€ NFS๋Š” ๋™์ผํ•˜๋‹ค๊ณ  ๋ด๋„ ๋ฌด๋ฐฉํ•˜๋‹ค

NFS๋ž€ ๋ฌด์—‡์ธ๊ฐ€์š”?

 

๊ณต์œ ๋œ ์›๊ฒฉ ํ˜ธ์ŠคํŠธ์˜ ํŒŒ์ผ์„ ๋กœ์ปฌ์—์„œ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋„๋ก ๊ฐœ๋ฐœ๋œ ํŒŒ์ผ ์‹œ์Šคํ…œ์„ ๋„คํŠธ์›Œํฌ ํŒŒ์ผ ์‹œ์Šคํ…œ(Network File System, NFS)์ด๋ผ๊ณ  ํ•ฉ๋‹ˆ๋‹ค. ์ „ํ†ต์ ์ธ ์œ ๋‹‰์Šค ํ™˜๊ฒฝ์—์„œ๋Š” ์˜ค๋žซ๋™์•ˆ ๋„คํŠธ์›Œํฌ์—์„œ ์ž๋ฃŒ๋ฅผ ๊ณต์œ ํ•˜๋Š” ๋ฐฉ๋ฒ•์œผ๋กœ NFS๋ฅผ ์‚ฌ์šฉํ–ˆ์Šต๋‹ˆ๋‹ค. NFS ์„œ๋ฒ„๊ฐ€ ํŒŒ์ผ์„ ๊ณต์œ ํ•˜๋ฉด NFS ํด๋ผ์ด์–ธํŠธ๊ฐ€ ๊ณต์œ ํ•œ ๋””๋ ‰ํ„ฐ๋ฆฌ๋ฅผ ๋งˆ์šดํŠธํ•ด์„œ ์›๊ฒฉ ํ˜ธ์ŠคํŠธ(NFS ์„œ๋ฒ„)์˜ ํŒŒ์ผ์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.

https://thebook.io/006718/part02/ch07/02/01/

NFS๋Š” ์†์‰ฝ๊ฒŒ ํŒŒ์ผ์„ ๊ณต์œ ํ•  ์ˆ˜ ์žˆ๋‹ค๋Š” ์žฅ์ ์ด ์žˆ์ง€๋งŒ ๋ณด์•ˆ์— ์ทจ์•ฝํ•˜๋‹ค๋Š” ๋‹จ์ ์ด ์žˆ์Šต๋‹ˆ๋‹ค. NFS๋กœ ๊ณต์œ ํ•œ ํŒŒ์ผ์—๋Š” ์ผ๋ฐ˜์ ์ธ ์†Œ์œ ๊ถŒ๊ณผ ์ ‘๊ทผ ๊ถŒํ•œ์ด ๊ทธ๋Œ€๋กœ ์ ์šฉ๋ฉ๋‹ˆ๋‹ค. ์›๊ฒฉ ์‹œ์Šคํ…œ์—์„œ ์–ด๋–ค ์‚ฌ์šฉ์ž๊ฐ€ ํŒŒ์ผ ์†Œ์œ ์ž์™€ ๊ฐ™์€ UID๋กœ ๊ณต์œ  ๋””๋ ‰ํ„ฐ๋ฆฌ์— ์ ‘๊ทผํ•ด์„œ ํŒŒ์ผ์„ ๋งˆ์Œ๋Œ€๋กœ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋ฃจํŠธ ๊ถŒํ•œ์ด ๋ถ€์—ฌ๋œ ์‚ฌ์šฉ์ž๊ฐ€ ๊ณต์œ  ๋””๋ ‰ํ„ฐ๋ฆฌ์— ์ ‘๊ทผํ•œ๋‹ค๋ฉด ๋”์šฑ ์œ„ํ—˜ํ•ฉ๋‹ˆ๋‹ค. NFS๋กœ ํŒŒ์ผ์„ ๊ณต์œ ํ•  ๋•Œ๋Š” ๋ณด์•ˆ์— ํŠน๋ณ„ํžˆ ์‹ ๊ฒฝ ์จ์•ผ ํ•ฉ๋‹ˆ๋‹ค.

 


NFS ๊ตฌ์ถ•ํ•˜๊ธฐ

 

NFS๋กœ ์‚ฌ์šฉํ•œ ๊ฐ€์ƒ ๋จธ์‹ (192.168.0.165)๊ณผ NFS๋ฅผ ๋งˆ์šดํŠธํ•  ๊ฐ€์ƒ ๋จธ์‹ (192.168.0.170), ์ด 2๋Œ€๋ฅผ ์ค€๋น„ํ•ฉ๋‹ˆ๋‹ค

๊ฐ€์ƒ ๋จธ์‹ ์˜ OS๋Š” ubuntu20์ž…๋‹ˆ๋‹ค.

 

NFS VM(192.168.0.165)

 

์šฐ์„  NFS์— ํ•„์š”ํ•œ ํŒจํ‚ค์ง€๋ฅผ ์„ค์น˜ํ•ด์ค๋‹ˆ๋‹ค. 

$ apt install nfs-common nfs-kernel-server portmap

 

NFS๋กœ ์‚ฌ์šฉํ•  ๋””๋ ‰ํ„ฐ๋ฆฌ๋ฅผ ์ƒ์„ฑํ•œ ํ›„ ๊ถŒํ•œ์„ 777๋กœ ์ค๋‹ˆ๋‹ค. 

$ mkdir /home/nfs
$ chmod 777 /home/nfs/

 

๊ณต์œ ํ•˜๋ ค๋Š” ๋””๋ ‰ํ† ๋ฆฌ์™€ ์„œ๋ฒ„ ์„ค์ •์„ ํ•ด์ค๋‹ˆ๋‹ค.

$ vim /etc/exports

 

vim ์—๋””ํ„ฐ๋กœ exports ์„ ์—ฐ ๋’ค ์•„๋ž˜์™€ ๊ฐ™์ด ๋””๋ ‰ํ„ฐ๋ฆฌ์™€ ์„œ๋ฒ„ ์„ค์ •์„ ํ•ด์ค๋‹ˆ๋‹ค. 192.168.0.170์— ๊ฐ€์ƒ๋จธ์‹ ์—์„œ NFS๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๊ฒŒ ์ž‘์„ฑํ•ด์ค๋‹ˆ๋‹ค.โ€‹

# /etc/exports: the access control list for filesystems which may be exported
#               to NFS clients.  See exports(5).
#
# Example for NFSv2 and NFSv3:
# /srv/homes       hostname1(rw,sync,no_subtree_check) hostname2(ro,sync,no_subtree_check)
#
# Example for NFSv4:
# /srv/nfs4        gss/krb5i(rw,sync,fsid=0,crossmnt,no_subtree_check)
# /srv/nfs4/homes  gss/krb5i(rw,sync,no_subtree_check)
#
/home/nfs       192.168.0.165(rw,sync,no_subtree_check) 192.168.0.170(ro,sync,no_subtree_check)
#<์›ํ•˜๋Š” ๋””๋ ‰ํ† ๋ฆฌ>   <๊ณต์œ  ๋Œ€์ƒ ์žฅ์น˜(์•„์ดํ”ผ)>(์˜ต์…˜1,์˜ต์…˜2)
#์˜ต์…˜1์—๋Š” ro(read-only), rw(read-write)๋“ฑ์ด ์žˆ์Œ

 

์ž‘์„ฑ ํ›„ nfs-server๋ฅผ ์žฌ์‹œ์ž‘ํ•ด์ค๋‹ˆ๋‹ค.

$ service nfs-server restart

 

์‹คํ–‰์ด ์ž˜๋˜์—ˆ๋Š”์ง€ ํ™•์ธํ•ด์ค๋‹ˆ๋‹ค.

$ showmount -e 127.0.0.1

 

์œ„์™€ ๊ฐ™์ด ๋œจ๋ฉด ์‹คํ–‰์ด ์ž˜๋˜๋Š” ๊ฒ๋‹ˆ๋‹ค.

 

ํ…Œ์ŠคํŠธ ํ•˜๊ธฐ ์œ„ํ•˜์—ฌ /hom/nfs ๊ฒฝ๋กœ์— ์ž„์˜์˜ ํŒŒ์ผ์„ ๋งŒ๋“ญ๋‹ˆ๋‹ค.

$ echo 'test' > /home/nfs/test.txt

 

NFS๋ฅผ ์‚ฌ์šฉํ•  VM(192.168.0.170)

 

NFS ์„œ๋ฒ„๋ฅผ ๋งˆ์šดํŠธํ•ฉ๋‹ˆ๋‹ค.

$ mount -t nfs 192.168.0.165:/home/nfs /mnt

 

NFS ์„œ๋ฒ„์—์„œ ๋งŒ๋“  test.txt๊ฐ€ ์กด์žฌํ•˜๋Š”์ง€ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค.

$ cat /mnt/test.txt

test๋ผ๋Š” ๋ฌธ๊ตฌ๊ฐ€ ์ถœ๋ ฅ๋˜๋Š” ๊ฑธ ๋ณด์•„ํ•˜๋‹ˆ ์ž˜ ์‹คํ–‰๋ฉ๋‹ˆ๋‹ค.

 

์ฟ ๋ฒ„๋„คํ‹ฐ์Šค์—์„œ ๋ณผ๋ฅจ์„ ์‚ฌ์šฉํ•  ๋•Œ ์˜จํ”„๋ ˆ๋ฏธ์Šค ํ™˜๊ฒฝ์ผ ๊ฒฝ์šฐ NFS๋ฅผ ๋งŽ์ด ์‚ฌ์šฉํ•˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. ํผ๋ธ”๋ฆญ ํด๋ผ์šฐ๋“œ ํ™˜๊ฒฝ์ด๋ผ๋ฉด AWS์—์„œ ์ œ๊ณตํ•ด์ฃผ๋Š” EFS๋ฅผ ์ด์šฉํ•˜์—ฌ ๋ณผ๋ฅจ์„ ํŒŒ๋“œ์— ๋งˆ์šดํŠธ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

 

์ด์ƒ NFS ์„œ๋ฒ„ ๊ตฌ์ถ•์— ๋Œ€ํ•ด ์•Œ์•„๋ณด์•˜์Šต๋‹ˆ๋‹ค.

 

*์ถ”๊ฐ€

apiVersion: v1
kind: Pod
metadata:
  name: nfs-httpd
spec:
  containers:
  - image: httpd
    name: web
    volumeMounts:
    - mountPath: /usr/local/apache2/htdocs
      name: nfs-volume
      readOnly: true
  volumes:
  - name:  nfs-volume
    nfs:
      server: 192.168.0.165
      path: /home/nfs

์ฐธ๊ณ ๋กœ ํŒŒ๋“œ์—์„œ nfs๋ฅผ ๋ณผ๋ฅจ์œผ๋กœ ์‚ฌ์šฉํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด ์œ„์™€ ๊ฐ™์ด yaml ํŒŒ์ผ์„ ์ž‘์„ฑํ•˜์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค.

profile on loading

Loading...