Introduction to and application of Oracle Advanced Replication Technology: Oracle Advanced Replication Technology is the first HA Disaster Tolerance solution proposed by Oracle. It originated from the Oracle8i system, you can still find the advanced copy in the official documents of the 11G website.
Introduction to and application of Oracle Advanced Replication Technology: Oracle Advanced Replication Technology is the first HA Disaster Tolerance solution proposed by Oracle. It originated from the Oracle8i system, you can still find the advanced copy in the official documents of the 11G website.
The Advanced Replication Technology is the first HA disaster recovery solution proposed by Oracle. It originated from the Oracle 8i system and can still find the Advanced Replication instructions in the 11g official documents. This technology is an old technology. I think most of my post-80s boots only hear their voices ~ It is invisible. It may not be used in a production environment. As the advanced replication technology is now a non-mainstream technology, it gradually exits from its historical stage and is gradually replaced by new technologies such as Data Guard, Golden Gate, and Streams, the reason for its decline is its own mechanism. We will introduce its principles and application scenarios later. Although this technology is very primitive, some old systems may continue to use it. We need to know the advantages, application scenarios, limitations, and risks of a technology so that we can use it easily and in a targeted manner. For example, there is almost no one using the original assembly language, however, due to its proximity to hardware, the efficiency is the fastest in some embedded systems. Therefore, we should also look at non-mainstream technologies. A good architect needs to select the most suitable among N different technology clusters. Always ask yourself: Can you reduce costs, solve problems, and make it easier to use.
Experiences
Different systems, different architectures, problem solving
A good architecture evolved from a system
Keep concise
Easy to scale, monitor, and fault tolerance
I. Application Architecture of Advanced Replication Technology
, Triggered immediately after the operation-> pass-> Application
(4) related replication Environment
(6) Master to Master provides node redundancy and Server Load balancer Replication
All node relationships are peer-to-peer, and data is peer-to-peer. When one of the Master nodes is unavailable, you can directly switch to another Master node.
Server Load balancer. For example, if three Master nodes Replicate each other, user 1 & 2 & 3 can connect the three Master nodes separately to achieve load balancing.
Used in Disaster Tolerance scenarios
(7) Support for synchronous and asynchronous replication
Synchronization: It can be pushed in real time. After the operation, trigger-> copy-> application immediately, because trigger and package are created on the copied table.
Asynchronous: you can set a scheduled job (background Process Control) to copy data in a scheduled or batch, and use Deferred Transaction Queue to implement this function.
(8) transactions and dependencies
Advanced Replication automatically processes the transaction dependency. If transaction B accesses transaction A and transaction A has updates, it is called transaction B's dependency on transaction.
Advanced Replication automatically resolves data constraints
Advanced Replication solves transaction consistency issues based on the distributed transaction method. It has more control over transactions than GG and Streams and has more involvement in user operations, we should try our best to separate user operations from data replication. Do not confuse them together to improve system stability and robustness.
(9) Materialized View-based Advanced Replication
The network quality is not high and can be interrupted due to non-real-time transmission.
Replicate data in a scheduled and batch manner by parsing materialized view logs.
Schematic diagram
---------------------------------------------------------------------------------------------------------------
REP LEO1.COM source database Y sends master node Y
REP LEO2.COM target database N receiving master node Y
The target end should also be able to find out
REPADMIN @ leo2> select gname, dblink, masterdef, master from dba_repsites where gname = 'rep ';
GNAME DBLINK MASTERDEF MASTER
------------------------------ Accept ----------------------------------------------------------------------------------------------------------------------------------------------------------------
REP LEO1.COM Y
REP LEO2.COM N Y
Check the content of table t at the source and target end. No data should be found.
Source end
AR @ leo1> select * from t;
No rows selected
Target end
AR @ leo2> select * from t;
No rows selected
10. Start replication group rep (Advanced Replication is now available)
REPADMIN @ leo1> execute 'cannot access the source library LEO1.COM
ORA-06550: line 1, column 8:
PLS-00201: identifier 'sys @ LEO1.COM 'must be declared to the source database dblink
ORA-06550: line 1, column 8:
PL/SQL: Statement ignored
ORA-06550: line 1, column 7:
PLS-00352: Unable to access another database 'leo1. com'
ORA-06550: line 1, column 7:
PLS-00201: identifier 'sys @ LEO1.COM 'must be declared
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
ORA-06512: at "SYS. DBMS_REPCAT_MAS", line 864
Solution
Dblink is created on the target end to the source end. The two ends must communicate with each other because of information interaction.
REPADMIN @ leo2> create database link leo1.com connect to repadmin identified by oracle using 'leo1 ';
Database link created.
Copy group rep must be restarted
REPADMIN @ leo1> execute dbms_repcat.suspend_master_activity ('rep '); pause
PL/SQL procedure successfully completed.
REPADMIN @ leo1> execute dbms_repcat.resume_master_activity ('rep ', true); restart
PL/SQL procedure successfully completed.
Internal triggers, stored procedures, and base tables are generated on both the source and target t tables.
REPADMIN @ leo1> select sname, oname, gname, status from dba_repobject where gname = 'rep ';
SNAME ONAME GNAME STATUS
----------------------------------------------------------------------------------------------------
AR T REP VALID
Ar t $ RP REP VALID
Ar t $ RP REP VALID
See DBMS_REPCAT in Database Advanced Replication Management API Reference.
The target end can be copied normally when these items exist in the target database t table.
REPADMIN @ leo2> select sname, oname, gname, status from dba_repobject where gname = 'rep ';
SNAME ONAME GNAME STATUS
----------------------------------------------------------------------------------------------------
AR T REP VALID
Ar t $ RP REP VALID
Ar t $ RP REP VALID
Test again
Source database, insert two records, and copy them to the target database only after submission
AR @ leo1> insert into t values (1 );
1 row created.
AR @ leo1> select * from t;
X
----------
1
AR @ leo1> insert into t values (2 );
1 row created.
AR @ leo1> select * from t;
X
----------
1
2
AR @ leo1> commit;
Commit complete.
Target Database
AR @ leo2> select * from t;
X
----------
1
2
Source, update operation, submitted before being passed to the target database
AR @ leo1> update t set x = 10 where x = 1;
1 row updated.
AR @ leo1> update t set x = 20 where x = 2;
1 row updated.
AR @ leo1> commit;
Commit complete.
Target end
AR @ leo2> select * from t;
X
----------
10
20
DDL operation test. As mentioned above, Advanced Replication does not support DDL operations.
Source end
AR @ leo1> truncate table t;
Table truncated.
AR @ leo1> select * from t;
No rows selected
The target end is not cleared, and the source DDL operation does not affect the target end.
AR @ leo2> select * from t;
X
----------
10
20
The data constraints are automatically resolved, So GG and Streams will not be automatically resolved.
Source database
AR @ leo1> insert into t values (10 );
Insert into t values (10)
*
ERROR at line 1:
ORA-00001: unique constraint (AR. SYS_C007046) violated violates unique constraints
ORA-02063: preceding line from LEO2 from LEO2
Note: This constraint warning is not a problem with the source database t table, but when a transaction occurs, the Advanced Replication will immediately automatically check the data constraints at both ends,
When the value 10 in table t of the target database is found, a warning is immediately issued, indicating that the target database violates the constraint relationship ~ Global constraints.
AR @ leo2> select * from t;
X
----------
10
20
Global constraints: This is caused by distributed transactions. If a constraint conflict exists in the entire distributed environment, an alarm is triggered.
If we insert 30, there is no problem. It feels faster than GG and streams.
AR @ leo1> insert into t values (30 );
1 row created.
AR @ leo1> commit;
Commit complete.
AR @ leo2> select * from t;
X
----------
10
20
30