The database should have at least one table in order to be added to replication. If it is a colocated database then there should be at least one colocated table in the database in order for it to be added to replication.
-
Create a checkpoint on the Primary universe for all the databases that you want to add to an existing replication group.
./bin/yugabyted xcluster add_to_checkpoint \ --replication_id <replication_id> \ --databases <comma_separated_database_names>
You should see output similar to the following:
Waiting for checkpointing of database to complete Successfully checkpointed database db2 for xCluster replication group repl_group1 Bootstrap is not required for adding database to xCluster replication Create equivalent YSQL objects (schemas, tables, indexes, ...) for the database in the standby universe
-
If needed, perform a full copy of the database(s) on the Primary to the Standby using distributed backup and restore. If your source database is not empty, it must be bootstrapped, even if the output suggests otherwise. This applies even if it contains only empty tables, unused types, or enums (#24030).
-
Enable point in time restore (PITR) on the database(s) on both the Primary and Standby universes:
./bin/yugabyted configure point_in_time_recovery \ --enable \ --retention <retention_period> \ --database <database_name>
The
retention_period
must be greater than the amount of time you expect the Primary universe to be down before it self recovers or before you perform a failover to the Standby universe. -
Add the databases to the xCluster replication.
./bin/yugabyted xcluster add_to_replication \ --databases <comma_separated_database_names> \ --replication_id <replication_id> \ --target_address <IP-of-any-target-node> \ --bootstrap_done
-
Create a checkpoint.
./bin/yb-admin \ -master_addresses <primary_master_addresses> \ add_namespace_to_xcluster_checkpoint <replication_group_id> <namespace_name>
You should see output similar to the following:
Waiting for checkpointing of database to complete Successfully checkpointed database db2 for xCluster replication group repl_group1 Bootstrap is not required for adding database to xCluster replication Create equivalent YSQL objects (schemas, tables, indexes, ...) for the database in the standby universe
-
If needed, perform a full copy of the database(s) on the Primary to the Standby using distributed backup and restore. If your source database is not empty, it must be bootstrapped, even if the output suggests otherwise. This applies even if it contains only empty tables, unused types, or enums (#24030).
-
Enable point in time restore (PITR) on the database(s) on both the Primary and Standby universes:
./bin/yb-admin \ -master_addresses <standby_master_addresses> \ create_snapshot_schedule 1 10 ysql.yugabyte
-
Set up the database using the checkpoint.
./bin/yb-admin \ -master_addresses <primary_master_addresses> \ add_namespace_to_xcluster_replication <replication_group_id> <namespace_name> <standby_master_addresses>
You should see output similar to the following:
Successfully added db2 to xCluster Replication group repl_group1