The increasing demand for distributed applications requires a better distributed software environment, which constantly promotes the development of distributed technology.Oracle DatabaseReplication is a technology that implements a distributed data environment. It creates a distributed data environment by copying data on different physical sites. It is different from distributed databases. In distributed databases, although each data object is available to all sites, a specific data object only exists in a specific site. Data Replication allows all sites to copy the same data object.
In a typical distributed commercial application, you often need to back up data from different regions to the database at the Headquarters. On the one hand, it can be used as a backup method, and on the other hand, it facilitates the comprehensive statistics of the Headquarters application. This is a simple application of Oracle Data Replication. This article uses this example to describe how to implement Oracle Data replication.
The actual situation is that Company A is headquartered in Beijing and has three sales departments located in Shanghai (ORACLE. SHANGHAI. COM), Hangzhou (ORACLE. HANGZHOU. COM) and Wuhan (ORACLE. WUHAN. COM ). The three business departments have the same software system and database structure. Now we need to back up all the data from the three sales departments to the database at the headquarters.
Preparations
There are a lot of things to be prepared before replication, of course, the most basic thing is that the network must be smooth, and then you need to collect some basic information about the replication environment:
1. Number of database sites to be copied.
2. The Oracle version number of each site.
3. The size of each database to be copied.
4. character set used by each database.
5. The name of each solution used to copy the data.
After collecting environment information, you can start to build a centralized database at the Headquarters. a centralized database requires a version later than the version of all main battle sites. It is recommended that all databases use the same character set. After the database is created, create a tablespace for the backup data of each master site. The tablespace is larger than the data volume to be copied. The reserved development space depends on the actual situation.
Create a scheme for the corresponding replication data of each primary site. If the scheme names of each primary site are different, create a scheme with the same name on the centralized database site. Otherwise, a corresponding solution name is created for the copied data of each primary site. The actual situation is that the databases in various business departments use the Oracle solution name. Here we create three corresponding solutions: shyml, hzyml, and whyml. All database versions are 9i.
Basic Concepts
Before copying, explain the following concepts:
1. Primary Site Mater Site): the Site that provides the data source during the replication process. For example, the Shanghai database site.
2. Materialized View Site): the target Site in the Materialized View copy. For example, the Beijing database site.
3. Multi-Subject Site Replication Multimaster Replication): all sites in the Replication environment are master sites and have the same management permissions on the copied database objects.
4. Materialized View Replication): A subject site provides source Replication objects, and a Materialized View site copies data of the master site.
5. materialized View): Create a table for each copy table or View on the Materialized View site to save the corresponding data, this table can only be added, deleted, and modified using the Oracle replication mechanism.
6. fast refresh, full refresh, and forced Refresh: Three refresh methods during the replication process. Quick refresh only copies the changed part of the source data object. Full refresh copies the source data object once each time. Forced refresh is a compromise solution for the database. If the quick refresh fails, use full refresh.
7. Master Group): a collection of source data objects copied on the Master site.
8. Materialized View group Materialized View Site): a set of copying objects in the Materialized View Site.
9. Materialized View Log): The table that records the operation logs of the subject Source Data Objects During Quick refresh in the Materialized View copy.
Synchronous replication and asynchronous replication are not explained. In this example, asynchronous replication is performed once a day.