prosync
Synopsis
prosync config generate [option]...
prosync init [option]...
prosync run [option]...
prosync complete [option]...
Description
prosync is a utility to perform the change data capture (CDC) of a source database and replay the changes on a destination database of a different type.
prosync is not responsible for:
-
Database schema transfer.
-
Transferring data that is missing from log files.
-
Data verification after the data transfer.
Usage
Migrating the Database
prosync participates in the hot DB migration (refer to Cold and Hot Database Migration for more details).
Preparing for a Migration of a Hot DB
To prepare for the migration of a hot DB, perform the following steps:
-
Prepare and set up the destination DB for the migration:
-
Create the necessary schemas and tables.
-
Remove or turn off triggers.
-
-
Generate the configuration file:
prosync config generate -o <config_file> -
Update the configuration file with appropriate values.
-
Initialize prosync with the command:
prosync init -f <config_file>For an Oracle source, prosync will store the current SCN to start the subsequent replication with this value. For a PostgreSQL/Postgres Pro source, prosync will create a logical replication slot for subsequent reading of changes.
Performing the Migration of a Hot DB
Perform the migration as follows:
-
Launch the procopy load:
procopy load -f <config_file> -
When it finishes, launch the prosync replay of changes:
prosync run -f <config_file> -
Wait until the difference between
Parsing SCNandOracle latest SCNdecreases to an admissible value. For the migration of a hot DB, it is critical for this difference to decrease:Parsing SCN 3671057 Oracle latest SCN 4995972
-
Disable the load on the source DB and wait until
Parsing SCNandOracle latest SCNvirtually stop changing. Stop prosync.Changes always occur in Oracle even if nobody changes the data, so
Oracle latest SCNis continuously growing. Therefore, the difference betweenParsing SCNandOracle latest SCNnever reaches zero.
Excluding Columns from Tasks of the Table Type
When executing tasks of the TABLE type (refer to Types of Tasks for details) during data migration involving prosync, do not exclude (through exclude_columns or include_columns) columns that are used by LogMiner as a row key. Otherwise, executing DELETE or UPDATE commands can change more than one row.
For tables without keys (heap), do not exclude any columns as LogMiner uses the whole row for identification.
|
These rules do not apply for data migrations that are only performed by procopy. |
Notes for PostgreSQL/Postgres Pro Sources
When migrating the PostgreSQL/Postgres Pro DB, a replication slot is needed for running prosync replay of changes. Therefore:
-
Before launching the replay of changes by prosync prosync run, execute the prosync init command, which will create the replication slot.
-
When prosync run finishes, execute
completecommand to clear the replication slot.
Custom Names of the Replication Slot and the Publication
By default, prosync generates the names of the replication slot and the publication automatically based on the source database name, the transfer identifier prosync_options.transfer_id, and other data. You can also specify custom names with the prosync_options.custom_pub_name and prosync_options.custom_slot_name configuration parameters.
Custom names are used as is by the prosync init, prosync run, and prosync complete commands. You can specify only one of the names or both. For example, to reuse an existing publication, specify only the publication name; to create a slot in the past with the --start-lsn parameter, specify only the slot name.
The names must meet the following requirements:
-
The slot name must contain only lowercase Latin letters, digits, and underscores. The publication name must be a UTF-8 string without null characters.
-
The name length must not exceed 63 bytes. Otherwise, prosync terminates with an error.
-
You must not change the names in the configuration file between prosync runs; otherwise, the utility will not find the previously created slot and publication. Use the same name while working with the utility.
|
When working with a Postgres Pro Shardman cluster, prosync creates a separate slot and publication for global tables (for details, refer to Processing Global Tables). The |
Maintaining the Replication Connection
The PostgreSQL/Postgres Pro source terminates replication connections that remain inactive longer than the time period specified by the wal_sender_timeout parameter. A small value of this parameter can be used, for example, to detect a failure of the standby node quickly.
If passing the read operations for writing to the destination database slows down or stops, prosync cannot confirm that its connection is active in a timely manner, and the source may terminate the connection as inactive. To prevent this, every time interval set with the prosync_options.postgres_consumer_wait_timeout parameter prosync sends the source a replication status message and retries passing the operation. The value of the prosync_options.postgres_consumer_wait_timeout parameter must be less than the source’s wal_sender_timeout.
If the wal_sender_timeout value on the source only needs to be small to quickly detect failures of the standby nodes, you can override wal_sender_timeout for the prosync session in the source connection string specified by source.dsn instead of setting the prosync_options.postgres_consumer_wait_timeout parameter:
dsn: "postgresql://host:5432/mydb?user=prosync&options=-cwal_sender_timeout%3D60s"
Such an override only applies to prosync connections and does not affect other connections to the source database.
Preventing Replication Slot Invalidation
If the source database server invalidates a logical replication slot, prosync can no longer get changes from the slot and terminates with an error. In this case, changes that have not yet been transferred to the destination database may be lost.
Invalidation is also unacceptable for a slot that prosync does not read from but that retains WAL files and rows from the system catalogs required to create a slot in the past using the --start-lsn option (for details, refer to Creating a Logical Replication Slot in the Past). Once such a slot is invalidated, these WAL files are no longer retained, and it may be impossible to create a slot in the past from an earlier position.
A slot can be invalidated for the following reasons:
-
The disk has run out of space. A slot retains WAL files until prosync reads the changes from them so WAL files accumulate if prosync is stopped or lags behind.
-
The
max_slot_wal_keep_sizevalue is exceeded. -
The
idle_replication_slot_timeoutparameter is set to a non-zero value (PostgreSQL/Postgres Pro 18 or higher), and the slot has been inactive for longer than the specified time. -
VACUUMon the primary has removed rows from the system catalogs that are required by a slot on the standby. This can happen if prosync reads changes from a standby or uses failover replication slots, andhot_standby_feedbackis not enabled on the standby.
To prevent slot invalidation, set the following configuration parameter values on the source database nodes:
max_slot_wal_keep_size = -1
idle_replication_slot_timeout = 0
If prosync_options.use_failover_slots is set to true or prosync reads changes from a standby, also set the following on the standby nodes:
sync_replication_slots = on
hot_standby_feedback = on
Monitor free space on the disk that contains the pg_wal directory and the slot states in the pg_replication_slots view: the unreserved`or `lost value in the wal_status column means that the slot is at risk of being invalidated or it has already been invalidated.
If the disk is running out of space and the source database has slots that are used only to retain WAL files, advance such slots to a later position using the pg_replication_slot_advance function. WAL files that precede the new position are no longer retained, so it may be impossible to create a slot in the past from an earlier position. Do not advance the slot that prosync reads from, and do not delete files from the pg_wal directory manually as this will result in the loss of changes.
Advancing the Replication Slot When There Are No Changes
When there are new changes, the slot is advanced to the WAL position confirmed by the destination, that is, to the position up to which the data has already been transferred to the destination. To keep the replication slot from lagging behind the current WAL position and holding only up-to-date log files, prosync periodically advances the slot, even if there are no new changes in the replicated tables.
If no new operations appear in the slot during the time specified by the prosync_options.postgres_timeout_waiting_no_operations configuration parameter, prosync gets the current LSN and the time it was obtained from the primary. If, in addition, no new operations appear after the time specified by the prosync_options.postgres_timeout_checking_no_operations configuration parameter, prosync advances the replication slot to this LSN and continues tracking new changes. Such advancement is performed only when there are no new operations, so it does not lead to data loss, as changes that have not yet been read from the slot are not skipped. If a new operation appears during the wait, the countdown of the intervals starts over.
Skipping Oracle Background Transactions
By default, when reading changes from an Oracle source, prosync skips transactions of the Oracle background processes: PMON, DBW, LGWR, ARC, CKPT, MMON, MMNL, and their subprocesses. These processes maintain the operation of the database itself and contain no changes of user data, so migrating them to the destination is optional.
If you still need to migrate background transactions, run prosync with the --oracle-include-bg-tx flag.
Using Oracle Standby Sources
By default, prosync starts LogMiner on the Oracle source database only if it is open in the READ WRITE mode. To read changes from a read-only physical standby, configure a writable downstream mining database by specifying the prosync_options.oracle_logminer_downstream configuration parameter. In this case, prosync connects to the standby database as specified by source.dsn, reads metadata from it, and discovers archived redo logs there, but starts the DBMS_LOGMNR session on the mining database specified in the prosync_options.oracle_logminer_downstream.miner_dsn configuration parameter. To start using Oracle standby sources, follow the steps below:
-
Configure redo log shipping from the primary database to the mining database. On the primary database, set the
LOG_ARCHIVE_DEST_ninitialization parameter (wherenis a destination number from1to31) that defines the destination for archived redo logs. You must also set theTEMPLATEattribute to specify the path at which archived redo logs are stored on the mining database. -
Set
prosync_options.oracle_logminer_downstreamin the configuration file. The value ofprosync_options.oracle_logminer_downstream.archive_path_templatemust match theTEMPLATEattribute specified in the previous step. -
Run prosync prosync run as usual. The standby database must be open for queries, for example, in the
READ ONLY WITH APPLYmode. The mining database must be open in theREAD WRITEmode.prosync maps each archived redo log discovered on the standby database to its path on the mining database, adds it to the LogMiner session, and waits for logs that have not yet been shipped. The wait time is limited by the
prosync_options.oracle_logminer_downstream.archive_log_wait_timeoutconfiguration parameter.
|
On the mining database, LogMiner uses the dictionary stored in redo logs instead of the online catalog of the mining database. This is controlled by the |
Running prosync in the High-Availability Mode
prosync supports the high-availability operation mode. High availability is achieved by means of a prosync cluster, which consists of several prosync instances that perform tasks with the same configuration. These instances are located on different nodes and perform failover in case of a current leader failure.
The heartbeat and reconnection parameters of the high-availability mode are configured by the prosync_options.ha_cluster configuration parameters (refer to prosync config generate for details).
Launching prosync in the High-Availability Mode
To run the replication in the high-availability mode, follow these steps:
-
Create the configuration file by means of the prosync config generate command.
-
Edit the configuration file as appropriate. Specifically, if the destination is Postgres Pro Shardman or Oracle, set the value of
storage.driver_nametopostgres. -
Run prosync init on one of the servers where prosync will later run in the high-availability mode. If the
prosync_options.transfer_idconfiguration parameter is not specified in the configuration file, it is automatically generated and saved during theinitoperation.The
prosync_options.transfer_idparameter must be unique for a prosync cluster. It will be used to monitor the status of this cluster. Avoid specifying it manually. -
Copy the configuration file to all the servers where prosync will run.
-
Launch prosync run in the high-availability mode by specifying the
--haoption.
Monitoring the High Availability
When in the high-availability mode, information on all prosync cluster nodes is written to the supporting database specified by the storage configuration parameter. The following tables are available there:
| Table | Purpose |
|---|---|
|
Registration of the nodes: |
|
Transfer locks: |
The status column can have the following values:
| Node Status | Can Change to |
|---|---|
|
|
|
|
|
|
|
|
Performing Failover
The failover is organized as follows:
-
The leader node writes
leader_last_heartbeatonce everyheartbeat_periodinterval (5 sec by default). -
A node with the
reservestatus queries theprosync_ha_cluster_transfer_lockstable. -
If
leader_last_heartbeatis older thanheartbeat_period×heartbeat_max_errors(5 × 5 sec by default), the leader is considered failed, the reserve node clearsleader_uuidand promotes itself to leader by executing the query:UPDATE … SET leader_uuid = @self WHERE leader_uuid IS NULL -
If the leader encounters a critical error, such as the loss of the replication slot, it automatically performs prosync prosync complete, which must complete within the
complete_timeoutinterval. -
The new leader continues the replication.
All the prosync instances write last_heartbeat to the prosync_ha_cluster_nodes table, which can be used to monitor the cluster as a whole.
Stopping prosync High-Availability Mode
Before performing prosync complete, stop all the prosync instances operating in the high-availability mode.
Upon completion, nodes are not automatically deleted from the prosync_ha_cluster_nodes table. If a need arises, you can manually delete the information on stopped prosync nodes.
Running prosync in the Primary-Primary Replication Mode
prosync can replicate data between two PostgreSQL/Postgres Pro databases in both directions. In such a configuration, each database acts both as a source and as a destination, so a separate prosync instance is required for each direction. A change made on one node can therefore be applied by one prosync instance and then be read by the other instance as if it were made locally. This leads to replication loops of the same changes between the nodes. To avoid such loops, prosync can use replication origins. In this case, changes written to the destination are tagged with an origin name, and changes that carry an origin are skipped when read from the source.
This behavior is controlled by the prosync_options.use_origin configuration parameters (refer to prosync config generate for details).
|
When bidirectional replication is used, the same records must not be modified simultaneously on different databases. It is the responsibility of the business application to guarantee this. |
Setting Up Primary-Primary Replication
To run the bidirectional replication, follow the steps below:
-
Create a configuration file for each direction using the prosync config generate command. The first file describes replication from one database to the other, and the second file describes replication in the reverse direction. To achieve this, the
source.dsnvalue in the second file specifies the same database asdestination.dsnin the first one, and vice versa. -
Give each direction its own origin name. For example, set
prosync_options.use_origin.write_origintoprosync_1in the first configuration file and toprosync_2in the second one.Then set
prosync_options.use_origin.read_origintononein both files so that each prosync instance skips the changes written by the other one. -
Run prosync init and prosync run for each direction. During
init, the replication origins are created on the destination databases. Duringrun, each prosync instance tags the changes it writes to the destination with its own origin and reads only the changes that have no origin on the source. -
To stop the bidirectional replication, stop both prosync instances and run prosync complete for each direction. The
completeoperation deletes the replication origins it created on the destination databases.
|
The replication origins are displayed in the pg_replication_origin system view of the destination database. If |
Working with Postgres Pro Shardman
This section explains how prosync works with Postgres Pro Shardman.
Configuration
For example, in the YAML configuration file, specify:
source:
driver_name: shardman
shards:
shard-1:
dsn: postgresql://host1:5432,host2:5432/postgres?user=postgres&password=fqs291dbb&target_session_attrs=prefer-standby
shard-2:
dsn: postgresql://host3:5432,host4:5432/postgres?user=postgres&password=fqs291dbb&target_session_attrs=prefer-standby
Where shard-1 and shard-2 are shard names and dsn parameters specify BiHA nodes in these shards.
|
When |
Possible values of target_session_attrs in dsn are as follows:
-
read-write,primary— the connection is only to the master. Reconnects to master will occur (when the master changes or is inaccessible). -
read-only— the connection is always to a standby. Reconnects to other standbys will occur (if the current node was promoted to master or is inaccessible). -
prefer-standby— the preferred connection is to a standby. If the BiHA cluster has more standbys, reconnects to them will occur. If only the master is left, a reconnect to it will occur.
Configure prosync_options as follows:
-
Set
use_replica_auto_sync_slotsto true if you need failover replication slots and replication from a standby in the BiHA cluster. -
Set
use_failover_slotsto true if you need failover replication slots and replication only from the master. -
It is recommended to set
use_replica_auto_sync_slotsto true and indsn, settarget_session_attrstoprefer-standby.
Partially Specifying Shards
By default, exclusion of shards from the configuration is prohibited as it can cause data loss in the destination when working with sharded and local tables. However, running prosync prosync init or prosync run with the --allow-partial-shardman-read option allows you to exclude some shards. With this option, prosync will work without specifying all the shards in the configuration file. This is useful when:
-
Data is manually distributed across shards and is located, for example, in specific local tables.
-
Data is located only in global tables, or data from these tables is only needed.
Processing Global Tables
Global tables from only one shard are processed. The shard is chosen by sorting shard names in the configuration file.
Two replication slots are created on the chosen shard:
-
A slot for global tables only.
-
A slot for sharded and local tables.
On the other shards, replication slots for sharded and local tables are only created.
Processing Local Tables
By default, processing of local table is prohibited as the result of this processing in the destination is unpredictable. However, the prosync prosync init or prosync run command with the --allow-shardman-local-tables option processes local tables. This is useful when:
-
At the business logic level, local tables on all shards contain different data.
-
The local table is on one of the shards.
Additional Information
Tasks of the Schema or Table types are supported. For more details, refer to Types of Tasks.
If a local table located on one of the shards is specified in the configuration file, a replication slot that includes this table will automatically be created on this shard.
So for different local tables, replication slots with different names and different table lists will be created on different shards.
prosync prosync run displays Postgres Pro Shardman-specific statistics. Refer to Displayed Statistics for details.
Distributing Table Rows across Shards of a Local Table
For tasks of the TABLE type (refer to Types of Tasks for details) with an Oracle source and Postgres Pro Shardman destination, you can specify the shards of a local table where to send certain rows of the source table. To do this, follow the steps below:
-
In the configuration file, specify the
destination.shardsconfiguration parameter to include all the shards to distribute rows to. For example:destination: shards: shard_1: dsn: postgresql://10.5.53.160:5432/postgres?user=postgres&password=fqs291dbb&target_session_attrs=prefer-standby shard_2: dsn: postgresql://10.5.53.162:5432/postgres?user=postgres&password=fqs291dbb&target_session_attrs=prefer-standby ...Where
shard_1,shard_2, … are conventional shard names. -
In the
tasks.table.dst_shard_filter_mappingconfiguration parameter, specify the mapping of table rows to shards. For example:table: destination_table: xpress.fpsdocs_transgran source_table: xpress.fpsdocs_transgran dst_shard_filter_mapping: shard_1: mod(XINT, 4) = 0 shard_2: mod(XINT, 4) = 1 shard_3: mod(XINT, 4) = 2 shard_4: mod(XINT, 4) = 3With this setting, for example, rows that meet the
mod(XINT, 4) = 0condition will be sent to the shard specified indestination.shards.shard_1.
Creating a Logical Replication Slot in the Past
The prosync init command with the --start-lsn option creates a logical replication slot in the past in the source database, that is, a slot from which changes are read starting from the specified position in the write-ahead log (WAL). The position is specified as an LSN (log sequence number). This allows you to transfer changes committed after the selected position to the destination database.
A slot in the past is created using the pgpro_logical_slot extension, so the --start-lsn option is applicable to Postgres Pro Enterprise 17 or higher sources, as well as to Postgres Pro Shardman sources if the build includes this extension.
The --start-lsn option does not create a publication, it must be created in advance. For details, refer to Prerequisites.
If a slot cannot be created from the specified position, the command fails. If prosync init --start-lsn completes without errors, the slot is ready, and you can run prosync run.
Prerequisites
Before creating a slot in the past, perform the following steps:
-
Configure the source as described in Postgres Pro/PostgreSQL Source. In particular,
wal_levelmust be set tological. -
Install the pgpro_logical_slot extension package on each source node. Then create the extension in the source database (on the leader node of a BiHA cluster or of each Postgres Pro Shardman shard):
CREATE EXTENSION IF NOT EXISTS pgpro_logical_slot; -
Grant the
EXECUTEprivilege on thepg_ls_waldirfunction to the user that prosync uses to connect to the source database:GRANT EXECUTE ON FUNCTION pg_ls_waldir() TO PROGATE_USER;This user is specified in the
source.dsnconfiguration parameter. Superusers and roles with privileges of thepg_monitorrole have this privilege by default. -
Make sure that
prosync_options.use_failover_slotsis set tofalse. -
Create a publication by running
prosync initwith the--publication-onlyflag:prosync init -f <config_file> --publication-onlyprosync determines the publication name from the configuration file so use the same configuration file without changes when creating the slot.
-
Select the LSN to start reading changes from. The value is specified in the
X/XXXXXXXXformat and must not be0/0. The selected LSN must meet the following conditions:-
The publication already existed and
wal_levelwas set tologicalat this position. -
The WAL file containing this position is still present on each node where the slot is created.
-
The structure of the replicated tables has remained unchanged since this position.
-
|
Do not drop the publication if you plan to create slots in the past. A publication cannot be created retroactively so once it is dropped, you will not be able to create a slot in the past for LSNs that precede the new publication. In particular, do not run prosync complete if slots in the past may still be needed: this command drops not only the slot but also the publication. |
Creating a Slot on a Single Node
If source.dsn specifies a single node or prosync_options.use_replica_auto_sync_slots is set to false, the slot is created on the node that prosync connects to. Specify a single LSN:
prosync init -f <config_file> --start-lsn 0/16B6C50
Creating Slots for a BiHA Cluster
If source.dsn specifies several nodes of a BiHA cluster and prosync_options.use_replica_auto_sync_slots is set to true, specify a single LSN. prosync will create a slot in the past with this position on each node specified in source.dsn.
prosync_options:
use_replica_auto_sync_slots: true
prosync init -f <config_file> --start-lsn 0/16B6C50
BiHA cluster nodes replay the same WAL so the LSN is the same for all nodes. You cannot specify different LSNs for different nodes.
The publication is created on the leader node and must be available on all cluster nodes. If the publication is missing on at least one node, the command fails. If an error occurs, prosync drops only the slots created during the current command run and keeps the publication.
Creating Slots for Postgres Pro Shardman
Each shard of a Postgres Pro Shardman cluster has its own WAL and, therefore, its own LSN values. That is why the LSN is specified separately for each shard in the <shard_name>=<LSN> format, with values separated by commas. Shard names must match the names specified in the source.shards parameter:
prosync init -f <config_file> \
--start-lsn shard-1=0/16B6C50,shard-2=0/2A10000
Specify exactly one value for each shard. The specified LSN is used for all slots of the shard, including the slot for global tables (for details, refer to Processing Global Tables). If a shard is a BiHA cluster and prosync_options.use_replica_auto_sync_slots is set to true, slots with this LSN are created on each node of the shard. You cannot specify different LSNs for nodes of the same shard.
If an error occurs on one of the shards, the command terminates, and the publications and slots successfully created on other shards are kept. In this case, unlike when an error occurs without the --start-lsn option, prosync complete is not run automatically because it would drop the publications required for a retry. To continue, rerun prosync init with the same --start-lsn values (for details, refer to Rerunning the Command).
Rerunning the Command
When rerun, prosync init --start-lsn skips existing slots: it neither changes their position nor compares it with the specified LSN. After an error, rerun the command with the same values, and only the missing slots will be created.
To recreate a slot at a different position, drop it manually using the pg_drop_replication_slot function on each node where it was created and rerun the command. Do not use prosync complete for this, as it also drops the publication.
Limitations
-
The
--start-lsnoption is not applicable to an Oracle source. -
The
--start-lsnoption cannot be used together with the--publication-onlyflag. -
The
--start-lsnoption cannot be used ifprosync_options.use_failover_slotsis set totrueas the pgpro_logical_slot extension does not support creating failover slots.
Starting Change Processing from a Specified Time
For the Oracle source, the --from-time option of the prosync init command allows you to start processing changes from a specified point in time rather than from the current SCN, ignoring the changes started before the specified time.
The time is specified in the YYYY-MM-DD HH:MM:SS format. You can also specify only the time in the HH:MM:SS format, in which case the current date is used.
Based on the specified time, prosync determines the SCN from which it will start reading changes:
-
If the specified time falls within the range for which the source database maintains a time-to-SCN mapping, the SCN is determined directly from this data.
-
If the specified time is earlier than the period for which the time-to-SCN mapping is available in the source database, prosync finds the archived redo log whose time range includes the specified time. The utility then determines the SCN to start reading from as the SCN of the first redo log entry recorded at or after the specified time. If no archived redo log covering the specified time is found, the command fails with an error.
-
If the specified time is later than the period for which the time-to-SCN mapping is available in the source database, the current SCN is used.
-
If the specified time is in the future, the command fails.
The --from-time option applies only to Oracle sources. When used with other types of sources, the option is ignored and a warning is written to the log.
After the prosync init --from-time command completes, you can start the prosync run command.
Command-Line Reference
This section describes prosync commands. Optional parameters are enclosed in square brackets.
config generate
prosync config generate [-f | --format {json | yaml}]
[-o | --output config_file] [-c | --source_config]
[common_options]
Generates a prosync configuration file.
-f {json|yaml},--format {json|yaml}-
Specifies the format of the configuration file: JSON or YAML. The default is YAML.
-o <config_file>,--output <config_file>-
Specifies the filename of the configuration file. By default, the configuration file will be written to stdout.
-c,--source-config-
Use the procopy configuration file as the basis of the prosync configuration file and add missing options there.
init
prosync init {-f | --file} config_file [-u | --update-config]
[--publication-only | --start-lsn LSN] | --from-time time]
[--allow-partial-shardman-read] [--allow-shardman-local-tables]
[common_parameters]
Gets the current SCN from the source database. All the hosts specified in the configuration file must be accessible.
-f <config_file>,--file <config_file>-
Name of the configuration file, where the connection options are specified.
-u,--update-config-
Use the procopy configuration file as the basis and add missing options there.
--publication-only-
Create only a publication without a replication slot. Applicable to PostgreSQL/Postgres Pro and Postgres Pro Shardman sources. Cannot be used together with the
--start-lsnoption. --start-lsn <LSN>,--start-lsn <shard_name>=<LSN>[,<shard_name>=<LSN>…]-
Create a logical replication slot in the past to read changes starting from the specified LSN. The LSN is specified in the
X/XXXXXXXXformat and must not be0/0. For a single-node database and a BiHA cluster, specify one value. For Postgres Pro Shardman, specify a value for each shard. The publication must be created in advance by runningprosync initwith the--publication-onlyflag. For more information, refer to Creating a Logical Replication Slot in the Past. --from-time <time>-
Start change processing from the specified time instead of the current SCN. Changes in transactions started before the specified time are ignored. Applies only to Oracle sources. The time is specified in the
YYYY-MM-DD HH:MM:SSformat or in theHH:MM:SSformat (in this case, the current date is used). Refer to Starting Change Processing from a Specified Time for details. --allow-partial-shardman-read-
Run without the specification of all cluster shards in the configuration file. This may result in data loss.
--allow-shardman-local-tables-
Process local tables of a Postgres Pro Shardman cluster. This may result in inconsistent data in the destination.
run
prosync run {-f | --file} config_file
[--ha] [--dry-run | --read-only]
[-c | --clear] [--service] [--with-table-stats] [--with-dev-stats] [--allow-key-exclude]
[--allow-partial-shardman-read] [--allow-shardman-local-tables]
[--force-oracle-single-node] [--force-rac-thread thread_number]
[--rac-max-await-log-duration-seconds]
[--final-scn SCN] [--skip-scn-save] [--skip-missing-archive-logs]
[--oracle-include-bg-tx]
[common_options]
Launches the replay of changes to the source DB on the destination DB. Displays statistics on the replay.
-f <config_file>,--file <config_file>-
Name of the configuration file, where the connection options are specified.
--ha-
Run the replication in the high-availability mode. Refer to Running prosync in the High-Availability Mode for details.
--dry-run-
Turns off writing to the destination. prosync will perform all the operations except writing. This flag is useful for checking the performance of writing.
--read-only-
Turns off all the prosync logic except reading from the source. This flag is useful for checking the performance of reading.
-c,--clear-
Clear the screen before each time the statistics are displayed. When enabled, it is recommended to write logs to a file, as follows:
prosync run ... -c 2>prosync.log
--service-
Run prosync in the service mode. In addition to the terminal output, utility operation statistics are written to the log. The statistics output interval is set by the
prosync_options.statistic_intervalconfiguration parameter. --with-table-stats-
Collect and report the progress per tables and operations. Refer to Displayed Statistics for details.
--with-dev-stats-
Collect and report the statistics for development. Refer to Displayed Statistics for details.
--allow-key-exclude-
Allows excluding key columns from replication. If enabled, prosync may not work correctly for tables with unique constraints and heap tables when including or excluding certain columns. Set to true with caution and at the risk of data loss.
--allow-partial-shardman-read-
Run without the specification of all cluster shards in the configuration file. This may result in data loss.
--allow-shardman-local-tables-
Process local tables of a Postgres Pro Shardman cluster. This may result in inconsistent data in the destination.
--force-oracle-single-node-
Forces the single-node mode for prosync. Even if prosync is connected to Oracle Real Application Clusters (RAC), it will only work with the node it is connected to.
--force-rac-thread <thread_number>-
Forces the single-node mode for prosync, but unlike
--force-oracle-single-node, with this option prosync will only work with the node specified by<thread_number>. --rac-max-await-log-duration-seconds-
Time interval, in seconds, after which it is assumed that no log will arrive or a new log will not contain anything important, so it can be skipped. Only works for Oracle RAC.
--final-scn <SCN>-
SCN to stop the synchronization. The default is “0”.
--skip-scn-save-
Skip saving the SCN.
--skip-missing-archive-logs-
Skip the archive log entries with a
NULLvalue in theNAMEcolumn of theV$ARCHIVED_LOGview instead of failing. Such entries may appear in Oracle RAC when an archive log file is missing from the archive destination, so prosync cannot read the changes for the SCN range this file covers. + When set to the defaultfalse, prosync stops with an error when it encounters such an entry. When set totrue, prosync logs a warning and continues. Note that this may cause data loss for the affected SCN range. --oracle-include-bg-tx-
Read and replay Oracle background transactions. By default, prosync skips these transactions (refer to Skipping Oracle Background Transactions for details).
Displayed Statistics
The following statistics are displayed regardless of the options:
-
Total Measures — general statistics as a table:
-
Read— number of operations read from the source. -
Write— number of operations written to the destination. -
Transactions— number of transactions read. -
Read bytes— number of bytes read. -
Write bytes— number of bytes written.
-
-
Shards — statistics on shards as a table (for Postgres Pro Shardman source):
-
Shard name— name of a shard. If global tables are transferred, a row with the shard name and the “_global” postfix is added with the statistics on transferring global tables from this shard. -
State— name of the current status:receiveLogs— reading or waiting for reading data from the source;processLogs— processing the read data;reconnecting— reconnection. -
Time lag— time of the destination lagging behind the source. Computed as the difference between the completion time of the last transferred operation in the source and the current time on the source server. -
Bytes lag— destination lagging behind the source in bytes. Computed as the difference between the LSN of the last transferred operation in the source and the current LSN on the source server. The operations on all the tables on the source server are taken into account. -
Avg 60 sec, speed— the average speed of writing bytes to the destination for 60 seconds.
-
-
Additional — more general statistics:
-
Confirmed data time— time of the transferred data on the source server. Computed as the current source time minus the maximumTime lag. This value can be useful to check data in the source and destination. -
App time— current time in the prosync application. -
App duration— time of the prosync operation since the process start.
-
If --with-table-stats is specified, more statistics on tables are displayed:
-
Tables Measures — more statistics on tables as a table:
-
<schema>.<table_name> Insert— number of transferredInsertoperations, where<schema>.<table_name>is the name of the schema and table in the destination andInsertis the type of the transferred operation. Each transferred operation is in a separate row. -
<schema>.<table_name> Write bytes— number of bytes transferred.
-
If --with-dev-stats is specified, more statistics are displayed:
-
Total Measures:
-
Read time— Time spent reading data. -
Process time— Time spent processing data. -
Write time— Time spent writing data. -
Write batch count— Number of batches written to the destination. -
Write, current applying batch importers— Number of loaders that are currently writing batches.
-
-
Additional:
-
Latest batch insert time— Time the last batch was written.
-
complete
prosync complete [-f config_file] [--clean-nodes-info] [--force]
[common_options]
Clears the replication slot used by prosync run. The slot name is determined from the configuration file, whose name is passed through the -f option. The default name is config.yaml.
--clean-nodes-info-
Delete all inactive cluster nodes from the
prosync_ha_cluster_nodestable (refer to Monitoring the High Availability for details). --force-
Proceed with the cleanup even if some of the cluster nodes are unavailable. By default, the
completecommand exits with an error if it fails to connect to the supporting database, as well as if it fails to clean up the source or the supporting database. With the--forceoption, prosync performs all the cleanup operations it can. If an operation cannot be performed, this is written to the log.If the transfer lock string cannot be removed, prosync displays a warning that it must be deleted from the
prosync_ha_cluster_transfer_lockstable manually before running prosync run or prosync init again, or that the value of theprosync_options.transfer_iddata transfer identifier must be changed in the configuration file.
Common Options
--log-level <level>-
Log level of the command. Possible values are
error,warn,info, anddebug. The default isinfo. --pprof-port <port>-
Enables runtime profiling and starts the pprof server listening on the specified port at
127.0.0.1. A value of0means a random port. The actual address of the pprof server is written to the log at startup. Profiling is disabled by default. To disable profiling explicitly, set--pprof-portto-1or do not set this option. -v,--version-
Display the prosync version.