Google Cloud コンソールを使用して Memorystore for Memcached インスタンスを作成する
このクイックスタートでは、Memorystore for Memcached インスタンスの作成、インスタンスへの接続、値の設定、値の取得、インスタンスの削除の手順を説明します。
始める前に
- 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.
- 
    
    
      In the Google Cloud console, on the project selector page, select or create 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
      (roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
 
- 
  
    Verify that billing is enabled for your Google Cloud project. 
- 
    
    
      In the Google Cloud console, on the project selector page, select or create 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
      (roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
 
- 
  
    Verify that billing is enabled for your Google Cloud project. 
- 
    プロジェクトで Service Networking API を有効にします。
 Service Networking API を有効にする
- 
    プロジェクトで Memorystore for Memcached API を有効にします。
 Memorystore for Memcached API を有効にする
Memcached インスタンスを作成する
- Google Cloud コンソールの [Memorystore for Memcached] ページに移動します。 
 Memorystore for Memcached
- [インスタンスを作成] ボタンをクリックします。 
- Google Cloud コンソールの [Memcached インスタンスの作成] ページで、新しいインスタンスの構成を選択します。 - 小文字、数字、ハイフンのみを使用してインスタンス ID を入力します。文字から始まる。
- 例:my-memcached-instance-1
 
- 例:
- [リージョン] プルダウンで us-central1を選択します。
- [ゾーン] プルダウンで Automatically distributeを選択します。
- [ノード] で「2」と入力して、2 つのノードを作成します。
- [ノードあたりのメモリ] で 1 GB を選択します。
- [ノードあたりのコア数] で 1 を選択します。
- [承認済みネットワーク] で - defaultを選択します。
 
- 小文字、数字、ハイフンのみを使用してインスタンス ID を入力します。文字から始まる。
- [作成] をクリックします。 
- インスタンスが作成されたら、インスタンス ID をクリックして、インスタンスの詳細ページを表示します。 
- いずれかのノードの - IP addressをメモします。
Compute Engine VM からインスタンスへの接続
接続をテストするには:
- Linux VM に接続します。Linux VM に接続する手順については、Linux VM の使用に関するクイックスタートをご覧ください。クイックスタートの説明に従い、Debian ベースのイメージを使用して VM インスタンスを作成した場合は、 - apt-getを使用して- telnetをインストールします。- sudo apt-get install telnet
- ターミナルから、Memcached ノードのいずれかの IP アドレスに telnet で接続します。 node-ip-address は、ノードの IP アドレスに置き換えます。 - telnet node-ip-address 11211 - 次の出力にプロジェクトの変数で置き換えられた - [bracketed-variables]が表示されます。- Trying [node-ip-address]… Connected to [node-ip-address] 
- telnet セッションで、いくつかの Memcached コマンドを入力します。 - 次のように入力します。 - get greeting - 結果: - END - 次のように入力します。 - set greeting 1 0 11 hello world - 結果: - STORED - 次のように入力します。 - get greeting - 結果: - VALUE greeting 1 11 hello world END 
Memorystore for Memcached は、標準のオープンソース Memcached ライブラリをサポートしています。
クリーンアップ
このページで使用したリソースについて、 Google Cloud アカウントに課金されないようにするには、次の手順を実施します。
- Google Cloud コンソールの [Memorystore for Memcached] ページに移動します。 
 Memorystore for Memcached
- 削除するインスタンスの ID をクリックします。 
- [削除] ボタンをクリックします。 
- プロンプトが表示されると、インスタンスの ID を入力します。 
- [削除] ボタンをクリックします。