[클라우드 With리눅스/NFS 서버 운용하기]

SooYeon Yeon·2022년 8월 18일

클라우드 With리눅스

목록 보기
12/39

NFS 서버 운용하기

NFS(Network FIle System)

  • AWS에서는 EFS(Elastic File System)으로 사용

centos7 ——————> centos8

(nfs server) (nfs client)

  1. 다른 사용자와 공유할 수 있는 디렉토리 생성

    [centos7 - nfs server]

    [root@srv7 0720]# mkdir /public
  2. 접근 제어

    [centos7 - nfs server]

    • 소유주, 그룹, 그외 일반사용자 모두 /public에 접근해 파일 업로드, 다운로드 가능하게 함
    [root@srv7 0720]# chmod 777 /public
    [root@srv7 0720]# ls -l /
    total 28
    ...
    drwxrwxrwx.   2 root root    6 Jul 20 15:11 public
    ...

    chmod 777 : rwxrwxrwx, 모두가 읽기,쓰기,실행 가능

  3. 파일 하나 생성 해두기

    [centos7 - nfs server]

    # 파일 하나 만들어두기
    [root@srv7 0720]# touch /public/test.txt
  4. centos7,8 모두 nfs-utils 설치

    yum -y install nfs-utils
  5. 파일 내용 추가

    [centos7 - nfs server]

    [root@srv7 0720]# vi /etc/exports

    파일 내용

    /public         211.183.3.0/24(rw,sync,no_root_squash)
    • 211.183.3.대에 있는 모든 네트워크가 접근 할 수 있도록 함
    • sync 동기화
    • no_root_squash : 원격지에 있는 사용자가 공유 디렉토리에서 파일을 만들었을 경우 서버 입장에서 해당 파일을 누가 만든 것으로 간주 할 것인지
      • 만약, root_squash면 nfsnobody가 만든 것
      • no_root_squash면 root가 만든 것
  6. nfs-server 시작

    restart : 지금 재시작

    enable : 시작 시 nfs-server 켜지도록 함

    [centos7 - nfs server]

    [root@srv7 0720]# systemctl restart nfs-server
    [root@srv7 0720]# systemctl enable nfs-server
    Created symlink from /etc/systemd/system/multi-user.target.wants/nfs-server.service to /usr/lib/systemd/system/nfs-server.service.
  7. mount하기

    [centos8 - nfs client]

    • mount하기
    # 해당 IP에서 현재 외부에 노출하고 있는 디렉토리를 보여줘
    [root@srv8 ~]# showmount -e 211.183.3.201
    Export list for 211.183.3.201:
    /public 211.183.3.0/24
    
    # 211.183.3.201에 있는 /public을 내 /remote와 mount
    [root@srv8 ~]# mkdir /remote
    [root@srv8 ~]# mount -t nfs 211.183.3.201:/public /remote
    
    [root@srv8 ~]# ls /remote
    test.txt
    [root@srv8 ~]# echo "hello" > /remote/test.txt

    [centos7 - nfs server]

    • centos7에서 바뀐 것이 잘 확인됨
    [root@srv7 0720]# cat /public/test.txt
    hello

0개의 댓글