
Before you begin
- Labs create a Google Cloud project and resources for a fixed time
- Labs have a time limit and no pause feature. If you end the lab, you'll have to restart from the beginning.
- On the top left of your screen, click Start lab to begin
Create a connection profile for the PostgreSQL source instance
/ 50
Test the continuous migration of data
/ 50
In Google Cloud, you can use Database Migration Service to migrate PostgreSQL databases to AlloyDB for PostgreSQL. To do this, AlloyDB requires the use of private services access. This access is implemented as a VPC peering connection between your VPC network and the underlying Google Cloud VPC network where your AlloyDB resources reside.
In this lab, you migrate a stand-alone PostgreSQL database (running on a virtual machine) to AlloyDB for PostgreSQL using a continuous Database Migration Service job with VPC peering for connectivity.
Migrating a database via Database Migration Service requires some preparation of the source database. Those tasks have been completed for you on the source environment with the most important being setting up the pglogical package on the source instance.
After you create and run the migration job, you confirm that an initial copy of your database has been successfully migrated to your AlloyDB for PostgreSQL instance. You also explore how continuous migration jobs apply data updates from your source database to your AlloyDB for PostgreSQL instance.
In this lab, you learn how to configure a continuous Database Migration Service job to migrate databases from a PostgreSQL instance to AlloyDB for PostgreSQL.
Read these instructions. Labs are timed and you cannot pause them. The timer, which starts when you click Start Lab, shows how long Google Cloud resources are made available to you.
This hands-on lab lets you do the lab activities in a real cloud environment, not in a simulation or demo environment. It does so by giving you new, temporary credentials you use to sign in and access Google Cloud for the duration of the lab.
To complete this lab, you need:
Click the Start Lab button. If you need to pay for the lab, a dialog opens for you to select your payment method. On the left is the Lab Details pane with the following:
Click Open Google Cloud console (or right-click and select Open Link in Incognito Window if you are running the Chrome browser).
The lab spins up resources, and then opens another tab that shows the Sign in page.
Tip: Arrange the tabs in separate windows, side-by-side.
If necessary, copy the Username below and paste it into the Sign in dialog.
You can also find the Username in the Lab Details pane.
Click Next.
Copy the Password below and paste it into the Welcome dialog.
You can also find the Password in the Lab Details pane.
Click Next.
Click through the subsequent pages:
After a few moments, the Google Cloud console opens in this tab.
Cloud Shell is a virtual machine that is loaded with development tools. It offers a persistent 5GB home directory and runs on the Google Cloud. Cloud Shell provides command-line access to your Google Cloud resources.
Click Activate Cloud Shell at the top of the Google Cloud console.
Click through the following windows:
When you are connected, you are already authenticated, and the project is set to your Project_ID,
gcloud
is the command-line tool for Google Cloud. It comes pre-installed on Cloud Shell and supports tab-completion.
Output:
Output:
gcloud
, in Google Cloud, refer to the gcloud CLI overview guide.
In this step connect to and verify data in the postgres database on the pg14-source VM Instance.
On the Navigation menu (), under Compute Engine click VM instances.
For the instance named pg14-source, in the Connect column, click SSH to open a terminal window.
Use the following command to launch the PostgreSQL (psql) client.
Name | Rows |
---|---|
countries | 25 |
departments | 27 |
employees | 107 |
jobs | 19 |
locations | 23 |
regions | 4 |
Type \q to exit the psql client.
Type exit to close the terminal window.
In this task, you will create a connection profile for the PostgreSQL source instance.
In this step, you identify the internal IP address of the source database instance that you will migrate to AlloyDB.
On the Navigation menu (), under Compute Engine click VM instances.
Locate the line for the instance pg14-source.
Copy the value for the Internal IP (e.g., 10.128.15.208).
A connection profile stores information about the source database instance (e.g., stand-alone PostgreSQL) and is used by the Database Migration Service to migrate data from the source to your destination AlloyDB for PostgreSQL instance. After you create a connection profile, it can be reused across migration jobs.
In this step you will create a new connection profile for the PostgreSQL source instance.
In the Google Cloud Console, on the Navigation menu (), click on View All products under Databases section click Database Migration > Connection profiles.
Click + Create Profile.
For Profile Role, select Source.
For Database engine, select PostgreSQL.
For Connection profile name, enter pg14-source.
For Region select
Under Define connection configurations click on DEFINE
For Hostname or IP address, enter the internal IP for the PostgreSQL source instance that you copied in the previous task (e.g., 10.128.15.208)
For Port, enter 5432.
For Username, enter postgres.
For Password, enter Change3Me.
For all other values leave the defaults.
Click Save
Click Create.
A new connection profile named pg14-source will appear in the Connections profile list.
When you create a new migration job, you first define the source database instance using a previously created connection profile. Then you create a new destination database instance and configure connectivity between the source and destination instances.
In this task, you use the migration job interface to create a new AlloyDB for PostgreSQL cluster and set it as the destination for the continuous migration job from the PostgreSQL source instance.
In this step you will create a new continuous migration job.
In the Google Cloud Console, on the Navigation menu (), click on View All products under Databases section click Database Migration > Migration jobs.
Click + Create Migration Job.
For Migration job name, enter postgres-to-alloydb.
For Source database engine, select PostgreSQL.
For Destination database engine, select AlloyDB for PostgreSQL.
For Destination region, select
At the moment, Continuous is the only option available Migration job type for PostgreSQL to AlloyDB.
Leave the defaults for the other settings.
Click Save & Continue.
In this step, you will define the source instance for the migration.
For Select source connection profile, select the pg14-source connection profile you created a few steps ago.
Click Save & Continue.
In this step, the DMS wizard will create the AlloyDB cluster and instance on your behalf.
For Type of destination cluster, there is the already option selected is New cluster.
Click Continue for Review the cluster configuration.
For Cluster ID, enter alloydb-target-cluster.
For Password, enter Change3Me.
For Network, select peering-network.
Click Continue.
For Instance ID, enter alloydb-target-instance.
Select 2 vCPU, 16 GB as your machine type.
Click Save & Continue.
On the pop-up window, Click Create Destination & Continue to continue.
While your AlloyDB instance and cluster are being created, you can choose VPC peering from the Connectivity method list of options.
Please wait until the cluster and instance are complete. The Configure & Continue link will be available once the database is available.
Click Configure & Continue.
On the Select objects to migrate page, under Databases to migrate, select All databases.
Click Save & Continue.
In this step, you will test and start the migration job.
The Database Migration Service wizard will now be on the Test and create your migration job step.
Click Test Job.
After a successful test, click Create & Start Job.
If prompted to confirm, click Create & Start.
In this step, you will confirm that the continuous migration job is running.
In the Google Cloud Console, on the Navigation menu (), click on View All products under Databases section click Database Migration > Migration jobs.
Click the migration job postgres-to-alloydb to see the details page.
Review the migration job status.
When the job status changes to Running CDC in progress, proceed to the next task.
On the Cloud Console Navigation menu (), click on View All products under Databases section click AlloyDB for PostgreSQL then Clusters to examine the cluster's details.
The cluster is named alloydb-target-cluster and the instance is named alloydb-target-cluster-primary.
Please make note of the Private IP address in the instances section. Copy the Private IP address to a text file so that you can paste the value in a later step.
On the Navigation menu (), under Compute Engine click VM instances.
For the instance named alloydb-client, in the Connect column, click SSH to open a terminal window.
Set the following environment variable, replacing ALLOYDB_ADDRESS with the Private IP address of the AlloyDB instance.
Name | Rows |
---|---|
countries | 25 |
departments | 27 |
employees | 107 |
jobs | 19 |
locations | 23 |
regions | 4 |
Because the Database Migration Service job is set in a continuous update configuration, any updates you make on the source instance will be applied to the AlloyDB target.
On the Navigation menu (), under Compute Engine click VM instances.
For the instance named pg14-source, in the Connect column, click SSH to open a terminal window.
Use the following command to launch the PostgreSQL (psql) client.
You have now successfully migrated a stand-alone PostgreSQL database (running on a virtual machine) to AlloyDB for PostgreSQL using a continuous Database Migration Service job.
Manual Last Updated February 14, 2025
Lab Last Tested February 14, 2025
Copyright 2025 Google LLC All rights reserved. Google and the Google logo are trademarks of Google LLC. All other company and product names may be trademarks of the respective companies with which they are associated.
このコンテンツは現在ご利用いただけません
利用可能になりましたら、メールでお知らせいたします
ありがとうございます。
利用可能になりましたら、メールでご連絡いたします
One lab at a time
Confirm to end all existing labs and start this one