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 fileshare from that instance on a client VM instance.
  • Create a file on the mounted fileshare.
  • Delete the Cloud Filestore instance.

Before you begin

  1. Google アカウントにログインします。

    Google アカウントをまだお持ちでない場合は、新しいアカウントを登録します。

  2. GCP プロジェクトを選択または作成します。

    [リソースの管理] ページに移動

  3. プロジェクトに対して課金が有効になっていることを確認します。

    課金を有効にする方法について

  4. Cloud SDK をインストールして初期化します。
  5. If you already have the Cloud SDK installed, run the following command to update it:

    gcloud components update
    

このチュートリアルの終了後は、作成したリソースを削除するとそれ以降課金されることがありません。詳細については、クリーンアップをご覧ください。

Create a Compute Engine VM instance to be the client

Linux

  1. Go to the Compute Engine instances page
  2. Click Create Instance.
  3. Set Name to nfs-client.
  4. Set Zone to us-central1-c.
  5. In the Firewall section, select Allow HTTP traffic.
  6. Click Create to create the instance.

Windows

  1. Go to the Compute Engine instances page
  2. Click Create Instance.
  3. Set Name to nfs-client.
  4. Set Zone to us-central1-c.
  5. In the Boot disk section, click Change.
  6. Select Windows Server 2012 R2 Datacenter in the OS images tab and click Select.
  7. In the Firewall section, select Allow HTTP traffic.
  8. Click Create to create the instance.

Create a Cloud Filestore instance

  1. Create an instance named nfs-server by running the following command in a local terminal or PowerShell window:

    gcloud filestore instances create nfs-server
        --project=[PROJECT_ID]
        --zone=us-central1-c
        --tier=STANDARD
        --file-share=name="vol1",capacity=1TB
        --network=name="default",reserved-ip-range="10.0.0.0/29"
    

    Where:

    • [PROJECT_ID] is the ID of the GCP project in which you want to create the instance.
  2. Get information about the Cloud Filestore instance you just created by running the following command:

    gcloud filestore instances describe nfs-server --project=[PROJECT_ID] --zone=us-central1-c
    

    You will see something similar to the following:

    createTime: '2017-11-06T16:49:36.852873Z'
    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
    fileshares:
    - capacityGb: '1024'
      name: vol1

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

Mount the Cloud Filestore fileshare on the client

Linux

  1. Go to the VM instances page
  2. In the list of VM instances, click the SSH button for nfs-client to open a terminal window connected to that instance.
  3. Install NFS by running the following commands:

    sudo apt-get -y update
    sudo apt-get -y install nfs-common
    
  4. Create a mount directory on the client VM for the Cloud Filestore fileshare by running the following command:

    sudo mkdir /mnt/test
    
  5. Mount the fileshare to the client VM with the mount command by specifying the IP address of the Cloud Filestore instance, the name of the fileshare, and the mount directory to mount to:

    sudo mount 10.0.0.2:/vol1 /mnt/test
    
  6. Make the fileshare accessible by changing its permissions:

    sudo chmod go+rw /mnt/test
    

Windows

Log in to the VM

  1. Go to the VM instances page
  2. Click the dropdown arrow next to the RDP button of nfs-client and select Set Windows password.
  3. Enter your desired username and click Set.
  4. Copy the generated password and click Close.
  5. Click the RDP button of nfs-server
  6. Enter the username and password from the previous steps.

Configure the user ID used by the NFS client

  1. From the Windows VM, open PowerShell as an administrator.
  2. In PowerShell, install the NFS client by running the following command:

    Install-WindowsFeature -Name NFS-Client
    
  3. Restart the Windows VM instance as prompted, then open a new remote desktop connection.

  4. From the Start menu of the client VM, search regedit and then open the Registry Editor.

  5. Go to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ClientForNFS\CurrentVersion\Default.

  6. Right-click on the Default folder and choose New > DWORD (32-bit) Value.

  7. Name the new entry AnonymousUid and leave it with the default value of 0.

  8. Repeat the previous two steps and create another entry named AnonymousGid.

  9. Open PowerShell as an administrator.

  10. In PowerShell, restart the NFS client service by running the following commands:

    nfsadmin client stop
    

    Then:

    nfsadmin client start
    

Map the network drive

  1. Open Windows Explorer and click the Map network drive menu item.
  2. For Drive, select an unused drive letter to map to. For the purpose of this quickstart, we use Z:\.
  3. For Folder, enter the following:

    \\10.0.0.2\vol1
    
  4. Click Finish.

Create a file on the fileshare

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 PowerShell window on the nfs-client VM, create a file named testfile by running the following command:

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

    dir Z:
    

    And verify that testfile is in the directory contents returned.

Clean up

To avoid incurring charges to your GCP account for the resources used in this quickstart:

  1. Delete the Cloud Filestore instance by running the following command in your local terminal or PowerShell window:

    gcloud filestore instances delete nfs-server --project=[PROJECT_ID] --zone=us-central1-c
    
  2. Go to the VM instances page

  3. Click the name of the nfs-client instance.

  4. At the top of the instance's details page, click Delete.

  5. Follow the instructions at Shutting down projects to delete the GCP project you created.

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.
このページは役立ちましたか?評価をお願いいたします。

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

Cloud Filestore Documentation