gcloud CLI를 사용하여 Filestore 인스턴스 만들기

이 빠른 시작에서는 Google Cloud CLI를 사용하여 Filestore를 빠르게 시작하고 실행하는 방법을 보여줍니다. 이 빠른 시작에서 설명하는 사항은 다음과 같습니다.

  • Filestore 인스턴스를 만듭니다.
  • 해당 인스턴스의 파일 공유를 Compute Engine 클라이언트 VM에 마운트합니다.
  • 마운트된 파일 공유에서 파일을 만듭니다.
  • Filestore 인스턴스를 삭제합니다.

시작하기 전에

  1. 프로젝트 선택 또는 생성:

    프로젝트 만들기

     gcloud projects create project-id
    

    프로젝트 선택

     gcloud config set project project-id
    

    여기서 project-id는 Google Cloud 프로젝트의 ID입니다.

  2. 프로젝트에 결제가 사용 설정되어 있는지 확인하세요. 결제 사용 설정 방법을 알아봅니다.

  3. gcloud CLI를 설치하고 초기화합니다.

    gcloud CLI가 이미 설치되어 있으면 다음 명령어를 실행하여 업데이트합니다.

    gcloud components update
    

이 문서에 설명된 태스크를 완료했으면 만든 리소스를 삭제하여 청구가 계속되는 것을 방지할 수 있습니다. 자세한 내용은 삭제를 참조하세요.

클라이언트로 사용할 Compute Engine VM 만들기

Linux

  1. Compute Engine 인스턴스를 만듭니다. 인스턴스를 다음과 같이 구성합니다.
    • 인스턴스 이름을 nfs-client로 지정합니다.
    • --zone 플래그를 us-central1-c로 설정합니다.
    • --image-project 플래그를 debian-cloud로 설정합니다.
    • --image-family 플래그를 debian-10로 설정합니다.
    • --tags 플래그를 http-server,로 설정합니다.
    gcloud compute instances create nfs-client --zone=us-central1-c --image-project=debian-cloud --image-family=debian-10 --tags=http-server,

Windows

  1. Compute Engine 인스턴스를 만듭니다. 인스턴스를 다음과 같이 구성합니다.
    • 인스턴스 이름을 nfs-client로 지정합니다.
    • --zone 플래그를 us-central1-c로 설정합니다.
    • --image-project 플래그를 windows-cloud로 설정합니다.
    • --image-family 플래그를 windows-2012-r2로 설정합니다.
    • --tags 플래그를 http-server,http-server,로 설정합니다.
    gcloud compute instances create nfs-client --zone=us-central1-c --image-project=windows-cloud --image-family=windows-2012-r2 --tags=http-server,http-server,

Filestore 인스턴스 만들기

  1. Filestore 인스턴스를 만듭니다. 다음과 같이 인스턴스를 구성합니다.

    • 인스턴스 이름을 nfs-server로 지정합니다.
    • --zone 플래그를 us-central1-c로 설정합니다.
    • --tier 플래그를 BASIC_HDD로 설정합니다.
    • --file-share 플래그를 name="vol1",capacity=1TB로 설정합니다.
    • --network 플래그를 name="default"로 설정합니다.
    gcloud filestore instances create nfs-server --zone=us-central1-c --tier=BASIC_HDD --file-share=name="vol1",capacity=1TB --network=name="default"
  2. 만든 Filestore 인스턴스에 대한 정보를 가져옵니다.

    gcloud filestore instances describe nfs-server --zone=us-central1-c
    

    이 명령어는 다음과 비슷한 결과를 반환합니다.

    createTime: '2019-10-11T17:28:23.340943077Z'
    fileShares:
    - capacityGb: '1024'
     name: vol1
    name: projects/yourproject/locations/us-central1-c/instances/nfs-server
    networks:
    - ipAddresses:
     - 10.0.0.2
     network: default
     reservedIpRange: 10.0.0.0/29
    state: READY
    tier: BASIC_HDD
    

    파일 공유를 마운트할 때 사용하기 위해 인스턴스의 IP 주소를 복사합니다. 이 빠른 시작에서는 IP 주소 10.0.0.2가 사용됩니다.

Filestore 파일 공유를 nfs-client 인스턴스에 마운트

Linux

  1. nfs-client 인스턴스에 SSH 연결을 설정합니다.
    gcloud compute ssh nfs-client

  1. nfs-client의 터미널 창에서 다음 명령어를 실행하여 NFS를 설치합니다.

    sudo apt-get -y update &&
    sudo apt-get -y install nfs-common
    
  2. Filestore 파일 공유에 대해 nfs-client 인스턴스에 마운트 디렉터리를 만듭니다.

    sudo mkdir /mnt/test
    
  3. Filestore 인스턴스의 IP 주소, 파일 공유 이름, 마운트할 마운트 디렉터리를 지정하여 mount 명령어로 nfs-client 인스턴스에 파일 공유를 마운트합니다.

    sudo mount 10.0.0.2:/vol1 /mnt/test
    
  4. 파일 공유 액세스가 가능하도록 권한을 변경합니다.

    sudo chmod go+rw /mnt/test
    

