Quickstart using the gcloud tool

This quickstart shows you how to get up and running quickly with Cloud Filestore using the gcloud command-line tool. In this quickstart, you will learn how to do the following:

  • Create a Cloud Filestore instance.
  • Mount the file share from that instance on a Compute Engine client VM.
  • Create a file on the mounted file share.
  • Delete the Cloud Filestore instance.

Before you begin

  1. Select or create a GCP project:

    To create a project, run:

    gcloud projects create project-id
    

    To select a project, run:

    gcloud config set project-id
    

    where project-id is the ID of the Google Cloud project.

  2. Make sure that billing is enabled for your Google Cloud Platform project. Learn how to enable billing.

  3. Install and initialize the Cloud SDK.

    If you already have the Cloud SDK installed, run the following command to update it:

    gcloud components update
    

このチュートリアルを終了した後、作成したリソースを削除すると、それ以上の請求は発生しません。詳しくは、クリーンアップをご覧ください。

Create a Compute Engine VM to be the client

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,

Create a Cloud Filestore instance

  1. Create a Cloud Filestore instance. Configure the instance as follows:

    • Name the instance nfs-server.
    • Set the --zone flag to us-central1-c.
    • Set the --tier flag to STANDARD.
    • Set the --file-share flag to name="vol1",capacity=1TB.
    • Set the --network flag to name="default".
    gcloud filestore instances create nfs-server --zone=us-central1-c --tier=STANDARD --file-share=name="vol1",capacity=1TB --network=name="default"
  2. Get information about the Cloud Filestore instance you just created:

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

    You will see something similar to the following:

    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: STANDARD
    

    Copy down the IP address of the instance for use when mounting the file share. For this quickstart, we use the IP address 10.0.0.2.

Mount the Cloud Filestore file share on the nfs-client instance

Linux

  1. nfs-clientnfs-client インスタンスへの SSH 接続を確立します。
    gcloud compute ssh nfs-client

  1. Install NFS by running the following commands on the terminal window of nfs-client:

    sudo apt-get -y update &&
    sudo apt-get -y install nfs-common
    
  2. Create a mount directory on the nfs-client instance for the Cloud Filestore file share:

    sudo mkdir /mnt/test
    
  3. Mount the file share to the nfs-client instance with the mount command by specifying the IP address of the Cloud Filestore instance, the name of the file share, and the mount directory to mount to:

    sudo mount 10.0.0.2:/vol1 /mnt/test
    
  4. Make the file share accessible by changing its permissions:

    sudo chmod go+rw /mnt/test
    

Windows

Log in to the nfs-client instance and open a Command Prompt as an administrator

  1. Create an account and set an initial password for the nfs-client instance:

    gcloud compute reset-windows-password nfs-client
    
  2. Configure your instance to enable connecting to serial ports:

    gcloud compute instances add-metadata nfs-client --metadata=serial-port-enable=1
    
  3. Enter an interactive session:

    gcloud compute connect-to-serial-port nfs-client --port=2
    
  4. At the SAC> prompt, create a new channel:

    cmd
    

    A channel with the name Cmd0001 is created.

  5. Connect to the channel:

    ch -sn Cmd0001
    
  6. Enter the username and password of the nfs-client instance and leave the Domain field blank. This connects you to the Command Prompt interface of the nfs-client instance.

Install NFS client

  1. In the Command Prompt of nfs-client, switch to Windows PowerShell:

    powershell
    
  2. Install the NFS client:

    Install-WindowsFeature -Name NFS-Client
    
  3. Restart the nfs-client instance when prompted:

    restart-computer
    
  4. At the SAC> prompt, wait for the following notification to appear:

    EVENT: The CMD command is now available.
    

    Then, run the cmd and ch -sn commands as previously instructed to log in and reconnect to the nfs-client instance.

Configure the user ID used by the NFS client

  1. In the Command Prompt, run powershell to switch to Windows PowerShell.
  2. In PowerShell, run the following commands to create two new registry entries, AnonymousUid and AnonymousGid:

    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. Restart the NFS client service:

    nfsadmin client stop
    
    nfsadmin client start
    

Map the vol1 file share to the nfs-client instance

  1. Exit PowerShell:

    exit
    
  2. From Command Prompt, mount file share vol1 of nfs-server:

    mount 10.0.0.2:/vol1 z:
    

Create a file on the mounted file share

Linux

  1. In the nfs-client terminal window, create a file named testfile by running the following command:

    echo 'This is a test' > /mnt/test/testfile
    
  2. Confirm the file was created by running the following command and verifying that testfile is in the directory contents returned:

    ls /mnt/test
    

Windows

  1. In the Command Prompt window of the nfs-client instance, create a file named testfile:

    echo 'This is a test' > Z:\testfile
    
  2. Confirm the file was created by running the following command:

    dir Z:
    

    and verifying that testfile is in the directory contents returned.

Clean up

To avoid incurring charges to your Google Cloud account for the resources used in this quickstart, follow these steps.

Deleting the Google Cloud project

  1. GCP Console で [プロジェクト] ページに移動します。

    プロジェクト ページに移動

  2. プロジェクト リストで、削除するプロジェクトを選択し、[削除] をクリックします。
  3. ダイアログでプロジェクト ID を入力し、[シャットダウン] をクリックしてプロジェクトを削除します。

Deleting the Cloud Filestore instance

Delete the nfs-server instance:

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

Deleting the Compute Engine instance

次のように入力してインスタンスを削除します。
gcloud compute instances delete nfs-client

What's next

  • Read the Cloud Filestore Overview to learn more about the basics of Cloud Filestore.
  • Set up a Cloud Filestore instance on your own by following the instructions at Creating Instances.
  • Read Access Control to learn how to control access to Cloud Filestore operations as well as the resources on an instance.
このページは役立ちましたか?評価をお願いいたします。

フィードバックを送信...