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

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

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

시작하기 전에

  1. Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
  2. Install the Google Cloud CLI.

  3. 외부 ID 공급업체(IdP)를 사용하는 경우 먼저 제휴 ID로 gcloud CLI에 로그인해야 합니다.

  4. gcloud CLI를 초기화하려면, 다음 명령어를 실행합니다.

    gcloud init
  5. Create or select a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator role (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.
    • Create a Google Cloud project:

      gcloud projects create PROJECT_ID

      Replace PROJECT_ID with a name for the Google Cloud project you are creating.

    • Select the Google Cloud project that you created:

      gcloud config set project PROJECT_ID

      Replace PROJECT_ID with your Google Cloud project name.

  6. 이 가이드에 기존 프로젝트를 사용하는 경우 이 가이드를 완료하는 데 필요한 권한이 있는지 확인합니다. 새 프로젝트를 만든 경우 필요한 권한이 이미 있습니다.

  7. Verify that billing is enabled for your Google Cloud project.

  8. Enable the Filestore API:

    Roles required to enable APIs

    To enable APIs, you need the Service Usage Admin IAM role (roles/serviceusage.serviceUsageAdmin), which contains the serviceusage.services.enable permission. Learn how to grant roles.

    gcloud services enable file.googleapis.com
  9. Install the Google Cloud CLI.

  10. 외부 ID 공급업체(IdP)를 사용하는 경우 먼저 제휴 ID로 gcloud CLI에 로그인해야 합니다.

  11. gcloud CLI를 초기화하려면, 다음 명령어를 실행합니다.

    gcloud init
  12. Create or select a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator role (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.
    • Create a Google Cloud project:

      gcloud projects create PROJECT_ID

      Replace PROJECT_ID with a name for the Google Cloud project you are creating.

    • Select the Google Cloud project that you created:

      gcloud config set project PROJECT_ID

      Replace PROJECT_ID with your Google Cloud project name.

  13. 이 가이드에 기존 프로젝트를 사용하는 경우 이 가이드를 완료하는 데 필요한 권한이 있는지 확인합니다. 새 프로젝트를 만든 경우 필요한 권한이 이미 있습니다.

  14. Verify that billing is enabled for your Google Cloud project.

  15. Enable the Filestore API:

    Roles required to enable APIs

    To enable APIs, you need the Service Usage Admin IAM role (roles/serviceusage.serviceUsageAdmin), which contains the serviceusage.services.enable permission. Learn how to grant roles.

    gcloud services enable file.googleapis.com
  16. 필요한 역할

    빠른 시작을 완료하는 데 필요한 권한을 얻으려면 관리자에게 프로젝트에 대한 다음 IAM 역할을 부여해 달라고 요청하세요.

    역할 부여에 대한 자세한 내용은 프로젝트, 폴더, 조직에 대한 액세스 관리를 참조하세요.

    커스텀 역할이나 다른 사전 정의된 역할을 통해 필요한 권한을 얻을 수도 있습니다.

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

    Compute Engine VM 만들기

    Linux

    1. Create a Compute Engine instance. Configure the instance as follows:
      • Name the instance nfs-client.
      • --zone 플래그를 us-central1-c로 설정합니다.
      • --image-project 플래그를 debian-cloud로 설정합니다.
      • --image-family 플래그를 debian-11로 설정합니다.
      • --tags 플래그를 http-server,로 설정합니다.
      • gcloud compute instances create nfs-client --zone=us-central1-c --image-project=debian-cloud --image-family=debian-11 --tags=http-server,

    Windows

    1. Create a Compute Engine instance. Configure the instance as follows:
      • Name the instance 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,

    IAM 인스턴스 만들기

    이 빠른 시작에서는 맞춤 성능이 사용 설정된 리전 서비스 등급에서 인스턴스를 만드는 방법을 보여줍니다. 인스턴스 만들기에 대한 자세한 내용은 인스턴스 만들기를 참고하세요.

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

      • 인스턴스 이름을 nfs-server로 지정합니다.
      • --region 플래그를 us-central1로 설정합니다.
      • --tier 플래그를 REGIONAL로 설정합니다.
      • --performance 플래그를 max-iops-per-tb=17000로 설정합니다.

      • --file-share 플래그를 name="vol1",capacity=1TB로 설정합니다.

      • --network 플래그를 name="default"로 설정합니다.

        gcloud filestore instances create nfs-server --region=us-central1 --tier=REGIONAL --performance=max-iops-per-tb=17000 --file-share=name="vol1",capacity=1TB --network=name="default"
    2. 생성한 IAM 인스턴스에 대한 정보를 가져옵니다.

        gcloud filestore instances describe nfs-server --region=us-central1 

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

          createTime: '2025-02-12T09:15:08.163246004Z'
          customPerformanceSupported: true
          fileShares:
           -capacityGb: '1024'
              name: vol1
          name: projects/yourproject/locations/us-central1/instances/nfs-server
          networks:
          -connectMode: DIRECT_PEERING
            ipAddresses:
             - 10.0.0.2
            network: default
            reservedIpRange: 10.0.0.2/26
          performanceConfig:
            iopsPerTb:
              maxIopsPerTb: '17000'
          performanceLimits:
            maxIops: '17000'
            maxReadIops: '17000'
            maxReadThroughputBps: '417792000'
            maxWriteIops: '5100'
            maxWriteThroughputBps: '139264000'
          protocol: NFS_V3
          state: READY
          tier: REGIONAL

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

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

    Linux

    1. Establish an SSH connection to the nfs-client 인스턴스:
      gcloud compute ssh nfs-client

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

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

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

      sudo mount MOUNT-POINT-DIRECTORY /mnt/test
      

      각 항목의 의미는 다음과 같습니다.

      MOUNT-POINT-DIRECTORY는 Filestore 파일 공유가 마운트된 디렉터리의 경로입니다. 예를 들면 10.0.0.2:/vol1입니다.

    4. 선택사항: Filestore 파일 공유가 마운트되었는지 확인합니다.

      df -h --type=nfs

    5. 파일 공유 액세스가 가능하도록 권한을 변경합니다.

      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에서 IAM 인스턴스의 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 프로젝트 삭제

      Delete a Google Cloud project:

      gcloud projects delete PROJECT_ID

    IAM 인스턴스 삭제

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

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

    Compute Engine 인스턴스 삭제

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

    다음 단계