Windows

nfs-client 인스턴스에 로그인하고 관리자로 명령 프롬프트를 엽니다.

  1. 계정을 만들고 nfs-client 인스턴스에 대해 초기 비밀번호를 설정합니다.

    gcloud compute reset-windows-password nfs-client
    
  2. 직렬 포트에 연결할 수 있도록 인스턴스를 구성합니다.

    gcloud compute instances add-metadata nfs-client --metadata=serial-port-enable=1
    
  3. 대화형 세션을 입력합니다.

    gcloud compute connect-to-serial-port nfs-client --port=2
    
  4. SAC> 프롬프트에서 새 채널을 만듭니다.

    cmd
    

    이름이 Cmd0001인 채널이 생성됩니다.

  5. 채널에 연결합니다.

    ch -sn Cmd0001
    
  6. nfs-client 인스턴스의 사용자 이름과 비밀번호를 입력하고 Domain 필드를 비워 둡니다. nfs-client 인스턴스의 Command Prompt 인터페이스에 연결됩니다.

NFS 클라이언트 설치

  1. nfs-clientCommand Prompt에서 Windows PowerShell로 전환합니다.

    powershell
    
  2. NFS 클라이언트를 설치합니다.

    Install-WindowsFeature -Name NFS-Client
    
  3. 메시지가 표시되면 nfs-client 인스턴스를 다시 시작합니다.

    restart-computer
    
  4. SAC> 프롬프트에서 다음 알림이 표시될 때까지 기다립니다.

    EVENT: The CMD command is now available.
    

    그런 후 이전 안내에 따라 cmdch -sn 명령어를 실행하여 로그인하고 nfs-client 인스턴스에 다시 연결합니다.

NFS 클라이언트에 사용되는 사용자 ID 구성

  1. 명령 프롬프트에서 powershell을 실행하여 Windows PowerShell로 전환합니다.
  2. PowerShell에서 다음 명령어를 실행하여 2개의 새 레지스트리 항목 AnonymousUidAnonymousGid를 만듭니다.

    New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\ClientForNFS\CurrentVersion\Default" `
        -Name "AnonymousUid" -Value "0" -PropertyType DWORD
    
    New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\ClientForNFS\CurrentVersion\Default" `
        -Name "AnonymousGid" -Value "0" -PropertyType DWORD
    
  3. NFS 클라이언트 서비스를 다시 시작합니다.

    nfsadmin client stop
    
    nfsadmin client start
    

vol1 파일 공유를 nfs-client 인스턴스에 매핑

  1. PowerShell을 종료합니다.

    exit
    
  2. Command Prompt에서 Filestore 인스턴스의 IP 주소, 파일 공유 이름, 마운트할 드라이브 문자를 지정하여 mount 명령어로 nfs-client 인스턴스에 파일 공유를 마운트합니다.

    mount -o mtype=hard 10.0.0.2:/vol1 z:
    

마운트된 파일 공유에서 파일 만들기

Linux

  1. nfs-client 터미널 창에서 다음 명령어를 실행하여 이름이 testfile인 파일을 만듭니다.

    echo 'This is a test' > /mnt/test/testfile
    
  2. 다음 명령어를 실행하고 testfile이 반환된 디렉터리 콘텐츠에 있는지 확인하여 파일이 생성되었는지 확인합니다.

    ls /mnt/test
    

Windows

  1. nfs-client 인스턴스의 명령 프롬프트 창에서 이름이 testfile인 파일을 만듭니다.

    echo 'This is a test' > Z:\testfile
    
  2. 다음 명령어를 실행하여 파일이 생성되었는지 확인합니다.

    dir Z:
    

    그리고 testfile이 반환된 디렉터리 콘텐츠에 있는지 확인합니다.

삭제

이 페이지에서 사용한 리소스 비용이 Google Cloud 계정에 청구되지 않도록 하려면 리소스가 포함된 Google Cloud 프로젝트를 삭제하면 됩니다.

Google Cloud 프로젝트 삭제

    Google Cloud 프로젝트를 삭제합니다.

    gcloud projects delete PROJECT_ID

Filestore 인스턴스 삭제

nfs-server 인스턴스를 삭제합니다.

gcloud filestore instances delete nfs-server --zone=us-central1-c

Compute Engine 인스턴스 삭제

인스턴스를 삭제합니다.
gcloud compute instances delete nfs-client

다음 단계

  • Filestore 개요를 읽고 Filestore의 기본 사항에 대해 자세히 알아봅니다.
  • 인스턴스 만들기의 안내에 따라 직접 Filestore 인스턴스를 설정합니다.
  • 액세스 제어를 읽어 Filestore 작업 및 인스턴스의 리소스에 대한 액세스를 제어하는 방법을 알아봅니다.