When OGG is used, data is synchronized one way between two Oracle databases.

Source: Internet
Author: User

When OGG is used, data is synchronized one way between two Oracle databases.

Configuration: source database 100.100.100.21 Instance name dbsid2

Target database 100.100.100.41 Instance name db1

Tutorial objective: to synchronize the scott user emp table in the source database to the test table in the target database scott

The installation package is the ogg1121020.fbo_ggs_linux_x64_ora10g_64bit.zip file.

Decompress the package, and then decompress tar-xvf fbo_ggs_Linux_x64_ora10g_64bit.tar-C/oracle/ogg/

1. source database (dbsid2) Configuration:

(1) user permission: grant dba to scott

(2) Open the archive Mode

(3) additional logs:
Alter database add supplemental log data;

Alter database force logging;

(4) Add the db1 information of the target database to tnsnames. ora.

2. target database (db1) Configuration:

(1) scott creates an empty table test with the same table structure as emp.

(2) Open the archive Mode

(3) additional logs:

Alter database add supplemental log data;

Alter database force logging;

(4) add the information of the source database (dbsid2) to tnsnames. ora.

3. Install the source database server goldengate

(1) decompress the package to the/oracle/ogg target

(2) Run./ggsci

(3) create a subdirectory: GGSCI (host2) 1> create subdirs

Creating subdirectories under current directory/oracle/ogg

Parameter files/oracle/ogg/dirprm: already exists

Report files/oracle/ogg/dirrpt: created

Checkpoint files/oracle/ogg/dirchk: created

Process status files/oracle/ogg/dirpcs: created

SQL script files/oracle/ogg/dirsql: created

Database definitions files/oracle/ogg/dirdef: created

Extract data files/oracle/ogg/dirdat: created

(4) configure the Port parameters for character Management

GGSCI (host2) 6> edit params mgr

Input: PORT 7809 and save

Check input:

GGSCI (host2) 7> view params mgr

PORT 7809

(5) Start mgr:

GGSCI (host2) 8> start mgr

MGR is already running.

GGSCI (host2) 9> info mgr

Manager is running (IP port host2.7809 ).

4. Install goldengate on the target database server (same as the source database server)

(1) decompress the package to the/oracle/ogg target

(2) Run./ggsci

(3) create a subdirectory: GGSCI (host2) 1> create subdirs

Creating subdirectories under current directory/oracle/ogg

Parameter files/oracle/ogg/dirprm: already exists

Report files/oracle/ogg/dirrpt: created

Checkpoint files/oracle/ogg/dirchk: created

Process status files/oracle/ogg/dirpcs: created

SQL script files/oracle/ogg/dirsql: created

Database definitions files/oracle/ogg/dirdef: created

Extract data files/oracle/ogg/dirdat: created

(4) configure the Port parameters for character Management

GGSCI (host2) 6> edit params mgr

Input: PORT 7809 and save

Check input:

GGSCI (host2) 7> view params mgr

PORT 7809

(4) Start mgr:

GGSCI (host2) 8> start mgr

MGR is already running.

GGSCI (host2) 9> info mgr

Manager is running (IP port host2.7809 ).

5. Configure the source database server (dbsid2) Transfer Process extract

(1) Add a process named source1

GGSCI (host2) 19> add extract source1, sourceistable

EXTRACT added.

(3) modify the source1 Parameter

GGSCI (host2) 20> edit params source1

Add and save

Extract source1

Setenv (NLS_LANG = AMERICAN_AMERICA.AL32UTF8)

Userid scott, password tiger

Rmthost 100.100.100.41, mgrport 7809

Rmttask replicat, group target1

Table scott. emp;

Note: 1. the username and password of the table to be copied are scott and tiger.

2. the IP address of the target database (db1) is 100.100.100.41, and the port is 7809.

3. The receiving process name of the target database (db1) is target1.

4. the table to be copied is the scott. emp table.

View modified Parameters

GGSCI (host2) 21> view params source1

6. Configure the target database db1 replicat receiving process

(1) Add a replicat process named source1

GGSCI (host2) 9> add replicat target1, specialrun

REPLICAT added.

(2) Add the modification parameter: GGSCI (host2) 13> edit params target1

Replicat target1

Setenv (NLS_LANG = AMERICAN_AMERICA.AL32UTF8)

Assumetargetdefs

Userid scott, password tiger

Discardfile./dirrpt/target1.dsc, purge

Map scott. emp, target scott. test;

Note: 1. The target database account is scott and tiger.

2. Synchronize scott. emp from the source database to the scott. test table.

View the modified

GGSCI (host2) 1> view params target1

7. The source database (dbsid2) starts synchronization.

(1) Start Synchronization

GGSCI (host2) 11> start extract source1

 

Sending START request to MANAGER...

EXTRACT SOURCE1 starting

(2) monitoring synchronization process

GGSCI (host2) 12> info all

Program Status Group Lag at Chkpt Time Since Chkpt

MANAGER RUNNING

 

(3) view synchronization logs in the source database

GGSCI (host2) 13> view report source1

8. View synchronization information in the target database (db1)

SQL> select * from test;


How can we synchronize data between two Oracle databases?

Execute timed exp database A, and then imp database B

Urgent: how can we synchronize data updates in two tables with the same structure between two oracle databases? dblink has been created

Can I use a trigger to implement the same data type? Take oracle database as an example. Two tables, test and test01, have the id name age sal.
Create or replace trigger TRIG_UPDATE_TEST
After insert or delete or update on test
For each row
Declare
Rochelle ID varchar2 (50 );
L_name varchar2 (50 );
Rochelle age number;
Rochelle Sal number;

Begin
If (deleting or updating) then
Delete test01
Where id =: old. id;
If (deleting) then
Return;
End if;
End if;

Rochelle id: =: new. id;
L_name: =: new. name;
Rochelle age: =: new. age;
L_sal: =: new. sal;
Begin
Insert into test01 (id, name, age, sal) values (l_id, l_name, l_age, l_sal );
End;
End TRIG_UPDATE_TEST;
To simplify the process, do not declare variables in the trigger, instead of using the new. Field.
Ah, no points

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.