Question

Difficulty: HardManaging Compute Engine Resources

A Cloud Engineer needs to migrate an existing standalone, stateful Compute Engine VM instance named 'prod-db-node' and its boot persistent disk from zone us-central1-a to zone us-central1-b due to a planned zone retirement. The database engine requires complete data consistency prior to taking storage backups. Which sequence of gcloud CLI actions correctly performs this zonal migration while ensuring data integrity?

  1. 1Stop the source VM instance 'prod-db-node' in zone us-central1-a to freeze disk I/O.
  2. 2Create a snapshot from the source VM's boot persistent disk 'prod-db-node-disk'.
  3. 3Create a new zonal persistent disk in us-central1-b specifying the snapshot as the source.
  4. 4Provision a new VM instance in us-central1-b attaching the newly created disk as the boot disk.

Answer

The correct operational sequence to migrate a stateful Compute Engine instance to a new zone is: 1) Stop the source instance in us-central1-a to ensure disk consistency. 2) Take a snapshot of the boot persistent disk. 3) Provision a new persistent disk in target zone us-central1-b using the snapshot as source. 4) Launch a new Compute Engine instance in us-central1-b attached to the restored persistent disk as its boot disk.
Because Compute Engine Persistent Disks are bound to a single zone, migrating a stateful VM to another zone requires creating a new persistent disk in the target zone. The proper workflow starts with stopping the VM instance to guarantee data consistency, capturing a project-wide persistent disk snapshot, instantiating a new persistent disk in target zone us-central1-b using the snapshot as a source, and finally launching a new Compute Engine VM in us-central1-b referencing the new disk as its boot disk.

Step-by-Step Solution

1
Execute `gcloud compute instances stop prod-db-node --zone=us-central1-a`
The virtual machine transitions to the TERMINATED state, stopping all write operations to the persistent disk.
Stopping the database VM ensures unwritten data in buffer cache is flushed, avoiding data corruption in the snapshot.
2
Execute `gcloud compute disks snapshot prod-db-node-disk --zone=us-central1-a --snapshot-names=prod-db-snapshot`
A project-level persistent disk snapshot is generated from the consistent disk state.
Persistent Disks are zonal resources, but disk snapshots are available project-wide across all zones.
3
Execute `gcloud compute disks create prod-db-node-disk-b --zone=us-central1-b --source-snapshot=prod-db-snapshot`
A new zonal persistent disk containing the source data is created in us-central1-b.
Disks cannot be directly moved or re-attached across zones without recreating them in the target zone from a snapshot.
4
Execute `gcloud compute instances create prod-db-node --zone=us-central1-b --disk=name=prod-db-node-disk-b,boot=yes`
The newly provisioned instance boots up in us-central1-b with all original data intact.
Attaching the new zonal disk as the primary boot device restores the workload in the target zone.

Key Concept

Cross-Zone Compute Engine Persistent Disk Migration
Estimated Time:2m 0s
Rate this question