使用 Google Cloud 控制台建立 Memorystore for Memcached 執行個體

本快速入門導覽課程會逐步引導您建立 Memorystore for Memcached 執行個體、連線至執行個體、設定值、擷取值及刪除執行個體。

事前準備

  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. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

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

  4. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

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

  6. 為專案啟用 Service Networking API。
    啟用 Service Networking API
  7. 為專案啟用 Memorystore for Memcached API。
    啟用 Memorystore for Memcached API

建立 Memcached 執行個體

  1. 前往 Google Cloud 控制台的 Memorystore for Memcached 頁面。
    Memorystore for Memcached

  2. 按一下 [Create Instance] (建立執行個體) 按鈕。

  3. 在 Google Cloud 控制台的「Create a Memcached instance」(建立 Memcached 執行個體) 頁面上,選取新執行個體的設定:

    • 請輸入執行個體 ID,只能使用小寫英文字母、數字和連字號。 開頭須為英文字母。
      • 例如 my-memcached-instance-1
    • 從「Region」下拉式選單中選擇 us-central1
    • 從「區域」下拉式選單中選擇 Automatically distribute
    • 在「節點」下方輸入 2,建立兩個節點。
    • 選擇每個節點 1 GB 的記憶體
    • 選擇「每節點的核心數」為 1。
    • 選取「授權網路」default

  4. 點選「建立」

  5. 執行個體建立完成後,按一下執行個體 ID 以查看執行個體詳細資料頁面。

  6. 記下其中一個節點的 IP address

從 Compute Engine VM 連線至執行個體

如要測試連線,請按照下列步驟操作:

  1. 連線至 Linux VM。如需連線至 Linux VM 的步驟,請參閱「使用 Linux VM 的快速入門導覽課程」。 如果您依快速入門所述,使用以 Debian 為基礎的映像檔建立 VM 執行個體,請使用 apt-get 安裝 telnet

    sudo apt-get install telnet
    
  2. 在終端機中,透過 telnet 連線至其中一個 Memcached 節點的 IP 位址。將 node-ip-address 替換為節點的 IP 位址。

    telnet node-ip-address 11211
    

    您應該會看到下列輸出內容,其中 [bracketed-variables] 已替換為專案的變數:

    Trying [node-ip-address]…
    Connected to [node-ip-address]
    
  3. 在 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 帳戶收取本頁所用資源的費用,請按照下列步驟操作。

  1. 前往 Google Cloud 控制台的 Memorystore for Memcached 頁面。
    Memorystore for Memcached

  2. 找出要刪除的執行個體,然後按一下該執行個體的 ID。

  3. 按一下 [Delete] (刪除) 按鈕。

  4. 在隨即顯示的提示中,輸入執行個體的 ID。

  5. 按一下 [Delete] (刪除) 按鈕。

後續步驟