איך מפעילים, עוצרים ומפעילים מחדש מכונות

בדף הזה מוסבר איך להפעיל מכונה, לעצור מכונה ולהפעיל מחדש מכונה שפועלת.

מדיניות הפעלה

כשמפעילים, עוצרים או מפעילים מחדש מכונה, צריך להגדיר מדיניות הפעלה. מדיניות ההפעלה מציינת אם המכונה מופעלת כדי לקבל בקשות חיבור.

אפשרויות מדיניות ההפעלה הן:

  • ‫ALWAYS – המכונה תמיד פועלת.
  • ‫NEVER – המכונה לא מופעלת מחדש.
מגדירים את מדיניות ההפעלה ל-ALWAYS. אם אתם לא משתמשים במכונה, אתם יכולים להגדיר את מדיניות ההפעלה שלה ל-NEVER כדי להימנע מחיובים על המכונה.

הפעלת מכונה

כדי להפעיל מכונה שהופסקה:

המסוף

  1. נכנסים לדף Cloud SQL Instances במסוף Google Cloud .

    כניסה לדף Cloud SQL Instances

  2. כדי לפתוח את הדף Overview של מכונה, לוחצים על שם המכונה.
  3. לוחצים על התחלה.
  4. בתיבת הדו-שיח 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"
}
כדי לראות איך בקשת ה-API הבסיסית בארכיטקטורת REST בנויה למשימה הזו, עיינו ב-APIs Explorer בדף instances:patch.

עצירת מכונה

אפשר לעצור מכונה באופן ידני לפי הצורך. כשעוצרים מכונה, היא נשארת במצב עצירה ולא מגיבה לחיבורים של אפליקציות עד שמפעילים אותה מחדש.

כשעוצרים מכונה, החיובים עליה מושעים. נתוני המכונה לא מושפעים, והחיובים על אחסון וכתובות IP ממשיכים לחול.

כדי לעצור מכונה:

המסוף

  1. נכנסים לדף Cloud SQL Instances במסוף Google Cloud .

    כניסה לדף Cloud SQL Instances

  2. כדי לפתוח את הדף Overview של מכונה, לוחצים על שם המכונה.
  3. לוחצים על הפסקה.
  4. בתיבת הדו-שיח 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"
}
כדי לראות איך בקשת ה-API הבסיסית בארכיטקטורת REST בנויה למשימה הזו, עיינו ב-APIs Explorer בדף instances:patch.

הפעלה מחדש של מכונה

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

הפעלה מחדש של מכונה לא משנה את כתובות ה-IP הציבוריות או הפרטיות שלה.

כדי להפעיל מחדש מכונה:

המסוף

  1. נכנסים לדף Cloud SQL Instances במסוף Google Cloud .

    כניסה לדף Cloud SQL Instances

  2. כדי לפתוח את הדף Overview של מכונה, לוחצים על שם המכונה.
  3. לוחצים על הפעלה מחדש.
  4. בתיבת הדו-שיח 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"
}
כדי לראות איך בקשת ה-API הבסיסית בארכיטקטורת REST בנויה למשימה הזו, עיינו ב-APIs Explorer בדף instances:restart.