Apa yang dimaksud dengan Database Migration Service?
Database Migration Service adalah layanan yang memudahkan Anda memigrasikan data ke Google Cloud. Database Migration Service membantu Anda melakukan lift-and-shift workload PostgreSQL ke Cloud SQL.
Database Migration Service mendukung migrasi PostgreSQL ke Cloud SQL di semua versi utama, dengan tujuan yang memiliki versi yang sama atau lebih tinggi daripada database sumber.
Komponen data, skema, dan metadata mana yang dimigrasikan?
Database Migration Service memigrasikan skema, data, dan metadata dari sumber ke tujuan. Semua
komponen data, skema, dan metadata berikut dimigrasikan sebagai bagian dari migrasi database:
Migrasi Data
Semua skema dan semua tabel dari database yang dipilih.
Migrasi Skema
Penamaan
Kunci utama
Jenis data
Posisi ordinal
Nilai default
Nullability
Atribut penambahan otomatis
Indeks sekunder
Migrasi Metadata
Prosedur Tersimpan
Functions
Pemicu
Dilihat
Batasan kunci asing
Perubahan mana yang direplikasi selama migrasi berkelanjutan?
Hanya perubahan DML yang otomatis diperbarui selama migrasi. Mengelola DDL agar database sumber dan
tujuan tetap kompatibel adalah tanggung jawab pengguna, dan dapat dilakukan dengan
dua cara:
Hentikan penulisan ke sumber dan jalankan perintah DDL di sumber dan tujuan. Sebelum
menjalankan perintah DDL di tujuan, berikan peran cloudsqlexternalsync kepada pengguna Cloud SQL yang menerapkan
perubahan DDL. Untuk mengaktifkan kueri atau mengubah data, berikan peran cloudsqlexternalsync kepada
pengguna Cloud SQL yang relevan.
Gunakan pglogical.replicate_ddl_command untuk menjalankan DDL di sumber dan tujuan pada titik yang konsisten. Pengguna yang menjalankan perintah ini harus memiliki nama pengguna yang sama di sumber dan tujuan, serta harus merupakan superuser atau pemilik artefak yang dimigrasikan (misalnya, tabel, urutan, tampilan, atau database).
Berikut beberapa contoh penggunaan pglogical.replicate_ddl_command.
Untuk menambahkan kolom ke tabel database, jalankan perintah berikut:
Untuk menambahkan pengguna ke instance tujuan Cloud SQL, buka instance dan tambahkan pengguna
dari tab Pengguna, atau tambahkan dari klien PostgreSQL. Pelajari lebih lanjut cara membuat
dan mengelola pengguna PostgreSQL.
Objek besar tidak dapat
direplikasi karena fasilitas decoding logis PostgreSQL tidak
mendukung perubahan decoding pada objek besar. Untuk tabel yang memiliki
oid jenis kolom yang mereferensikan objek
besar, baris masih disinkronkan, dan baris baru direplikasi. Namun, mencoba mengakses
objek besar di database tujuan
(baca menggunakan lo_get,
ekspor menggunakan lo_export, atau periksa
pg_largeobject katalog untuk oid yang diberikan), gagal dengan pesan yang menyatakan bahwa objek
besar tidak ada.
Untuk tabel yang tidak memiliki kunci utama, Database Migration Service mendukung migrasi snapshot awal dan pernyataan INSERT selama fase pengambilan data perubahan (CDC). Anda harus memigrasikan pernyataan UPDATE dan DELETE secara manual.
Database Migration Service tidak memigrasikan data dari tampilan yang diwujudkan, hanya skema tampilan. Untuk mengisi tampilan, jalankan perintah berikut: REFRESH MATERIALIZED VIEW view_name.
Status SEQUENCE (misalnya, last_value) di tujuan Cloud SQL baru mungkin berbeda dari status SEQUENCE sumber.
Metode jaringan mana yang digunakan?
Untuk membuat migrasi di Database Migration Service, konektivitas harus dibuat
antara sumber dan instance tujuan Cloud SQL. Ada berbagai metode yang didukung.
Pilih salah satu yang paling sesuai untuk beban kerja tertentu.
Metode jaringan
Deskripsi
Kelebihan
Kekurangan
Daftar IP yang diizinkan
Berfungsi dengan mengonfigurasi server database sumber agar dapat menerima koneksi dari IP publik
instance Cloud SQL. Jika Anda memilih metode ini, Database Migration Service akan memandu Anda melalui proses penyiapan selama pembuatan migrasi.
Mudah dikonfigurasi.
Direkomendasikan untuk skenario migrasi berumur pendek (POC atau migrasi database kecil).
Konfigurasi firewall mungkin memerlukan bantuan dari IT.
Mengekspos database sumber ke IP publik.
Koneksi tidak dienkripsi secara default. Memerlukan pengaktifan SSL di database sumber
untuk mengenkripsi koneksi.
Tunnel SSH terbalik melalui VM yang dihosting di cloud
Membangun konektivitas dari tujuan ke sumber melalui tunnel SSH terbalik yang aman.
Memerlukan VM host bastion dalam project Google Cloud dan mesin (misalnya, laptop di jaringan) yang memiliki konektivitas ke sumber. Database Migration Service mengumpulkan informasi yang diperlukan pada waktu pembuatan migrasi, dan membuat skrip secara otomatis untuk menyiapkannya.
Mudah dikonfigurasi.
Tidak memerlukan konfigurasi firewall kustom.
Direkomendasikan untuk skenario migrasi berumur pendek (POC atau migrasi database kecil).
Anda memiliki dan mengelola VM Bastion.
Dapat dikenai biaya tambahan.
Peering VPC
Metode ini berfungsi dengan mengonfigurasi VPC untuk berkomunikasi satu sama lain. Hal ini hanya
berlaku jika sumber dan tujuan dihosting di Google Cloud. Direkomendasikan untuk
migrasi yang berjalan lama atau bervolume tinggi.
SolusiGoogle Cloud .
Mudah dikonfigurasi.
Bandwidth tinggi
Hanya tersedia jika sumber dihosting di Google Cloud.
VPN
Menyiapkan tunnel VPN IPSec yang menghubungkan jaringan internal dan Google Cloud VPC melalui koneksi aman melalui Internet publik. Gunakan Google Cloud VPN atau solusi VPN apa pun yang
disiapkan untuk jaringan internal.
Solusi konektivitas yang tangguh dan skalabel.
Bandwidth sedang-tinggi.
Dilengkapi fitur keamanan bawaan.
Ditawarkan sebagai Google Cloud solusi atau dari pihak ketiga lainnya.
Biaya tambahan.
Konfigurasi yang tidak biasa (kecuali jika sudah diterapkan).
Cloud Interconnect
Menggunakan koneksi dengan ketersediaan tinggi dan latensi rendah antara jaringan lokal dan
Google Cloud.
Bandwidth tertinggi, ideal untuk migrasi bervolume tinggi yang berjalan lama.
Biaya tambahan.
Koneksi tidak aman secara default.
Konfigurasi yang tidak biasa (kecuali jika sudah diterapkan).
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-09-05 UTC."],[[["\u003cp\u003eDatabase Migration Service simplifies migrating PostgreSQL workloads to Cloud SQL, supporting various source types like Amazon RDS, Aurora, self-managed PostgreSQL, and others.\u003c/p\u003e\n"],["\u003cp\u003eThe service migrates data, schema, and metadata, including schemas, tables, stored procedures, functions, triggers, and views, with DML changes automatically updated during continuous migration.\u003c/p\u003e\n"],["\u003cp\u003ePostgreSQL-to-Cloud SQL migrations are supported across any major version, provided the destination is the same or higher than the source.\u003c/p\u003e\n"],["\u003cp\u003eSeveral networking methods are available, including IP allowlist, reverse SSH tunnel, VPC peering, VPN, and Cloud Interconnect, each with its own set of pros and cons.\u003c/p\u003e\n"],["\u003cp\u003eLarge objects, data from materialized views, and \u003ccode\u003eUPDATE\u003c/code\u003e/\u003ccode\u003eDELETE\u003c/code\u003e statements for tables without primary keys are not migrated by the service.\u003c/p\u003e\n"]]],[],null,["# Database Migration Service for PostgreSQL FAQ\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n[MySQL](/database-migration/docs/mysql/faq \"View this page for the MySQL version of Database Migration Service.\") \\| PostgreSQL \\| [PostgreSQL to AlloyDB](/database-migration/docs/postgresql-to-alloydb/faq \"View this page for the PostgreSQL to AlloyDB version of Database Migration Service.\")\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n- [What is Database Migration Service?](#whatisdms)\n- [Which sources are supported?](#sources)\n- [Which destinations are supported?](#destinations)\n- [Is there cross-version support?](#crossversion)\n- [Which data, schema, and metadata components are migrated?](#migrated)\n- [Which changes are replicated during continuous migration?](#replicated)\n- [What isn't migrated?](#notmigrated)\n- [Which networking methods are used?](#networking)\n- [What are the known limitations?](#limitations)\n\n\u003cbr /\u003e\n\nWhat is Database Migration Service?\n: Database Migration Service is a service that makes it easier for you to migrate your data to Google Cloud. Database Migration Service helps you lift and shift your PostgreSQL workloads into Cloud SQL.\n\nWhich sources are supported?\n:\n\n\n - Amazon RDS 9.6.10+, 10.5+, 11.1+, 12, 13, 14, 15, 16, 17.\n - Amazon Aurora 10.11+, 11.6+, 12.4+, 13.3+, 14.6+, 15.2+, 16, 17.\n - Self-managed PostgreSQL (on premises or on any cloud VM that you fully control) 9.4, 9.5, 9.6, 10, 11, 12, 13, 14, 15, 16, 17.\n - Cloud SQL for PostgreSQL 9.6, 10, 11, 12, 13, 14, 15, 16, 17.\n - Microsoft Azure Database for PostgreSQL Flexible Server: 11+\n\n\nWhich destinations are supported?\n:\n\n\n - Cloud SQL for PostgreSQL 9.6, 10, 11, 12, 13, 14, 15, 16, 17.\n\n\nIs there cross-version support?\n:\n\n Database Migration Service supports PostgreSQL-to-Cloud SQL migrations across any major\n version, where the destination is the same or higher version than the source database.\n\nWhich data, schema, and metadata components are migrated?\n\n: Database Migration Service migrates schema, data, and metadata from the source to the destination. All of the following data, schema, and metadata components are migrated as part of the database migration: \u003cbr /\u003e\n\n Data Migration\n\n - All schemas and all tables from the selected database.\n\n Schema Migration\n\n \u003c!-- --\u003e\n\n - Naming\n - Primary key\n - Data type\n - Ordinal position\n - Default value\n - Nullability\n - Auto-increment attributes\n - Secondary indexes\n\n Metadata Migration\n\n \u003c!-- --\u003e\n\n - Stored Procedures\n - Functions\n - Triggers\n - Views\n - Foreign key constraints\n\nWhich changes are replicated during continuous migration?\n:\n\n Only DML changes are automatically updated during the migration. Managing DDL so that the source and\n destination database(s) remain compatible is the responsibility of the user, and can be achieved in\n two ways:\n\n 1. Stop writes to the source and run the DDL commands in both the source and the destination. Before running DDL commands on the destination, grant the `cloudsqlexternalsync` role to the Cloud SQL user applying the DDL changes. To enable querying or changing the data, grant the `cloudsqlexternalsync` role to the relevant Cloud SQL users.\n 2. Use the `pglogical.replicate_ddl_command` to run DDL on the source and destination at a consistent\n point. The user running this command must have the same username on both the source and the destination, and should be the superuser or the owner of the artifact being migrated (for example, the table, sequence, view, or database).\n\n Here are a few examples of using the `pglogical.replicate_ddl_command`.\n\n To add a column to a database table, run the following command:\n\n `select pglogical.replicate_ddl_command('ALTER TABLE `\u003cvar translate=\"no\"\u003e[schema].[table]\u003c/var\u003e` add column surname varchar(20)', '{default}');`\n\n To change the name of a database table, run the following command:\n\n `select pglogical.replicate_ddl_command('ALTER TABLE `\u003cvar translate=\"no\"\u003e[schema].[table]\u003c/var\u003e` RENAME TO `\u003cvar translate=\"no\"\u003e[table_name]\u003c/var\u003e`','{default}');`\n\n To create a database table, run the following commands:\n 1. `select pglogical.replicate_ddl_command(command := 'CREATE TABLE `\u003cvar translate=\"no\"\u003e[schema].[table]\u003c/var\u003e` (id INTEGER PRIMARY KEY, name VARCHAR);', replication_sets := ARRAY['default'']);`\n 2. `select pglogical.replication_set_add_table('default', '`\u003cvar translate=\"no\"\u003e[schema].[table]\u003c/var\u003e`');`\n\nWhat isn't migrated?\n\n: To add users to the Cloud SQL destination instance, navigate to the instance and add users\n from the **Users** tab, or add them from the PostgreSQL client. Learn more about [creating\n and managing PostgreSQL users](https://cloud.google.com/sql/docs/postgres/create-manage-users).\n\n [Large objects](https://www.postgresql.org/docs/current/largeobjects.html) can't be\n replicated because PostgreSQL's logical decoding facility doesn't\n support decoding changes to large objects. For tables that have [column type oid](https://www.postgresql.org/docs/current/datatype-oid.html) referencing large\n objects, the rows are still synced, and new rows are replicated. However, trying to access\n the large object on the destination database\n (read using [lo_get](https://www.postgresql.org/docs/current/lo-funcs.html),\n export using [lo_export](https://www.postgresql.org/docs/current/lo-funcs.html), or check\n the catalog `pg_largeobject` for the given oid), fails with a message saying that the large\n object doesn't exist.\n\n For tables that don't have primary keys, Database Migration Service supports migration of the **initial snapshot and `INSERT` statements during the change data capture (CDC) phase** . You should migrate `UPDATE` and `DELETE` statements manually.\n\n Database Migration Service doesn't migrate data from materialized views, just the view schema. To populate the views, run the following command: `REFRESH MATERIALIZED VIEW `\u003cvar translate=\"no\"\u003eview_name\u003c/var\u003e.\n\n The `SEQUENCE` states (for example, `last_value`) on the new Cloud SQL destination might vary from the source `SEQUENCE` states.\n\nWhich networking methods are used?\n: To create a migration in Database Migration Service, connectivity must be established\n between the source and the Cloud SQL destination instance. There are a variety of methods supported.\n Choose the one that works best for the specific workload.\n\n\nWhat are the known limitations?\n: See [Known limitations](/database-migration/docs/postgres/known-limitations)."]]