בדף הזה מוסבר איך להפעיל מכונה, לעצור מכונה ולהפעיל מחדש מכונה שפועלת.
מדיניות הפעלה
כשמפעילים, עוצרים או מפעילים מחדש מכונה, צריך להגדיר מדיניות הפעלה. מדיניות ההפעלה מציינת אם המכונה מופעלת כדי לקבל בקשות חיבור.
אפשרויות מדיניות ההפעלה הן:
-
ALWAYS– המכונה תמיד פועלת. -
NEVER– המכונה לא מופעלת מחדש.
ALWAYS. אם אתם לא משתמשים במכונה, אתם יכולים להגדיר את מדיניות ההפעלה שלה ל-NEVER כדי להימנע מחיובים על המכונה.
הפעלת מכונה
כדי להפעיל מכונה שהופסקה:
המסוף
-
נכנסים לדף Cloud SQL Instances במסוף Google Cloud .
- כדי לפתוח את הדף Overview של מכונה, לוחצים על שם המכונה.
- לוחצים על התחלה.
- בתיבת הדו-שיח Start database instance?, לוחצים על Start.
מדיניות ההפעלה של המכונה מוגדרת כ-Always והמכונה מופעלת.
gcloud
משתמשים בערך ALWAYS במדיניות ההפעלה:
gcloud sql instances patch INSTANCE_NAME \ --activation-policy=ALWAYS
REST v1
לפני שמשתמשים בנתוני הבקשה, צריך להחליף את הנתונים הבאים:
- project-id: מזהה הפרויקט
- instance-id: מזהה המכונה
- activation-policy: מדיניות ההפעלה היא ALWAYS או NEVER
ה-method של ה-HTTP וכתובת ה-URL:
PATCH https://sqladmin.googleapis.com/v1/projects/project-id/instances/instance-id
תוכן בקשת JSON:
{
"settings": {
"activationPolicy": "activation-policy"
}
}
כדי לשלוח את הבקשה צריך להרחיב אחת מהאפשרויות הבאות:
אתם אמורים לקבל תגובת JSON שדומה לזו:
{
"kind": "sql#operation",
"targetLink": "https://sqladmin.googleapis.com/v1/projects/project-id/instances/instance-id",
"status": "PENDING",
"user": "user@example.com",
"insertTime": "2020-01-20T21:30:35.667Z",
"operationType": "UPDATE",
"name": "operation-id",
"targetId": "instance-id",
"selfLink": "https://sqladmin.googleapis.com/v1/projects/project-id/operations/operation-id",
"targetProject": "project-id"
}
REST v1beta4
לפני שמשתמשים בנתוני הבקשה, צריך להחליף את הנתונים הבאים:
- project-id: מזהה הפרויקט
- instance-id: מזהה המכונה
- activation-policy: מדיניות ההפעלה היא ALWAYS או NEVER
ה-method של ה-HTTP וכתובת ה-URL:
PATCH https://sqladmin.googleapis.com/sql/v1beta4/projects/project-id/instances/instance-id
תוכן בקשת JSON:
{
"settings": {
"activationPolicy": "activation-policy"
}
}
כדי לשלוח את הבקשה צריך להרחיב אחת מהאפשרויות הבאות:
אתם אמורים לקבל תגובת JSON שדומה לזו:
{
"kind": "sql#operation",
"targetLink": "https://sqladmin.googleapis.com/sql/v1beta4/projects/project-id/instances/instance-id",
"status": "PENDING",
"user": "user@example.com",
"insertTime": "2020-01-20T21:30:35.667Z",
"operationType": "UPDATE",
"name": "operation-id",
"targetId": "instance-id",
"selfLink": "https://sqladmin.googleapis.com/sql/v1beta4/projects/project-id/operations/operation-id",
"targetProject": "project-id"
}
עצירת מכונה
אפשר לעצור מכונה באופן ידני לפי הצורך. כשעוצרים מכונה, היא נשארת במצב עצירה ולא מגיבה לחיבורים של אפליקציות עד שמפעילים אותה מחדש.
כשעוצרים מכונה, החיובים עליה מושעים. נתוני המכונה לא מושפעים, והחיובים על אחסון וכתובות IP ממשיכים לחול.
כדי לעצור מכונה:
המסוף
-
נכנסים לדף Cloud SQL Instances במסוף Google Cloud .
- כדי לפתוח את הדף Overview של מכונה, לוחצים על שם המכונה.
- לוחצים על הפסקה.
- בתיבת הדו-שיח Stop database instance? לוחצים על Stop.
מדיניות ההפעלה של המכונה מוגדרת כ-
Off(אף פעם) והמכונה נעצרה.
gcloud
gcloud sql instances patch INSTANCE_NAME \ --activation-policy=NEVER
REST v1
לפני שמשתמשים בנתוני הבקשה, צריך להחליף את הנתונים הבאים:
- project-id: מזהה הפרויקט
- instance-id: מזהה המכונה
- activation-policy: מדיניות ההפעלה היא NEVER
ה-method של ה-HTTP וכתובת ה-URL:
PATCH https://sqladmin.googleapis.com/v1/projects/project-id/instances/instance-id
תוכן בקשת JSON:
{
"settings": {
"activationPolicy": "activation-policy"
}
}
כדי לשלוח את הבקשה צריך להרחיב אחת מהאפשרויות הבאות:
אתם אמורים לקבל תגובת JSON שדומה לזו:
{
"kind": "sql#operation",
"targetLink": "https://sqladmin.googleapis.com/v1/projects/project-id/instances/instance-id",
"status": "PENDING",
"user": "user@example.com",
"insertTime": "2020-01-20T21:30:35.667Z",
"operationType": "UPDATE",
"name": "operation-id",
"targetId": "instance-id",
"selfLink": "https://sqladmin.googleapis.com/v1/projects/project-id/operations/operation-id",
"targetProject": "project-id"
}
REST v1beta4
לפני שמשתמשים בנתוני הבקשה, צריך להחליף את הנתונים הבאים:
- project-id: מזהה הפרויקט
- instance-id: מזהה המכונה
- activation-policy: מדיניות ההפעלה היא NEVER
ה-method של ה-HTTP וכתובת ה-URL:
PATCH https://sqladmin.googleapis.com/sql/v1beta4/projects/project-id/instances/instance-id
תוכן בקשת JSON:
{
"settings": {
"activationPolicy": "activation-policy"
}
}
כדי לשלוח את הבקשה צריך להרחיב אחת מהאפשרויות הבאות:
אתם אמורים לקבל תגובת JSON שדומה לזו:
{
"kind": "sql#operation",
"targetLink": "https://sqladmin.googleapis.com/sql/v1beta4/projects/project-id/instances/instance-id",
"status": "PENDING",
"user": "user@example.com",
"insertTime": "2020-01-20T21:30:35.667Z",
"operationType": "UPDATE",
"name": "operation-id",
"targetId": "instance-id",
"selfLink": "https://sqladmin.googleapis.com/sql/v1beta4/projects/project-id/operations/operation-id",
"targetProject": "project-id"
}
הפעלה מחדש של מכונה
הפעלה מחדש של מכונה מרוקנת את החיבורים מהמכונה ועוצרת אותה. לאחר מכן, המכונה מופעלת מחדש ומוכנה לקבל חיבורים חדשים.
הפעלה מחדש של מכונה לא משנה את כתובות ה-IP הציבוריות או הפרטיות שלה.
כדי להפעיל מחדש מכונה:
המסוף
-
נכנסים לדף Cloud SQL Instances במסוף Google Cloud .
- כדי לפתוח את הדף Overview של מכונה, לוחצים על שם המכונה.
- לוחצים על הפעלה מחדש.
- בתיבת הדו-שיח Restart database instance?, לוחצים על Restart.
gcloud
מפעילים מחדש את המכונה:
gcloud sql instances restart INSTANCE_NAME
REST v1
לפני שמשתמשים בנתוני הבקשה, צריך להחליף את הנתונים הבאים:
- project-id: מזהה הפרויקט
- instance-id: מזהה המכונה
- activation-policy: מדיניות ההפעלה היא ALWAYS או NEVER
ה-method של ה-HTTP וכתובת ה-URL:
POST https://sqladmin.googleapis.com/v1/projects/project-id/instances/instance-id/restart
תוכן בקשת JSON:
{
"settings": {
"activationPolicy": "activation-policy"
}
}
כדי לשלוח את הבקשה צריך להרחיב אחת מהאפשרויות הבאות:
אתם אמורים לקבל תגובת JSON שדומה לזו:
{
"kind": "sql#operation",
"targetLink": "https://sqladmin.googleapis.com/v1/projects/project-id/instances/instance-id",
"status": "PENDING",
"user": "user@example.com",
"insertTime": "2020-01-20T21:30:35.667Z",
"operationType": "RESTART",
"name": "operation-id",
"targetId": "instance-id",
"selfLink": "https://sqladmin.googleapis.com/v1/projects/project-id/operations/operation-id",
"targetProject": "project-id"
}
REST v1beta4
לפני שמשתמשים בנתוני הבקשה, צריך להחליף את הנתונים הבאים:
- project-id: מזהה הפרויקט
- instance-id: מזהה המכונה
- activation-policy: מדיניות ההפעלה היא ALWAYS או NEVER
ה-method של ה-HTTP וכתובת ה-URL:
POST https://sqladmin.googleapis.com/sql/v1beta4/projects/project-id/instances/instance-id/restart
תוכן בקשת JSON:
{
"settings": {
"activationPolicy": "activation-policy"
}
}
כדי לשלוח את הבקשה צריך להרחיב אחת מהאפשרויות הבאות:
אתם אמורים לקבל תגובת JSON שדומה לזו:
{
"kind": "sql#operation",
"targetLink": "https://sqladmin.googleapis.com/sql/v1beta4/projects/project-id/instances/instance-id",
"status": "PENDING",
"user": "user@example.com",
"insertTime": "2020-01-20T21:30:35.667Z",
"operationType": "RESTART",
"name": "operation-id",
"targetId": "instance-id",
"selfLink": "https://sqladmin.googleapis.com/sql/v1beta4/projects/project-id/operations/operation-id",
"targetProject": "project-id"
}