The following assumes you have set up Primary and Standby universes. Refer to Set up yugabyted universes. The yugabyted node must be started with --backup_daemon=true
to initialize the backup/restore agent.
-
Create a checkpoint on the Primary universe for all the databases that you want to be part of the replication.
./bin/yugabyted xcluster create_checkpoint \ --replication_id <replication_id> \ --databases <comma_separated_database_names>
The command informs you if any data needs to be copied to the Standby, or only the schema (empty tables and indexes) needs to be created.
For example:
+-------------------------------------------------------------------------+ | yugabyted | +-------------------------------------------------------------------------+ | Status : xCluster create checkpoint success. | | Bootstrapping : Bootstrap is required for database `yugabyte`. | +-------------------------------------------------------------------------+ For each database which requires bootstrap run the following commands to perform a backup and restore. Run on source: ./yugabyted backup --cloud_storage_uri <AWS/GCP/local cloud storage uri> --database <database_name> --base_dir <base_dir of source node> Run on target: ./yugabyted restore --cloud_storage_uri <AWS/GCP/local cloud storage uri> --database <database_name> --base_dir <base_dir of target node>
-
If needed, perform a full copy of the database(s) on the Primary to the Standby using distributed backup and restore.
-
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. -
Set up the xCluster replication.
./bin/yugabyted xcluster set_up \ --target_address <ip_of_any_target_cluster_node> \ --replication_id <replication_id> \ --bootstrap_done
You should see output similar to the following:
+-----------------------------------------------+ | yugabyted | +-----------------------------------------------+ | Status : xCluster set-up successful. | +-----------------------------------------------+
The following assumes you have set up Primary and Standby universes. Refer to Set up universes.
-
Create a checkpoint using the
create_xcluster_checkpoint
command, providing a name for the replication group, and the names of the databases to replicate as a comma-separated list../bin/yb-admin \ -master_addresses <primary_master_addresses> \ create_xcluster_checkpoint <replication_group_id> <comma_separated_namespace_names>
The command informs you if any data needs to be copied to the Standby, or only the schema (empty tables and indexes) needs to be created. For example:
Waiting for checkpointing of database(s) to complete Checkpointing of yugabyte completed. Bootstrap is not required for setting up xCluster replication Successfully checkpointed databases for xCluster replication group repl_group1 Create equivalent YSQL objects (schemas, tables, indexes, ...) for databases [yugabyte] on the standby universe Once the above step(s) complete run 'setup_xcluster_replication'
You can also manually check the status as follows:
./bin/yb-admin \ -master_addresses 127.0.0.1:7100,127.0.0.2:7100,127.0.0.3:7100 \ is_xcluster_bootstrap_required repl_group1 yugabyte
You should see output similar to the following:
Waiting for checkpointing of database(s) to complete Checkpointing of yugabyte completed. Bootstrap is not required for setting up xCluster replication
-
If needed, perform a full copy of the database on the Primary to the Standby using distributed backup and restore. See Distributed snapshots for YSQL. Otherwise, create the necessary schema objects (tables and indexes) on the Standby.
-
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 xCluster replication group.
./bin/yb-admin \ -master_addresses <primary_master_addresses> \ setup_xcluster_replication <replication_group_id> <standby_master_addresses>
You should see output similar to the following:
xCluster Replication group repl_group1 setup successfully