This section demonstrates the speed and accuracy of SharePlex replication. It can also be used to verify that SharePlex was installed and configured correctly. For detailed information, see Demonstration of replication.
This demonstration shows you how to use named post queues to process different tables through different, parallel Post processes to improve performance.
NOTE: The demonstration objects are assumed to be in the schema named splex.
Perform the following steps to clean up the replication environment:
If you ran previous demonstrations, do the following:
On the source and target, run sp_ctrl and issue the following command to shut down sp_cop.
sp_ctrl(source)shutdown
sp_ctrl(target)shutdown
On the source, TRUNCATE the splex.demo_src. SharePlex replicates the TRUNCATE to the target.
truncate table splex.demo_src;
Perform these steps on the source system. The demonstration objects are assumed to be in the schema named splex.
You will configure the following:
Run sp_ctrl.
Issue the following command to create a configuration file named postq_config in the default text editor.
sp_ctrl(source)>create config postq_config
In the text editor, build your configuration file based on the appropriate template, as shown in the Configuration templates. Allow no spaces between the characters in a component (source specification, target specification, routing map), and place at least one space between each component.
In sp_ctrl, verify that the configuration file will activate successfully.
sp_ctrl(source)>verify config postq_config
datasource:r.dbname | ||
splex.demo_src |
splex.demo_dest |
target_system:q1@r.database_name |
splex.demo_dest |
splex.demo_src |
target_system:q2@r.database_name |
where:
splex is the database user of the target database
Important!Make certain you created the scripts described in Prework for the demonstrations.
Perform these steps on the source system. When you activate a configuration, SharePlex is ready to capture transactional changes that are made to the specified source data.
Perform the following steps to activate the configuration:
Activate the configuration.
sp_ctrl(source)>activate config postq_config
Note: Configuration names are case-sensitive.
Confirm that the configuration activated successfully. The name postq_config should appear under File Name, and the word Active should appear under State.
sp_ctrl(source)>list config
On the source, run the following scripts to insert data into the two local demonstration tables (in this demonstration, the demo_dest table is used as a source):
Perform the following steps to view the post queues:
On the target, issue the show post command with the detail option. This command shows statistics about the number of messages processed and the queues that were used.
sp_ctrl(target)>show post detail
In the output, the Queue field shows the name of each post queue, in this case q1 and q2, and the Operations Posted field shows the number of operations that were posted. Each queue should show 500 operations posted.
Demonstration of Conflict Resolution - PostgreSQL to PostgreSQL
Demonstration of conflict resolution - PostgreSQL to Oracle
Demonstration of transformation for PostgreSQL
Sample configuration for PostgreSQL to PostgreSQL replication
Configure, activate, and verify replication on the PostgreSQL source
This chapter demonstrates selected features of SharePlex. These exercises can be run on Unix and Linux systems to demonstrate:
Notes:
|
Prerequisites:
|
In this demonstration, you will configure SharePlex to use generic conflict resolution procedures to resolve a replication conflict. Generic conflict resolution allows you to use one PL/SQL procedure to resolve conflicts for multiple tables.
The following conflict-resolution strategy is demonstrated:
IMPORTANT! Peer-to-peer replication is not compatible with all business applications. When suitable for an environment, it requires careful analysis and execution, including the creation of custom conflict resolution procedures that are typically more complex than those in this demonstration. Do not use this demonstration as the foundation of a production peer-to-peer deployment. For more information about peer-to-peer replication, see the SharePlex Administration Guide.
Install the demonstration objects as described below before you start the demonstrations.
Note: To run the scripts, set Replica Identity to Full for tables that are a part of replication.
The pg_p2p.sql and pg_od.sql scripts install the demonstration objects that you will use during these demonstrations. These scripts are stored in the util sub-directory of the SharePlex product directory.
To run the scripts:
Note: The scripts prompt for the schema where you want the demonstration objects need to be installed. Additionally, pg_p2p.sql prompts for the name of the system that will be the trusted source of accurate data.
od_employee
Name |
Null? |
Type |
---|---|---|
emp_no | not null | int |
emp_first_name | varchar(20) | |
emp_last_name | varchar(20) | |
emp_dob | date | |
emp_dept_no | int | |
emp_timestamp | date |
Name |
Null? |
Type |
---|---|---|
exc_no | not null | int |
exc_type | varchar (6) | |
exc_target_table | varchar (66) | |
exc_fixed | varchar (3) | |
exc_info | varchar (500) | |
exc_timestamp | date |
exc_source
Name |
Type |
---|---|
pri_system | varchar |
Note: Apart from these tables, other demonstration objects are also created those are not part of this demonstration.
Note: In this demonstration, the demonstration objects are assumed to be in the schema named demo. Substitute the actual schema, if different.
Perform these steps on both systems (for both databases).
Shut down SharePlex.
sp_ctrl(peer1)>shutdown
Run the pg_p2p.sql script from the util sub-directory of the SharePlex product directory. This installs the od_employee_gen demonstration conflict resolution routine. You are prompted for the following:
Perform these steps to configure SharePlex:
On each system, open the conflict_resolution.database file in a text editor. This file is located in the data sub-directory of the SharePlex variable-data directory.
Note: Post checks this file when there is a replication conflict to determine if there is a resolution procedure to call.
On each system, create the following entries in the conflict_resolution.database file. Separate each column with at least a few spaces or a tab character.
demo.od_employee | IUD | demo.od_employee_gen |
Note: The first component is a table, the second specifies the operation types for which a resolution routine will be called if there is a conflict on that table, and the third is the name of the resolution routine that will be used.
On peer1 (the trusted source), create a configuration file named od_peer1 that replicates the od_employee table to the od_employee table on peer2.
sp_ctrl(peer1)> create config od_peer1
demo.od_employee | demo.od_employee | peer2@r.database |
On peer2 (the secondary source), create a configuration file named od.peer2 that replicates the od_employee table to the od_employee table on peer1.
sp_ctrl(peer2)> create config od_peer2
demo.od_employee | demo.od_employee | peer1@r.database |
Perform these steps to activate and start replication:
On peer1, activate the od_peer1 configuration.
On peer2, activate the od_peer2 configuration.
On each system, confirm that the configuration activated successfully. The name od_peer1 or od_peer2 (depending on the system) should appear under File Name, and the word Active should appear under State.
sp_ctrl(source)>list config
In this demonstration, an INSERT that originates on peer1 will override a conflicting INSERT that is replicated from peer2.
On peer2, insert a row into od_employee.
insert into od_employee values(1, 'John', 'Doe', '1949-04-01', 1, '2022-01-01');
On peer1, insert the same row (same values).
insert into od_employee values(1, 'John', 'Doe', '1949-04-01', 1, '2022-01-01');
In this demonstration, whenever there is a conflict for an UPDATE statement, the row with the most current value of the emp timestamp column gets precedence.
Note: The EMP_TIMESTAMP field, along with the other columns, must be modified to a non-null value in order for timestamp priority to function. The stored procedure won't be able to resolve the conflict if the timestamp column in the UPDATE statement is not being updated or is being modified to a null value. Out-of-sync problems will then be seen.
In this demonstration, if a DELETE statement generates a conflict, it is ignored.
A table named exc_table was installed in the schema that you specified when you installed the demonstration objects. You can view it through PSQL to view information about each conflict. The following is the table description.
Column | Description |
---|---|
EXC_NO | The exception number of the conflict. |
EXC_TYPE | The type of SQL statement, whether INSERT, UPDATE or DELETE. |
EXC_TARGET_TABLE | The table on which the conflict occurred. |
EXC_FIXED |
The results of the conflict resolution routine. YES means that the routine was successful. NO means that the routine failed and the row needs to be manually changed to the correct value. |
EXC_INFO | The cause of the conflict. |
EXC_TIMESTAMP | The time that the conflict occurred on this machine. |
© ALL RIGHTS RESERVED. Terms of Use Privacy Cookie Preference Center