יצירת מכונה של Memorystore for Redis באמצעות מסוף Google Cloud
במאמר הזה מוסבר איך ליצור מכונת Memorystore for Redis, להתחבר אליה ואז למחוק אותה.
לחצו על תראו לי איך כדי לקרוא הסבר מפורט על המשימה ישירות במסוף Google Cloud :
לפני שמתחילים
- נכנסים לחשבון 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.
-
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.
-
Verify that billing is enabled for your Google Cloud project.
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 theserviceusage.services.enablepermission. Learn how to grant roles.-
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.
-
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.
-
Verify that billing is enabled for your Google Cloud project.
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 theserviceusage.services.enablepermission. Learn how to grant roles.
התפקידים הנדרשים
כדי לקבל את ההרשאות שדרושות ליצירת מכונת Memorystore for Redis, צריך לבקש מהאדמין להקצות לכם את תפקידי ה-IAM הבאים בפרויקט:
- אדמין ב-Cloud Memorystore Redis (
roles/redis.admin) - אדמין במכונות וירטואליות של Compute (גרסה 1) (
roles/compute.instanceAdmin.v1) - משתמש בחשבון שירות (
roles/iam.serviceAccountUser)
להסבר על מתן תפקידים, ראו איך מנהלים את הגישה ברמת הפרויקט, התיקייה והארגון.
יכול להיות שאפשר לקבל את ההרשאות הנדרשות גם באמצעות תפקידים בהתאמה אישית או תפקידים מוגדרים מראש.
יצירת מכונה של Memorystore for Redis
בקטע הזה יוצרים מכונת Memorystore for Redis בנפח 2GB שנמצאת באזור us-central1 וברמת Basic. מידע נוסף על הרמות זמין במאמר יכולות של רמות Redis.
נכנסים לדף Memorystore for Redis במסוף Google Cloud .
לוחצים על Create instance.
בדף Create a Redis instance, מבצעים את ההגדרות הבאות עבור המופע שיוצרים:
- בשדה Instance ID (מזהה המופע), מזינים את הערך
my-instance-1. - בשדה שם מוצג, מזינים
My Quickstart Instance. - בקטע Tier selection, בוחרים באפשרות Basic. המסלול הזה מייעד צומת Redis עצמאי, בניגוד למסלול Standard, שמשתמש בצומת העתקה לגיבוי הנתונים.
- בשדה קיבולת, מזינים
5. הפעולה הזו מגדירה את הקיבולת של המופע ל-5GB. - בתפריט Region, בוחרים באפשרות us-central1 (Iowa).
- בתפריט Network (רשת), בוחרים באפשרות default (ברירת מחדל).
- מרחיבים את הצומת Configuration, ואז בתפריט Version בוחרים באפשרות
7.2 (מומלץ).
- בשדה Instance ID (מזהה המופע), מזינים את הערך
לוחצים על Create instance.
אחרי שיוצרים את המופע, מקבלים את ה-
IP addressשל המופע באמצעות השלבים הבאים:- נכנסים לדף Memorystore for Redis במסוף Google Cloud .
Memorystore for Redis - לוחצים על המזהה של המופע:
my-instance-1. - בקטע Connections, רושמים את Primary Endpoint ואת מספר Port של המופע, שהוא
6379. צריך את נקודת הקצה ואת מספר היציאה כדי להתחבר למופע.
- נכנסים לדף Memorystore for Redis במסוף Google Cloud .
התחברות למכונת Memorystore for Redis ממכונה וירטואלית ב-Compute Engine
אפשר להתחבר למופע של Memorystore for Redis מכל מכונה וירטואלית ב-Compute Engine שמשתמשת ברשת המורשית של המופע עם כתובת IP נתמכת מסוג RFC 1918.
אם אין לכם מכונה וירטואלית של Compute Engine שמשתמשת באותה רשת מורשית כמו המופע שלכם, אתם צריכים ליצור אחת כזו ולהתחבר אליה באמצעות SSH. כדי לעשות זאת, פועלים לפי השלבים במאמר יצירת מכונה וירטואלית של Linux ב-Compute Engine.
משתמשים ב-
apt-getכדי להתקין אתtelnet:sudo apt-get install telnetמהטרמינל, מתחברים באמצעות Telnet לכתובת ה-IP של המכונה. מחליפים את VARIABLES בערכים המתאימים.
telnet INSTANCE_IP_ADDRESS 6379
אם אפשר להתחבר למופע, הפקודה תחזיר את התוצאה הבאה:
Trying INSTANCE_IP_ADDRESS… Connected to INSTANCE_IP_ADDRESS
בסשן של telnet, מזינים כמה פקודות Redis:
צריך להזין את הפרטים הבאים:
PING
תוצאה:
PONG
Enter
SET HELLO WORLD
תוצאה:
+OK
צריך להזין את הפרטים הבאים:
GET HELLO
תוצאה:
$5 WORLD
הסרת המשאבים
כדי לא לצבור חיובים לחשבון Google Cloud על המשאבים שבהם השתמשתם בדף הזה, פועלים לפי השלבים הבאים:
- נכנסים לדף Memorystore for Redis במסוף Google Cloud .
Memorystore for Redis - לוחצים על המזהה של המכונה שרוצים למחוק.
- לוחצים על Delete.
- בהנחיה שמופיעה, מזינים את מזהה המכונה.
- לוחצים על Delete.
- אופציונלי. אם יצרתם מכונה וירטואלית ב-Compute Engine לצורך המדריך למתחילים הזה, צריך למחוק אותה.