יצירת מכונת Memorystore for Memcached באמצעות ה-CLI של gcloud
במדריך למתחילים הזה מוסבר איך ליצור מופע של Memorystore for Memcached, להתחבר למופע, לשלוח כמה פקודות Memcached ולמחוק את המופע.
לפני שמתחילים
- נכנסים לחשבון Google Cloud . אם אתם משתמשים חדשים ב- Google Cloud, צרו חשבון כדי שתוכלו להעריך את הביצועים של המוצרים שלנו בתרחישים מהעולם האמיתי. לקוחות חדשים מקבלים בחינם גם קרדיט בשווי 300$ להרצה, לבדיקה ולפריסה של עומסי העבודה.
-
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 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 role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
- אם עדיין לא עשיתם זאת, מתקינים את Google Cloud SDK.
כשמתבקשים, בוחרים את הפרויקט שבחרתם או שיצרתם למעלה.
-
אם כבר התקנתם את Google Cloud SDK, עדכנו אותו.
gcloud components update
-
מפעילים את Service Networking API בפרויקט.
הפעלת Service Networking API -
מפעילים בפרויקט את Memorystore for Memcached API.
הפעלת Memorystore for Memcached API
יצירת מכונת Memorystore for Memcached
כדי ליצור מכונת Memorystore for Memcached:
פותחים חלון טרמינל.
מגדירים את הפרויקט שבו רוצים ליצור את המופע כפרויקט ברירת המחדל ב-
gcloudבאמצעות הפקודה הבאה:gcloud config set core/project project-id
מזינים את הפקודה הבאה כדי ליצור מופע 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אחרי שיוצרים את המופע, מריצים את הפקודה
describeהבאה ורושמים את כתובת ה-IP של אחד מהצמתים.gcloud memcache instances describe myinstance --region=us-central1
התחברות למופע ממכונה וירטואלית ב-Compute Engine
מתחברים ל-VM של Linux. הוראות להתחברות ל-VM של Linux מפורטות במאמר מדריך למתחילים: שימוש ב-VM של Linux. אם השתמשתם באימג' מבוסס Debian כדי ליצור את מופע ה-VM כמו שמתואר במאמר לתחילת העבודה, צריך להתקין את
telnetבאמצעותapt-get:sudo apt-get install telnet
במסוף, מריצים telnet לכתובת ה-IP של אחד מצמתי Memcached, ומחליפים את variables בערכים המתאימים.
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 על המשאבים שבהם השתמשתם במדריך למתחילים הזה, מוחקים את המופע באמצעות הפקודה הבאה:
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]
אם הפעולה בוצעה ללא שגיאות, הפקודה
gcloudמחזירה את התגובה הבאה:Deleted instance [myinstance]