Objective
The growing demand for distributed applications requires a better distributed software environment, which drives the development of distributed technology. Oracle data replication is a technology for implementing distributed data environments, which can be used to create distributed data environments by copying data from different physical sites. Unlike a distributed database, in a distributed database, although each data object is also available to all sites, a particular data object exists only in a particular site. Data replication enables all sites to have copies of the same data objects available.
In a typical distributed business application, it is often necessary to back up the data of the region to the database at Headquarters, on the one hand, it can be used as a backup, on the other hand, it facilitates the comprehensive statistics in the headquarter application. This is a simple application in Oracle data replication, and this article will describe how to implement Oracle data replication with an example.
The reality is that company A is headquartered in Beijing, with three sales offices located in Shanghai (ORACLE, respectively). shanghai.com), Hangzhou (ORACLE. hangzhou.com) and Wuhan (ORACLE.
wuhan.com). Three business departments of the same software system, database structure is the same. It is now necessary to back up the data in all three sales offices to the database at Headquarters.
Preparatory work
There are a lot of things you need to prepare before replicating, and of course the basics are that the network must be unblocked, and then you need to collect some basic information about the replication environment:
1. Number of database sites that need to be replicated
2. Oracle version number for each site
3. The size of each database that needs to be replicated
4. The character set used by each database
5. The scenario name used for each data that needs to be replicated
After gathering the environment information, you can start to build a centralized database at Headquarters, the centralized database requires a version higher than all the main points of the version, preferably all databases are in the same character set. After building the library for each main site backup data to build a table space, table space is larger than the need to replicate the amount of data, as to reserve the future development of space depending on the actual situation.
Create a scenario for each primary site's corresponding replication data, and if each primary site uses a different scenario name, create a corresponding scenario with the same name in the centralized database site. Otherwise, the corresponding schema name is established for each primary site's replicated data. The actual situation is the latter, the database of each sales department is using Oracle's scheme name, here we establish three counterparts
Case: Shoracl, Hzoracl and Whoracl. All databases have a version of 9i.
Basic concepts
Before you copy, explain some of the concepts in replication:
1. Primary site (Mater site): The site that provides the data source during the replication process. such as the Shanghai database site in the figure above.
2. The materialized view site (materialized view site): The target site in the materialized view replication. such as the Beijing database site in the above figure.
3. Multi-agent Site Replication (multimaster Replication): The sites in the replication environment are the primary sites that have the same administrative permissions on the replicated database objects.
4. Materialized view replication (materialized view Replication): A principal site provides source replication objects, and a materialized view site copies primary site data.
5. Materialized view: Materialized the materialized view site for each replicated table or view to create a corresponding table to save the corresponding data, the table can only be through the Oracle replication mechanism for the operation of data deletion.
6. Quick Refresh, full refresh, and force refresh: three ways to refresh during replication. Quick Refresh copies only the changes to the source data object; Full refresh copy the source data object every time; Force Refresh is a compromise of the database and use full refresh if the quick refresh fails.
7. Principal group: A collection of source data objects that are replicated in the principal site.
8. Materialized View group (materialized view site): A collection of replicated objects in a materialized view site.
9. Materialized view log (materialized view log): A table that records the action log of the principal source data object in a materialized view copy using a quick refresh.
Synchronous replication and asynchronous replication are not explained, and this example uses asynchronous replication once a day.
For replication
Configure a good local Service name: Shanghai site: SH, Hangzhou site: HZ, Wuhan site: WH, Beijing site: BJ, into the sqlplus without login, let us start copying!