The following sections provide steps to configure your
AlloyDB Omni primary server for replication, configure the
replica server, and verify replication status on the primary server.
Configure your primary server for replication
Update the network or firewall settings of your primary server's host so
that it allows ingress traffic from the replica server's host through TCP
port 5432.
Add the following lines in the /var/alloydb/config/pg_hba.conf file:
DATA_DIR: the file system path you want this replica
to use for its data directory.
PORT: the TCP port that you want
AlloyDB Omni to accept connections on. If you don't
provide this value, then AlloyDB Omni applies a default
value of 5432.
SOURCE_IP: the IP address of the primary
AlloyDB Omni instance to replicate from.
SOURCE_PORT: the TCP port of the primary
AlloyDB Omni instance to replicate from. If you don't
provide this value, then AlloyDB Omni applies a default
value of 5432.
Ensure the replica has network connectivity to the primary server:
pingSOURCE_IP
Start your replica:
sudoalloydbdatabase-serverstart
Verify replication status on the primary server
To verify replication is configured properly, run the following command on the
primary server's host:
dockerexec-itpg-servicepsql-hlocalhost-Ualloydbadmin-c"select * from pg_stat_replication"
The output table contains one row for every replica connected to your primary
database server.
After you set up replication, all inserts, updates, and deletions to rows in
your primary database server become readable on your replica within seconds.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-21 UTC."],[[["\u003cp\u003eAlloyDB Omni replica servers offer read-only clones of the primary database, enhancing read throughput and availability by continuously updating with the primary server's data.\u003c/p\u003e\n"],["\u003cp\u003eConfiguring a primary server for replication involves updating network/firewall settings to allow ingress traffic from the replica and modifying the \u003ccode\u003e/var/alloydb/config/pg_hba.conf\u003c/code\u003e file to permit connections.\u003c/p\u003e\n"],["\u003cp\u003eCreating a replica server requires installing AlloyDB Omni and using the \u003ccode\u003ealloydb database-server install\u003c/code\u003e command with specific flags, including the data directory, port, source IP, and source port of the primary server.\u003c/p\u003e\n"],["\u003cp\u003eTo ensure the replica is correctly set up, network connectivity to the primary server must be confirmed via a \u003ccode\u003eping\u003c/code\u003e command, and the replica must be started using \u003ccode\u003esudo alloydb database-server start\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eReplication status can be verified on the primary server using a \u003ccode\u003edocker exec\u003c/code\u003e command that checks the \u003ccode\u003epg_stat_replication\u003c/code\u003e table, and once configured, changes on the primary server reflect on the replica within seconds.\u003c/p\u003e\n"]]],[],null,[]]