Buat instance Memorystore for Redis menggunakan Google Cloud konsol

Pelajari cara membuat instance Memorystore for Redis, terhubung ke instance, lalu menghapusnya.


Untuk mengikuti panduan langkah demi langkah untuk tugas ini langsung di Google Cloud konsol, klik Pandu saya:

Pandu saya


Sebelum memulai

  1. Login ke akun Google Cloud Anda. Jika Anda baru menggunakan Google Cloud, buat akun untuk mengevaluasi performa produk kami dalam skenario dunia nyata. Pelanggan baru juga mendapatkan kredit gratis senilai $300 untuk menjalankan, menguji, dan men-deploy workload.
  2. 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 role (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  3. If you're using an existing project for this guide, verify that you have the permissions required to complete this guide. If you created a new project, then you already have the required permissions.

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

  5. Enable the Memorystore for Redis 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.

    Enable the API

  6. 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 role (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  7. If you're using an existing project for this guide, verify that you have the permissions required to complete this guide. If you created a new project, then you already have the required permissions.

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

  9. Enable the Memorystore for Redis 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.

    Enable the API

Peran yang diperlukan

Untuk mendapatkan izin yang Anda perlukan guna membuat instance Memorystore for Redis, minta administrator untuk memberi Anda peran IAM berikut pada project:

Untuk mengetahui informasi selengkapnya tentang pemberian peran, lihat Mengelola akses ke project, folder, dan organisasi.

Anda mungkin juga bisa mendapatkan izin yang diperlukan melalui peran khusus atau peran bawaan lainnya.

Buat instance Memorystore for Redis

Di bagian ini, Anda akan membuat instance Memorystore for Redis 2 GB yang berada di region us-central1 dan menggunakan tingkat Dasar. Untuk mengetahui informasi selengkapnya tentang tingkat, lihat Kemampuan tingkat Redis.

  1. Di konsol Google Cloud , buka halaman Memorystore for Redis.

    Memorystore for Redis

  2. Klik Create instance.

  3. Di halaman Create a Redis instance, lakukan konfigurasi berikut untuk instance yang Anda buat:

    • Di kolom Instance ID, masukkan my-instance-1.
    • Di kolom Nama tampilan, masukkan My Quickstart Instance.
    • Di bagian Tier selection, pilih Basic. Tingkat ini menetapkan node Redis mandiri, berbeda dengan tingkat Standar, yang menggunakan node replika untuk mencadangkan data Anda.
    • Di kolom Kapasitas, masukkan 5. Tindakan ini menetapkan kapasitas instance Anda ke 5 GB.
    • Dari menu Region, pilih us-central1 (Iowa).
    • Dari menu Network, pilih default.
    • Luaskan node Configuration, lalu dari menu Version, pilih
      7.2 (Direkomendasikan).
  4. Klik Create instance.

  5. Setelah membuat instance, dapatkan IP address instance Anda dengan mengikuti langkah-langkah berikut:

    1. Di konsol Google Cloud , buka halaman Memorystore for Redis.
      Memorystore for Redis
    2. Klik ID instance Anda: my-instance-1.
    3. Di bagian Connections, catat Primary Endpoint dan nomor Port instance Anda di 6379. Anda memerlukan endpoint dan nomor port untuk terhubung ke instance.

Menghubungkan ke instance Memorystore for Redis dari VM Compute Engine

Anda dapat terhubung ke instance Memorystore for Redis dari VM Compute Engine mana pun yang menggunakan jaringan resmi instance dengan alamat IP RFC 1918 yang didukung.

  1. Jika Anda tidak memiliki VM Compute Engine yang menggunakan jaringan resmi yang sama dengan instance Anda, buat VM tersebut, lalu hubungkan ke VM menggunakan SSH. Untuk melakukannya, ikuti langkah-langkah di Membuat instance VM Linux di Compute Engine.

  2. Gunakan apt-get untuk menginstal telnet:

    sudo apt-get install telnet
    
  3. Dari terminal, telnet ke alamat IP instance. Ganti VARIABLES dengan nilai yang sesuai.

    telnet INSTANCE_IP_ADDRESS 6379
    

    Jika Anda dapat terhubung ke instance, perintah akan menampilkan hasil ini:

    Trying INSTANCE_IP_ADDRESS…
    Connected to INSTANCE_IP_ADDRESS
    
  4. Di sesi telnet, masukkan beberapa perintah Redis:

    Enter:

    PING
    

    Hasil:

    PONG
    

    Enter

    SET HELLO WORLD
    

    Hasil:

    +OK
    

    Enter:

    GET HELLO
    

    Hasil:

    $5
    WORLD
    

Pembersihan

Agar akun Google Cloud Anda tidak dikenai biaya untuk resource yang digunakan pada halaman ini, ikuti langkah-langkah berikut.

  1. Di konsol Google Cloud , buka halaman Memorystore for Redis.
    Memorystore for Redis
  2. Klik ID instance yang ingin Anda hapus.
  3. Klik Hapus.
  4. Pada perintah yang muncul, masukkan ID instance.
  5. Klik Hapus.
  6. Opsional. Jika Anda membuat VM Compute Engine untuk panduan memulai ini, hapus VM tersebut.

Langkah berikutnya