Professional Documents
Culture Documents
GoldenGate - Installation (Oracle 11g On Linux)
GoldenGate - Installation (Oracle 11g On Linux)
Oracle GoldenGate enables the exchange and manipulation of data at the transaction
level among multiple, heterogeneous platforms across the enterprise. It moves
committed transactions with transaction integrity and minimal overhead on your
existing infrastructure. Its modular architecture gives you the flexibility to extract and
replicate selected data records, transactional changes, and changes to DDL (data
definition language) across a variety of topologies.
In this blog I am writing about oracle to oracle DB replication by using GoldenGate. Aim
of this demonstration if replicate all changes in one particular schema (include DDL)
from one oracle DB to another Oracle DB. For this purpose I have created two oracle DB
on same host from different users.
1. First of all, install Golden Gate software on each Oracle DB. Step1
process is same for both the database.
export PATH=$PATH:/u01/app/oratest/ggate
export
LD_LIBRARY_PATH=/u01/app/oratest/product/11.2.0/dbhome_1/lib:/u01/app/orate
st/ggate
Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights reserved.
We then need to create a database user which will be used by the GoldenGate Manager,
Extract and Replicat processes. We can create individual users for each process or
configure just a common user in our case we will create the one user GGS_OWNER
and grant it the required privileges.
LOG_MODE
------------
ARCHIVELOG
Prepare the database for DDL replication. Turn off the recyclebin feature and be
sure that it is empty.
2.3) create a schema that will contain the Oracle GoldenGate DDL objects.
SQL> create tablespace gg_tbls datafile
'/u01/app/ora1103/oradata/ora1103/gg_tbls.dbf' size 100m reuse autoextend on;
Tablespace created.
SQL> create user ggate identified by oracle default tablespace gg_tbls quota
unlimited on gg_tbls;
User created.
SQL> grant create session, connect, resource to ggate;
Grant succeeded.
SQL> grant dba to ggate;
Grant succeeded.
SQL> grant execute on utl_file to ggate;
Grant succeeded.
2.4) Change the directory on Golden Gate home directory and run scripts
for creating all necessary objects for support ddl replication.
SQL> @marker_setup.sql
SQL> @ddl_setup.sql
SQL> @role_setup.sql
SQL> grant GGS_GGSUSER_ROLE to ggate;
SQL> @ddl_enable.sql
2.5) after that, add information about your Oracle GoldenGate DDL scheme
into file GLOBALS. You should input this row into the file "GGSCHEMA
ggate".
Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights reserved.
GGSCI (localhost.localdomain) 1> EDIT PARAMS ./GLOBALS
GGSCHEMA ggate
GGSCI (localhost.localdomain) 2>
3. Create the schemes for replication on both hosts (ora1103 (db1), dup
(db2)).
3.1. Source database (db1):
SQL> create user source identified by oracle default tablespace users temporary
tablespace temp;
User created.
SQL> grant connect,resource,unlimited tablespace to source;
Grant succeeded.
SQL> create user target identified by oracle default tablespace users temporary
tablespace temp;
User created.
SQL> grant connect,resource,unlimited tablespace to target;
Grant succeeded.
SQL> grant dba to target; -- OR any particular grants
Grant succeeded.
4. Create the directory for trail files on both hosts and create directory for
discard file on db2 host only.
Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights reserved.
GGSCI (localhost.localdomain) 1> edit params mgr
PORT 7809
GGSCI (localhost.localdomain) 2> start manager
Manager started.
GGSCI (localhost.localdomain) 3> info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING
GGSCI (localhost.localdomain) 4>
5.1b) Login into database and add additional information about primary
keys into log files.
NOTE: This is a very important step, because if you don't do it you will not be able
to replicate Update statements. You will get errors like the following:
OCI Error ORA-01403: no data found, SQL
As you know, when you write the update statement you usually don't change the
primary key, so Oracle log files contain information about changing column values
and don't contain information about primary key. For avoiding this situation you
should add this information into log files using ADD SCHEMATRANDATA or ADD
TRANDATA commands. Add extracts (regular and data pump).
5.1c)
[ora1103@localhost ggate]$ ggsci
Oracle GoldenGate Command Interpreter for Oracle
Version 11.2.1.0.3 14400833
OGGCORE_11.2.1.0.3_PLATFORMS_120823.1258_FBO
Linux, x64, 64bit (optimized), Oracle 11g on Aug 23 2012 20:20:21
Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights reserved.
GGSCI (localhost.localdomain) 1> add extract ext1, tranlog, begin now
EXTRACT added.
5.1d)
GGSCI (localhost.localdomain) 5> add extract pump1, exttrailsource
/u01/app/ora1103/ggate/dirdat/tr , begin now
EXTRACT added.
Target:
5.2b)
Create the checkpoint table and change the GLOBAL file.
5.3b)
[oratest@localhost ggate]$ ggsci
Oracle GoldenGate Command Interpreter for Oracle
Version 11.2.1.0.3 14400833
OGGCORE_11.2.1.0.3_PLATFORMS_120823.1258_FBO
Linux, x64, 64bit (optimized), Oracle 11g on Aug 23 2012 20:20:21
Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights reserved.
GGSCI (localhost.localdomain) 5> start replicat rep1
Sending START request to MANAGER ...
REPLICAT REP1 starting
GGSCI (localhost.localdomain) 6> info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING
REPLICAT RUNNING REP1 00:00:00 00:00:00
GGSCI (localhost.localdomain) 7>
6.1 At source:
SQL> create table test (id number primary key, name varchar2(50));
Table created.
SQL> insert into test values (1,'test');
1 row created.
SQL> insert into test values (2,'test');
1 row created.
SQL> commit;
Commit complete.
6.1 at Target:
ID NAME
---------- --------------------------------------------------
1 test
2 test
As you can see, all works. Lets execute some more SQLs and Update statements.
Source db:
At Target:
SQL> select * from test;
ID NAME
---------- --------------------------------------------------
1 test
3 test3
ID NAME
---------- --------------------------------------------------
1 test
3 test3
4 test
Conclusion:
---------------
Oracle GoldenGate is a software package for enabling the replication of data in
heterogeneous data environments. It is easy to use. It provide other great feature
such as zero downtime upgrade of database, replication between different kind of
databases and data transformation from source to targets and many others. It has
a rich topology to deploy as per the requirements.