Google uses AI technology to translate content into your preferred language. AI translations can contain errors.
インスタンスのストレージ容量を縮小する
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
このページでは、ストレージ縮小機能を使用して Cloud SQL インスタンスのストレージ容量を管理する方法について説明します。
始める前に
機能の制限事項を確認します。
gcloud CLI を使用している場合は、Google Cloud SDK と gcloud CLI の最新バージョンを使用していることを確認してください。
- gcloud CLI の最新バージョンをインストールします(gcloud CLI バージョン 563.0.0 以降)。
- 現在の gcloud CLI のバージョンを取得するには、
gcloud --version を実行します。
- gcloud CLI のバージョンを更新するには、
gcloud components update を実行します。
次の IAM 権限を取得します。
cloudsql.instances.getDiskShrinkConfig
cloudsql.instances.performDiskShrink
これらの権限は、次のいずれかのロールで使用できます。ロールを割り当てる際は、最小権限の原則を適用することをおすすめします。
- Cloud SQL 管理者(
roles/cloudsql.admin)
- Cloud SQL 編集者(
roles/cloudsql.editor)
詳しくは、次のリソースをご覧ください。
インスタンスを準備する
始める前に、次の要件を満たしてください。
これらの手順は、プライマリ インスタンスとリードレプリカで同じです。
リードレプリカを更新する場合は、まずプライマリ インスタンスの容量を縮小してから、レプリカのサイズを縮小してください。
管理するインスタンスを含むプロジェクトのプロジェクト ID を取得します。
インスタンスの現在の状態を確認して、実行されていることを確認します。確認方法の 1 つは、describe コマンドを使用することです。
gcloud sql instances describe
次のステータスを返します。
RUNNABLE
実行されていない場合は、インスタンスを起動します。
現在のインスタンスのバックアップを作成します。これにより、構成中に問題が発生した場合に、後でインスタンスを復元できます。
PostgreSQL インスタンスを実行している場合は、max_wal_size フラグの値を 5, 128 MB 未満に設定します。max_wal_size の値が大きすぎると、インスタンスの起動が遅くなり、オペレーションが失敗する可能性があります。
アウトバウンド接続を有効にする(またはアウトバウンド データ転送を必要とする)拡張機能または機能をすべて無効にします。たとえば、これらの拡張機能または機能のいずれかを使用してアウトバウンド接続が確立されている場合、ストレージ縮小オペレーションを実行する前に、その接続を無効にする必要があります。
dblink 拡張機能
PL/proxy 拡張機能
pglogical 拡張機能
- 外部データラッパー(
postgres_fdw、oracle_fdw、tds_fdw など)
- PostgreSQL 10 以降の論理レプリケーション
インスタンスのストレージ容量を縮小する
次の手順は、プライマリ インスタンスとリードレプリカで同じです。
インスタンスの目標最小ストレージ容量と推定オペレーション時間を確認します。この情報は、ストレージの縮小オペレーションを計画する際に役立ちます。
gcloud
gcloud sql instances get-storage-shrink-config コマンドを実行します。
gcloud sql instances get-storage-shrink-config INSTANCE_NAME
次のように置き換えます。
- INSTANCE_NAME: プライマリ インスタンスの名前。
レスポンスには minimalTargetSizeGb の値が含まれます。この値を使用して、ストレージ縮小オペレーションを実行するときに --storage-size パラメータに使用する値を決定できます。
レスポンスには、次のような推定オペレーション時間を含むメッセージも返されます。
...
"The estimated operation time is 20 minutes".
REST v1
GET メソッドを使用して、インスタンスの最小ストレージ容量の目標値を取得します。
リクエストのデータを使用する前に、次のように置き換えます。
- PROJECT_ID: プライマリ インスタンスが存在するプロジェクトの名前。
- INSTANCE_ID: プライマリ インスタンスのインスタンス ID。
HTTP メソッドと URL:
GET https://sqladmin.googleapis.com/v1/projects/PROJECT_ID/instances/INSTANCE_ID/getDiskShrinkConfig
リクエストを送信するには、次のいずれかのオプションを展開します。
curl(Linux、macOS、Cloud Shell)
次のコマンドを実行します。
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://sqladmin.googleapis.com/v1/projects/PROJECT_ID/instances/INSTANCE_ID/getDiskShrinkConfig"
PowerShell(Windows)
次のコマンドを実行します。
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://sqladmin.googleapis.com/v1/projects/PROJECT_ID/instances/INSTANCE_ID/getDiskShrinkConfig" | Select-Object -Expand Content
次のような JSON レスポンスが返されます。
レスポンス
{
"kind": "sql#instance",
"min_target_size_gb": "1234"
"message": "The size of your instance's storage impacts IOPS, and therefore shrinking your storage
may have a negative impact on IOPS. Before shrinking your storage, please refer to our
documentation on Cloud SQL limits to understand what impact shrinking your storage might have:
https://cloud.google.com/sql/docs/quotas#fixed-limits. Additionally, we recommend leaving an
appropriate buffer for operational purposes, like reindexing, etc. We recommend a buffer of at
least 100 GB or 20% more than current usage, whichever is larger. For more details, please refer
to: https://cloud.google.com/sql/docs/shared-responsibility. The estimated operation time is
20 minutes."
}
レスポンスには min_target_size_gb の値が含まれます。この値を使用して、ストレージ縮小オペレーションを実行するときに --storage-size パラメータに使用する値を決定できます。
レスポンスには、次のような推定オペレーション時間を含むメッセージも返されます。
...
"The estimated operation time is 20 minutes".
REST v1beta4
GET メソッドを使用して、インスタンスの最小ストレージ容量の目標値を取得します。
リクエストのデータを使用する前に、次のように置き換えます。
- PROJECT_ID: プライマリ インスタンスが存在するプロジェクトの名前。
- INSTANCE_ID: プライマリ インスタンスのインスタンス ID。
HTTP メソッドと URL:
GET https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID/instances/INSTANCE_ID/getDiskShrinkConfig
リクエストを送信するには、次のいずれかのオプションを展開します。
curl(Linux、macOS、Cloud Shell)
次のコマンドを実行します。
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID/instances/INSTANCE_ID/getDiskShrinkConfig"
PowerShell(Windows)
次のコマンドを実行します。
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID/instances/INSTANCE_ID/getDiskShrinkConfig" | Select-Object -Expand Content
次のような JSON レスポンスが返されます。
レスポンス
{
"kind": "sql#instance",
"min_target_size_gb": "1234"
"message": "The size of your instance's storage impacts IOPS, and therefore shrinking your storage
may have a negative impact on IOPS. Before shrinking your storage, please refer to our
documentation on Cloud SQL limits to understand what impact shrinking your storage might have:
https://cloud.google.com/sql/docs/quotas#fixed-limits. Additionally, we recommend leaving an
appropriate buffer for operational purposes, like reindexing, etc. We recommend a buffer of at
least 100 GB or 20% more than current usage, whichever is larger. For more details, please refer
to: https://cloud.google.com/sql/docs/shared-responsibility. The estimated operation time is
20 minutes."
}
レスポンスには min_target_size_gb の値が含まれます。この値を使用して、ストレージ縮小オペレーションを実行するときに --storage-size パラメータに使用する値を決定できます。
レスポンスには、次のような推定オペレーション時間を含むメッセージも返されます。
...
"The estimated operation time is 20 minutes".
インスタンスのストレージ容量を縮小します。
gcloud
次のコマンドを実行して、インスタンスのストレージを縮小します。
gcloud sql instances perform-storage-shrink INSTANCE_NAME \
--storage-size=TARGET_STORAGE_SIZE
次のように置き換えます。
- INSTANCE_NAME: インスタンスの名前。
- TARGET_STORAGE_SIZE: 目標ストレージ容量(GB)。たとえば、100 GB。
REST v1
リクエストのデータを使用する前に、次のように置き換えます。
- PROJECT_ID: インスタンスが存在するプロジェクトの ID。
- INSTANCE_ID: インスタンスの ID。
- TARGET_STORAGE_SIZE: ターゲット ストレージのサイズ(GB)。
HTTP メソッドと URL:
POST https://sqladmin.googleapis.com/v1/projects/PROJECT_ID/instances/INSTANCE_ID/performDiskShrink
リクエストの本文(JSON):
{
"targetSizeGb": TARGET_STORAGE_SIZE
}
リクエストを送信するには、次のいずれかのオプションを展開します。
curl(Linux、macOS、Cloud Shell)
リクエスト本文を request.json という名前のファイルに保存して、次のコマンドを実行します。
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://sqladmin.googleapis.com/v1/projects/PROJECT_ID/instances/INSTANCE_ID/performDiskShrink"
PowerShell(Windows)
リクエスト本文を request.json という名前のファイルに保存して、次のコマンドを実行します。
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://sqladmin.googleapis.com/v1/projects/PROJECT_ID/instances/INSTANCE_ID/performDiskShrink" | Select-Object -Expand Content
次のような JSON レスポンスが返されます。
レスポンス
{
"kind": "sql#operation",
"targetLink": "https://sqladmin.googleapis.com/v1/projects/PROJECT_ID/instances/INSTANCE_ID",
"status": "PENDING",
"user": "user@example.com",
"insertTime": "2019-09-25T22:19:33.735Z",
"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: インスタンスが存在するプロジェクトの ID。
- INSTANCE_ID: インスタンスの ID。
- TARGET_STORAGE_SIZE: インスタンスのターゲット ストレージ サイズ。
HTTP メソッドと URL:
POST https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID/instances/INSTANCE_ID/performDiskShrink
リクエストの本文(JSON):
{
"targetSizeGb": TARGET_STORAGE_SIZE
}
リクエストを送信するには、次のいずれかのオプションを展開します。
curl(Linux、macOS、Cloud Shell)
リクエスト本文を request.json という名前のファイルに保存して、次のコマンドを実行します。
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID/instances/INSTANCE_ID/performDiskShrink"
PowerShell(Windows)
リクエスト本文を request.json という名前のファイルに保存して、次のコマンドを実行します。
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID/instances/INSTANCE_ID/performDiskShrink" | Select-Object -Expand Content
次のような JSON レスポンスが返されます。
レスポンス
{
"kind": "sql#operation",
"targetLink": "https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID/instances/INSTANCE_ID",
"status": "PENDING",
"user": "user@example.com",
"insertTime": "2019-09-25T22:19:33.735Z",
"operationType": "UPDATE",
"name": "operation-id",
"targetId": "INSTANCE_ID",
"selfLink": "https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID/operations/operation-id",
"targetProject": "PROJECT_ID"
}
ストレージ縮小オペレーションのステータスを確認するには、オペレーションのステータスを確認するをご覧ください。
ストレージの縮小オペレーションをキャンセルする
ストレージ縮小オペレーション ID を取得します。
オペレーション ID は、次の list コマンドを実行して取得できます。
gcloud sql operations list
キャンセル リクエストを送信します。
gcloud
次のコマンドを実行して、リクエストをキャンセルします。
gcloud sql operations cancel OPERATION_ID
次のように置き換えます。
OPERATION_ID: キャンセルするストレージ縮小オペレーションの ID。
REST v1
リクエストのデータを使用する前に、次のように置き換えます。
- PROJECT_ID: インスタンスが存在するプロジェクトの ID。
- OPERATION_ID: キャンセルするストレージ縮小オペレーションの ID。
HTTP メソッドと URL:
POST https://sqladmin.googleapis.com/v1/projects/PROJECT_ID/operations/OPERATION_ID/cancel
リクエストを送信するには、次のいずれかのオプションを展開します。
curl(Linux、macOS、Cloud Shell)
次のコマンドを実行します。
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d "" \
"https://sqladmin.googleapis.com/v1/projects/PROJECT_ID/operations/OPERATION_ID/cancel"
PowerShell(Windows)
次のコマンドを実行します。
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-Uri "https://sqladmin.googleapis.com/v1/projects/PROJECT_ID/operations/OPERATION_ID/cancel" | Select-Object -Expand Content
成功したことを示すステータス コード(2xx)と空のレスポンスが返されます。
REST v1beta4
リクエストのデータを使用する前に、次のように置き換えます。
- PROJECT_ID: インスタンスが存在するプロジェクトの ID。
- OPERATION_ID: キャンセルするストレージ縮小オペレーションの ID。
HTTP メソッドと URL:
POST https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID/operations/OPERATION_ID/cancel
リクエストを送信するには、次のいずれかのオプションを展開します。
curl(Linux、macOS、Cloud Shell)
次のコマンドを実行します。
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d "" \
"https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID/operations/OPERATION_ID/cancel"
PowerShell(Windows)
次のコマンドを実行します。
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-Uri "https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID/operations/OPERATION_ID/cancel" | Select-Object -Expand Content
成功したことを示すステータス コード(2xx)と空のレスポンスが返されます。
解約リクエストやその他の操作のステータスを確認する
リクエストのステータスを確認するには、次のコマンドを実行します。
gcloud
キャンセル リクエストのオペレーション ID を取得します。
gcloud sql operations list
オペレーションのステータスを確認します。
gcloud sql operations describe OPERATION_ID
次のように置き換えます。
OPERATION_ID: 確認するオペレーションの ID。
REST v1
リクエストのデータを使用する前に、次のように置き換えます。
- PROJECT_ID: インスタンスが存在するプロジェクトの名前。
- OPERATION_ID: ストレージ縮小オペレーションの ID。
HTTP メソッドと URL:
GET https://sqladmin.googleapis.com/v1/projects/PROJECT_ID/operations/OPERATION_ID
リクエストを送信するには、次のいずれかのオプションを展開します。
curl(Linux、macOS、Cloud Shell)
次のコマンドを実行します。
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://sqladmin.googleapis.com/v1/projects/PROJECT_ID/operations/OPERATION_ID"
PowerShell(Windows)
次のコマンドを実行します。
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://sqladmin.googleapis.com/v1/projects/PROJECT_ID/operations/OPERATION_ID" | Select-Object -Expand Content
次のような JSON レスポンスが返されます。
レスポンス
{
"kind": "sql#operation",
"targetLink": "https://sqladmin.googleapis.com/v1/projects/PROJECT_ID/instances/INSTANCE_ID",
"status": "RUNNING",
"user": "user@example.com",
"insertTime": "2023-12-18T22:43:09.849Z",
"startTime": "2023-12-18T22:43:10.373Z",
"operationType": "UPDATE",
"name": "OPERATION_ID",
"targetId": "example_instance",
"selfLink": "https://sqladmin.googleapis.com/v1/projects/PROJECT_ID/operations/OPERATION_ID",
"targetProject": "PROJECT_ID"
}
REST v1beta4
リクエストのデータを使用する前に、次のように置き換えます。
- PROJECT_ID: インスタンスが存在するプロジェクトの名前。
- OPERATION_ID: ストレージ縮小オペレーションの ID。
HTTP メソッドと URL:
GET https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID/operations/OPERATION_ID
リクエストを送信するには、次のいずれかのオプションを展開します。
curl(Linux、macOS、Cloud Shell)
次のコマンドを実行します。
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID/operations/OPERATION_ID"
PowerShell(Windows)
次のコマンドを実行します。
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID/operations/OPERATION_ID" | Select-Object -Expand Content
次のような JSON レスポンスが返されます。
レスポンス
{
"kind": "sql#operation",
"targetLink": "https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID/instances/INSTANCE_ID",
"status": "RUNNING",
"user": "user@example.com",
"insertTime": "2023-12-18T22:43:09.849Z",
"startTime": "2023-12-18T22:43:10.373Z",
"operationType": "UPDATE",
"name": "OPERATION_ID",
"targetId": "example_instance",
"selfLink": "https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID/operations/OPERATION_ID",
"targetProject": "PROJECT_ID"
}
トラブルシューティング
トラブルシューティングについては、ストレージ容量の更新に関する問題をご覧ください。
次のステップ
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2026-05-16 UTC。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["わかりにくい","hardToUnderstand","thumb-down"],["情報またはサンプルコードが不正確","incorrectInformationOrSampleCode","thumb-down"],["必要な情報 / サンプルがない","missingTheInformationSamplesINeed","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2026-05-16 UTC。"],[],[]]