このドキュメントでは、Compute Engine インスタンスを再起動またはリセットする方法について説明します。インスタンスのリセットの影響と、インスタンスの一時停止、停止、リセットの違いについては、Compute Engine インスタンスを一時停止、停止、リセットするをご覧ください。
インスタンスを再起動またはリセットすると、最適なパフォーマンスと安定性を確保できます。また、ゲスト オペレーティング システム(OS)のフリーズ、遅延、クラッシュなどの問題を解決できます。インスタンスのゲスト OS の状態に応じて、次のいずれかを行います。
インスタンスを再起動します。ゲスト OS が遅い場合やフリーズしている場合は、再起動すると、シャットダウンする前に実行中のタスクを完了するのに十分な時間があります。
インスタンスをリセットします。ゲスト OS がクラッシュしたか応答せず、他に方法がない場合にのみ、インスタンスをリセットします。インスタンスをリセットしても、ゲスト OS をクリーン シャットダウンすることはできません。この操作を行うと、保存されていないデータが破棄され、ディスクのファイルシステムが破損する可能性があります。
始める前に
-
まだ設定していない場合は、認証を設定します。認証とは、 Google Cloud サービスと API にアクセスするために ID を確認するプロセスです。ローカル開発環境からコードまたはサンプルを実行するには、次のいずれかのオプションを選択して Compute Engine に対する認証を行います。
Select the tab for how you plan to use the samples on this page:
Console
When you use the Google Cloud console to access Google Cloud services and APIs, you don't need to set up authentication.
gcloud
-
Install the Google Cloud CLI, then initialize it by running the following command:
gcloud init
- Set a default region and zone.
- Install the Google Cloud CLI.
-
To initialize the gcloud CLI, run the following command:
gcloud init
-
If you're using a local shell, then create local authentication credentials for your user account:
gcloud auth application-default login
You don't need to do this if you're using Cloud Shell.
If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.
- Install the Google Cloud CLI.
-
To initialize the gcloud CLI, run the following command:
gcloud init
-
If you're using a local shell, then create local authentication credentials for your user account:
gcloud auth application-default login
You don't need to do this if you're using Cloud Shell.
If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.
- Install the Google Cloud CLI.
-
To initialize the gcloud CLI, run the following command:
gcloud init
-
If you're using a local shell, then create local authentication credentials for your user account:
gcloud auth application-default login
You don't need to do this if you're using Cloud Shell.
If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.
- Install the Google Cloud CLI.
-
To initialize the gcloud CLI, run the following command:
gcloud init
-
If you're using a local shell, then create local authentication credentials for your user account:
gcloud auth application-default login
You don't need to do this if you're using Cloud Shell.
If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.
- Install the Google Cloud CLI.
-
To initialize the gcloud CLI, run the following command:
gcloud init
-
If you're using a local shell, then create local authentication credentials for your user account:
gcloud auth application-default login
You don't need to do this if you're using Cloud Shell.
If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.
-
インスタンスをリセットするには:
compute.instances.reset
-
ゲスト OS 内からインスタンスを再起動するには:
compute.instances.setMetadata
まだインスタンスに接続していない場合は、インスタンスに接続します。
インスタンスを再起動するには、次のコマンドを実行します。
sudo reboot
まだインスタンスに接続していない場合は、次のいずれかの方法でインスタンスに接続します。
インスタンスを再起動するには、次のコマンドを実行します。
shutdown /r /t 0
省略可: インスタンスのシャットダウンと再起動のプロセスをモニタリングするには、Windows ブート マネージャーのメニューを有効にします。
Google Cloud コンソールで [VM インスタンス] ページに移動します。
リセットするインスタンスを選択します。
[リセット] をクリックし、[リセット] をクリックして確定します。
INSTANCE_NAMES
: インスタンス名の空白区切りリスト(例:instance-01 instance-02 instance-03
)。ZONE
: インスタンスが配置されているゾーン。INSTANCE_NAME
: インスタンスの名前。PROJECT_ID
: インスタンスが配置されているプロジェクトの ID。ZONE
: インスタンスが配置されているゾーン。
Go
ローカル開発環境でこのページの Go サンプルを使用するには、gcloud CLI をインストールして初期化し、ユーザー認証情報を使用してアプリケーションのデフォルト認証情報を設定します。
詳細については Set up authentication for a local development environment をご覧ください。
Java
ローカル開発環境でこのページの Java サンプルを使用するには、gcloud CLI をインストールして初期化し、ユーザー認証情報を使用してアプリケーションのデフォルト認証情報を設定します。
詳細については Set up authentication for a local development environment をご覧ください。
Node.js
ローカル開発環境でこのページの Node.js サンプルを使用するには、gcloud CLI をインストールして初期化し、ユーザー認証情報を使用してアプリケーションのデフォルト認証情報を設定します。
詳細については Set up authentication for a local development environment をご覧ください。
PHP
ローカル開発環境でこのページの PHP サンプルを使用するには、gcloud CLI をインストールして初期化し、ユーザー認証情報を使用してアプリケーションのデフォルト認証情報を設定します。
詳細については Set up authentication for a local development environment をご覧ください。
Python
ローカル開発環境でこのページの Python サンプルを使用するには、gcloud CLI をインストールして初期化し、ユーザー認証情報を使用してアプリケーションのデフォルト認証情報を設定します。
詳細については Set up authentication for a local development environment をご覧ください。
REST
このページの REST API サンプルをローカル開発環境で使用するには、gcloud CLI に指定した認証情報を使用します。
Install the Google Cloud CLI, then initialize it by running the following command:
gcloud init
詳細については、 Google Cloud 認証ドキュメントの REST を使用して認証するをご覧ください。
必要なロール
Compute インスタンスのリセットと再起動に必要な権限を取得するには、インスタンスに対する Compute インスタンス管理者(v1) (
roles/compute.instanceAdmin.v1
)IAM ロールを付与するように管理者に依頼してください。ロールの付与については、プロジェクト、フォルダ、組織へのアクセス権の管理をご覧ください。この事前定義ロールには、コンピューティング インスタンスのリセットまたは再起動に必要な権限が含まれています。必要とされる正確な権限については、「必要な権限」セクションを開いてご確認ください。
必要な権限
コンピューティング インスタンスをリセットまたは再起動するには、次の権限が必要です。
カスタムロールや他の事前定義ロールを使用して、これらの権限を取得することもできます。
インスタンスを再起動する
コンピューティング インスタンスを再起動すると、Compute Engine が ACPI シャットダウン シグナルを送信する前に、インスタンス内のゲスト OS が実行中のタスクを完了できます。これにより、ゲスト OS のクリーン シャットダウンが確実に実行されます。
インスタンスを再起動すると、インスタンスで使用されているメモリが消去されます。インスタンスで RAM ディスクを使用していて、そのデータを保持する必要がある場合は、インスタンスを再起動する前にデータをバックアップします。
インスタンスを再起動するには、次のいずれかのオプションを選択します。
Linux
Windows
インスタンスのリセット
インスタンスをリセットすると、RAM ディスクに保存されている一時ファイルなど、インスタンスのメモリ内のすべてのデータが消去されます。このデータは完全に失われます。Compute Engine は、インスタンスをリセットする前にバックアップを作成しません。
複数のインスタンスを同時にリセットすることも、個々のインスタンスを再開することもできます。複数のインスタンスの場合は、Google Cloud コンソールを使用します。同じゾーンにあるインスタンスの場合は、Google Cloud CLI を使用します。個々のインスタンスの場合は、次のいずれかのオプションを選択します。
コンソール
gcloud
1 つのゾーンで実行中のインスタンスを 1 つ以上リセットするには、
gcloud compute instances reset
コマンドを使用します。gcloud compute instances reset INSTANCE_NAMES \ --zone=ZONE
次のように置き換えます。
Go
Java
Node.js
PHP
Python
REST
実行中のインスタンスをリセットするには、
instances.reset
メソッドにPOST
リクエストを送信します。POST https://compute.googleapis.com//compute/v1/projects/PROJECT_ID/zones/ZONE/instances/INSTANCE_NAME/reset
次のように置き換えます。
次のステップ
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-07-03 UTC。
-