This article briefly introduces the advanced replication function of ORACLE, and discusses how to use advanced replication to achieve data unification between the Intranet and the Internet through an actual project, finally, the configuration script is provided for your reference. 1. Basic Concepts ORACLEORACLE is a large-scale relational database based on advanced Structured Query Language (SQL ).
This article briefly introduces the advanced replication function of ORACLE, and discusses how to use advanced replication to achieve data unification between the Intranet and the Internet through an actual project, finally, the configuration script is provided for your reference. 1. Basic Concepts ORACLE is a large-scale relational database based on advanced Structured Query Language (SQL ).
This article briefly introduces the advanced replication function of ORACLE, and discusses how to use advanced replication to achieve data unification between the Intranet and the Internet through an actual project, finally, the configuration script is provided for your reference.
1. Basic Concepts
ORACLE
ORACLE is a large-scale relational database based on advanced Structured Query Language (SQL). It is a set of regular data manipulation in a language that facilitates logical management. It is one of the databases in the CLIENT/SERVER architecture.
Advanced Replication
What is replication? Simply put, replication is the process of copying data in a distributed database environment consisting of two or more database systems.
Advanced Replication is the process of copying and maintaining database objects in multiple databases that constitute a distributed database system. Oracle Advanced Replication allows applications to update any copies of a database and automatically pass these changes to other databases while ensuring consistency and data integrity of global transaction processing.
Synchronous replication: the copied data is consistent at any time on any replication node. If the replication data of any node in the replication environment is updated, this change is immediately reflected to all other replication nodes. This technology applies to commercial applications with high real-time requirements.
During asynchronous replication, data on all replication nodes is not synchronized for a certain period of time. If the replication data of one of the nodes in the replication environment is updated, this change will be propagated and applied to all other replication nodes in different transactions. The interval between these different transactions can be several seconds, several minutes, several hours, or several days later. Data between replication nodes is temporarily not synchronized, but the propagation will eventually ensure data consistency between all replication nodes.
2. Project Information
Requirement Description
This is an internal/external structure approval system.
The Internet has a WEB (+ APPSERVER) and a DB (ORACLE9.2, dual-nic), which is responsible for receiving the application and feedback the approval results.
The Intranet has a WEB (+ APPSERVER) and a DB (ORACLE9.2, dual-nic). It is responsible for receiving the application and feedback of the approval results, and processing the approval application from the Internet through the approval process.
As shown in the preceding figure, Intranet functions include Internet functions. However, CA authentication is required for Internet reporting, and Intranet authentication is not required.
According to national confidentiality regulations, the Intranet and Internet of the government system must be physically isolated. Therefore, the applications received by the Internet cannot be immediately reflected in the Intranet. Likewise, the Intranet processing results cannot be quickly fed back to the Internet.
Technical select'
We chose ORACLE asynchronous manual replication to complete the following functions:
1. Copy the new external network application data to the Intranet;
2. Report the reporting result from the Intranet to the Internet.
Operation implementation
During normal working hours, the Intranet and Internet cannot be paused, while the Intranet and Internet cannot be physically connected. Therefore, the maintenance period is set to (or other time periods) every night. During this period, the Internet and Intranet are stopped, and the system administrator disconnects all network cables connected to the DB, connect two databases with a direct connection network cable. Refresh the records manually on the outer network end through the operation interface provided by ORACLE.
3. Specific implementation steps
The following are the technical parameters used in the script. The internal and external tables have the same structure and have primary keys.
Intranet and Internet
IP 192.168.0.50 192.168.0.100
SID ORANEI ORAWAI
Table LAWTABLE
REGISTER
USERINFO
......
68 table LAWTABLE
REGISTER
Two tables in total
Login Name/password HOLEN/HOLEN
The following is the SQL script we used to install at the client.
Step 1: configure the Intranet, that is, the MASTER
-- Version 2.0
-- Revised by: Chen guang holen@263.net
-- Time:
-- Intranet as MASTER
-- Create an Intranet user HOLEN
Conn system/PASSWORD @ ORANEI
Create user "HOLEN" PROFILE "DEFAULT" identified by "HOLEN ";
GRANT "CONNECT" TO "HOLEN ";
GRANT "DBA" TO "HOLEN ";
GRANT "RESOURCE" TO "HOLEN ";
-- Import the intranet database backup, which is completed in dos (Table LAWTABLE, REGISTER, and other tables)
Step 2: configure the Intranet, that is, the MASTER end (continued)
-- The table to be copied (synchronized) is LAWTABLE and REGISTER under the HOLEN user.
-- Create a repadmin user to manage the replication Environment
Create user repadmin identified by repadmin;
Alter user repadmin default tablespace users;
Alter user repadmin temporary tablespace temp;
GRANT connect, resource to repadmin;
-- Grant repadmin user permissions to manage any subject group on the current site
EXECUTE dbms_repcat_admin.grant_admin_any_schema ('repadmin ');
-- Grant the repadmin user permission to create a snapshot logs for any table
GRANT comment any table to repadmin;
GRANT lock any table to repadmin;
-- Specify the repadmin user as propagator and grant the permission to execute any procedure.
EXECUTE dbms_defer_sys.register_propagator ('repadmin ');
GRANT execute any procedure to repadmin;
-- Grant proxy snapshot administration permission to repadmin. If list_of_gnames is null, all object groups can be managed.
BEGIN
Dbms_repcat_admin.register_user_repgroup (
Username => 'repadmin ',
Privilege_type => 'proxy _ snapadmin ',
List_of_gnames => NULL );
END;
/
-- Assign the 'Explorer' permission to repadmin.
BEGIN
Dbms_repcat_admin.register_user_repgroup (
Username => 'repadmin ',
Privilege_type => 'Explorer ',
List_of_gnames => NULL );
END;
/
GRANT select any table TO repadmin;
-- Create a principal group on ORANEI. The principal group is named HOLEN_MASTER and a table is added to the principal group.
-- Create a copy subject group
BEGIN
DBMS_REPCAT.CREATE_MASTER_REPGROUP (
Gname => '"HOLEN_MASTER "',
Qualifier => '',
Group_comment => '');
END;
/
Connect repadmin/REPADMIN;
-- Add the table object LAWTABLE to the replication group
BEGIN
DBMS_REPCAT.CREATE_MASTER_REPOBJECT (
Gname => '"HOLEN_MASTER "',
Type => 'table ',
OnAme => '"LAWTABLE "',
Sname => '"HOLEN "',
Copy_rows => TRUE,
Use_existing_object => TRUE );
END;
/
-- Create the corresponding snapshot log
CREATE SNAPSHOT LOG
ON "HOLEN". "LAWTABLE"
TABLESPACE "SYSTEM"
WITH PRIMARY KEY
Excluding new values;
-- Generate replication support
BEGIN
DBMS_REPCAT.GENERATE_REPLICATION_SUPPORT (
Sname => '"HOLEN "',
OnAme => '"LAWTABLE "',
Type => 'table ',
Min_communication => TRUE,
Generate_80_compatible => FALSE );
END;
/
-- Add the table object REGISTER to the replication group
BEGIN
DBMS_REPCAT.CREATE_MASTER_REPOBJECT (
Gname => '"HOLEN_MASTER "',
Type => 'table ',
OnAme => '"REGISTER "',
Sname => '"HOLEN "',
Copy_rows => TRUE,
Use_existing_object => TRUE );
END;
/
CREATE SNAPSHOT LOG
ON "HOLEN". "REGISTER"
TABLESPACE "SYSTEM"
WITH PRIMARY KEY
Excluding new values;
BEGIN
DBMS_REPCAT.GENERATE_REPLICATION_SUPPORT (
Sname => '"HOLEN "',
OnAme => '"REGISTER "',
Type => 'table ',
Min_communication => TRUE,
Generate_80_compatible => FALSE );
END;
/
-- MASTER end configuration is complete
Step 3: configure the Internet, that is, the SNAPSHOT end.
-- Use the Internet as a SNAPSHOT
-- Create an Internet user HOLEN
Conn system/PASSWORD @ ORAWAI
-- Create a common user
Create user "HOLEN" PROFILE "DEFAULT" identified by "HOLEN ";
GRANT "CONNECT" TO "HOLEN ";
GRANT "DBA" TO "HOLEN ";
GRANT "RESOURCE" TO "HOLEN ";
-- Create a repadmin user to manage the snapshot copy Environment
Create user repadmin identified by repadmin;
Alter user repadmin default tablespace users;
Alter user repadmin temporary tablespace temp;
GRANT connect, resource to repadmin;
-- Grant repadmin user permissions to manage any subject group on the current site
EXECUTE dbms_repcat_admin.grant_admin_any_schema ('repadmin ');
-- Grant the repadmin user permission to create a snapshot logs for any table
GRANT comment any table to repadmin;
GRANT lock any table to repadmin;
-- Specify the repadmin user as propagator and grant the permission to execute any procedure.
EXECUTE dbms_defer_sys.register_propagator ('repadmin ');
GRANT execute any procedure to repadmin;
-- Grant the repadmin user the permission to create snapshots.
GRANT create any snapshot to repadmin;
GRANT alter any snapshot to repadmin;
-- Establish a connection with the intranet on the Internet
-- Add ORANEI to the tree on the outer network side
Create public database link oranei connect to repadmin identified by repadmin using 'oranei ';
-- Create a refresh group HOLEN_REFRESH on the Internet
BEGIN
DBMS_REFRESH.MAKE (
Name => '"HOLEN". "HOLEN_REFRESH "',
List => '',
Next_date => SYSDATE,
Interval => '/* 1: Mins */sysdate + 1/(60*24 )',
Implicit_destroy => FALSE,
Lax => FALSE,
Job => 0,
Rollback_seg => NULL,
Push_deferred_rpc => TRUE,
Refresh_after_errors => TRUE,
Purge_option => NULL,
Parallelism => NULL,
Heap_size => NULL );
END;
/
-- Create a snapshot group on the Internet
BEGIN
DBMS_REPCAT.CREATE_SNAPSHOT_REPGROUP (
Gname => '"HOLEN_MASTER "',
Master => 'oranei. US. ORACLE. com ',
Propagation_mode => 'asynchronous ');
END;
/
-- Create a snapshot. the snapshot must be created under the user to which the table belongs. In this example, log in with the HOLEN user.
Connect holen/HOLEN;
-- Create a snapshot LAWTABLE
Create snapshot "HOLEN". "LAWTABLE"
REFRESH FAST FOR UPDATE
As select * FROM "HOLEN". "LAWTABLE" @ ORANEI. US. ORACLE. COM C
/
-- Add a snapshot to the refresh Group
BEGIN
DBMS_REFRESH.ADD (
Name => '"HOLEN". "HOLEN_REFRESH "',
List => '"HOLEN". "LAWTABLE "',
Lax => TRUE );
END;
/
-- Add a snapshot to a snapshot Group
BEGIN
DBMS_REPCAT.CREATE_SNAPSHOT_REPOBJECT (
Gname => '"HOLEN_MASTER "',
Sname => '"HOLEN "',
OnAme => '"LAWTABLE "',
Type => 'snapshot ',
Min_communication => FALSE );
END;
/
-- Create a snapshot REGISTER
Create snapshot "HOLEN". "REGISTER"
REFRESH FAST FOR UPDATE
As select * FROM "HOLEN". "REGISTER" @ ORANEI. US. ORACLE. COM C
/
-- Add a snapshot to the refresh Group
BEGIN
DBMS_REFRESH.ADD (
Name => '"HOLEN". "HOLEN_REFRESH "',
List => '"HOLEN". "REGISTER "',
Lax => TRUE );
END;
/
-- Add a snapshot to a snapshot Group
BEGIN
DBMS_REPCAT.CREATE_SNAPSHOT_REPOBJECT (
Gname => '"HOLEN_MASTER "',
Sname => '"HOLEN "',
OnAme => '"REGISTER "',
Type => 'snapshot ',
Min_communication => FALSE );
END;
/
-- SNAPSHOT is configured.
Step 4: configure the Intranet
-- After the Internet is configured, run the following statement on the Intranet:
BEGIN
DBMS_REPCAT.RESUME_MASTER_ACTIVITY (
Gname => '"HOLEN_MASTER "');
END;
/
4. Postscript
The Advanced Replication function of ORACLE is very powerful, and it can implement data synchronization and asynchronous replication between multiple points.
The submission, approval, and record filing of Intranet and Internet structures are becoming increasingly popular. If the internal and external databases are commercial databases of the same type, the database itself provides the replication function, if the Intranet and Intranet are different types of databases, for example, if the Intranet is SQLSERVER and the Internet is ORACLE, the "synchronization Machine" middleware is generally used and can be called in the program.