יצירת מכונת Memorystore for Memcached באמצעות ה-CLI של gcloud

במדריך למתחילים הזה מוסבר איך ליצור מופע של Memorystore for Memcached, להתחבר למופע, לשלוח כמה פקודות Memcached ולמחוק את המופע.

לפני שמתחילים

  1. נכנסים לחשבון Google Cloud . אם אתם משתמשים חדשים ב- Google Cloud, צרו חשבון כדי שתוכלו להעריך את הביצועים של המוצרים שלנו בתרחישים מהעולם האמיתי. לקוחות חדשים מקבלים בחינם גם קרדיט בשווי 300$ להרצה, לבדיקה ולפריסה של עומסי העבודה.
  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. 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.

    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

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

  6. אם עדיין לא עשיתם זאת, מתקינים את Google Cloud SDK.

    כשמתבקשים, בוחרים את הפרויקט שבחרתם או שיצרתם למעלה.

  7. אם כבר התקנתם את Google Cloud SDK, עדכנו אותו.

    gcloud components update
  8. מפעילים את Service Networking API בפרויקט.
    הפעלת Service Networking API
  9. מפעילים בפרויקט את Memorystore for Memcached API.
    הפעלת Memorystore for Memcached API

יצירת מכונת Memorystore for Memcached

כדי ליצור מכונת Memorystore for Memcached:

  1. פותחים חלון טרמינל.

  2. מגדירים את הפרויקט שבו רוצים ליצור את המופע כפרויקט ברירת המחדל ב-gcloud באמצעות הפקודה הבאה:

    gcloud config set core/project project-id
    
  3. מזינים את הפקודה הבאה כדי ליצור מופע Memcached עם 3 צמתים (כל צומת עם 4 ליבות וזיכרון של 10GB) באזור us-central1:

    gcloud memcache instances create myinstance --node-count=3 --node-cpu=4 \
        --node-memory=10GB --region=us-central1 --memcached-version=1.6.15
    
  4. אחרי שיוצרים את המופע, מריצים את הפקודה describe הבאה ורושמים את כתובת ה-IP של אחד מהצמתים.

    gcloud memcache instances describe myinstance --region=us-central1
    

התחברות למופע ממכונה וירטואלית ב-Compute Engine

  1. מתחברים ל-VM של Linux. הוראות להתחברות ל-VM של Linux מפורטות במאמר מדריך למתחילים: שימוש ב-VM של Linux. אם השתמשתם באימג' מבוסס Debian כדי ליצור את מופע ה-VM כמו שמתואר במאמר לתחילת העבודה, צריך להתקין את telnet באמצעות apt-get:

    sudo apt-get install telnet
    
  2. במסוף, מריצים telnet לכתובת ה-IP של אחד מצמתי Memcached, ומחליפים את variables בערכים המתאימים.

    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 על המשאבים שבהם השתמשתם במדריך למתחילים הזה, מוחקים את המופע באמצעות הפקודה הבאה:

    gcloud memcache instances delete myinstance --region=us-central1
    

    מזינים Y כדי לאשר את מחיקת המופע:

    You are about to delete instance [myinstance] in [us-central1].
    Any associated data will be lost.
    Do you want to continue (Y/n)? Y
    Delete request issued for: [myinstance]
    
  2. אם הפעולה בוצעה ללא שגיאות, הפקודה gcloud מחזירה את התגובה הבאה:

    Deleted instance [myinstance]
    

המאמרים הבאים