GoldenGate
Rudaiba Adnin
1
Contents
2
GoldenGate
3
GoldenGate Architecture Components
4
Golden Gate Workflow
5
Source Database
Capture (Local Extract)
Data Pump
Source Trail
Network
Collector
Remote Trail
Deliver (Replicate)
Target Database
Manager
Manager
Source Database
6
Source Database
Manager Process
7
Capture (Extract) Process
8
Source Database
Capture (Extract) Process
Extract Process
9
Source Database
Capture (Extract) Process
Classic capture vs Integrated capture
10
Classic capture
Integrated capture
Source Trail
11
Capture (Extract) Process
Source Trail Files
Data Pump
12
Data Pump
Source Trail
Data Pump
13
Source Database
Capture (Extract) Process
Data Pump Process
Source Trail
Target Database
Target Database
Target Database
Data Pump Process
Data Pump Process
What can go wrong if we do not have Data Pump process?
14
Data Pump Process
Source Trail Files
Network
15
Data Pump Process
Collector Process
Network
Collector Process
16
Delivery (Replicat) Process
17
Deliver (Replicate) Process
Remote Trail Files
Classic Replicat vs Integrated Replicat
18
Integrated Replicat
Classic Replicat
Target Database
19
Target Database
Deliver (Replicate) Process
Golden Gate Workflow
20
Source Database
Capture (Local Extract)
Data Pump
Source Trail
Network
Collector
Remote Trail
Deliver (Replicate)
Target Database
Manager
Manager
Initial Load & Change Sync
21
Two Important Terms
22
23
24
14 rows
0 rows
Source Table
Target Table
Initial Load
Change Synch
25
Capture (Local Extract)
Data Pump
Source Trail
Network
Collector
Remote Trail
Deliver (Replicat)
Source Table
Target Table
Initial Load
Do not start the replicat. Wait until Initial load completes to start the replicat
26
Capture (Local Extract)
Data Pump
Source Trail
Network
Collector
Remote Trail
Deliver (Replicat)
Source Table
Target Table
Initial Load (takes 4 hrs)
Configure change sync before initial load. Transaction happening in this 4 hours will be captured until the initial load completes.
27
Capture (Local Extract)
Data Pump
Source Trail
Network
Collector
Remote Trail
Deliver (Replicat)
Source Table
Target Table
Start the replicat after the initial load. (4hrs). Transaction that happened in these 4 hours will be replicated in the target.
Initial Load (takes 4 hrs)
28
How do you define initial load extract? How do you tell a extract is for initial load?
29
Initial Load Extract
Initial Load Replicat
Supported Topology by Golden Gate
30
31
Unidirectional Replication
Any database change on the source is replicated to the target.
32
Source Database
Target Database
Bidirectional Replication
Both the systems are active and receive transaction changes.
33
Primary Database
Secondary Database
One-to-many Replication
Source database is synchronized across multiple target databases.
34
Source Database
Target DatabaseA
Target DatabaseB
Many-to-one Replication
Data is sent from multiple source databases to one target database.
35
Target Database
Source DatabaseA
Source DatabaseB
Peer-to-peer Replication
Changes made on one site are propagated to all other sites.
36
Database A
Database B
Database D
Database C
Cascading Replication
Oracle GoldenGate propagates data changes from the source database to a second database, and then on to a third database.
37
Target DatabaseA
Target DatabaseA
Second Database
Source DatabaseA
GoldenGate Pre-installation Tasks
38
Design Consideration and Requirements
39
Design Consideration and Requirements
40
Replication Setup
41
Database Privileges for GoldenGate Users
42
Install Golden Gate
43
Installing Golden Gate
44
Create directory
Unzip the downloaded zip file in /u01/GG_SOFT
Update the bashrc file (Setting up environment variables) and run
export GG_HOME=/u01/app/GG_HOME
export PATH=$GG_HOME:$PATH
export LD_LIBRARY_PATH=$GG_HOME/lib:$LD_LIBRARY_PATH
45
Go to location
Update response file oggcore.rsp for silent installation
RUN the installer
Installing Golden Gate
46
Create the Golden Gate Schema Owner
A new user should be created to own the GoldenGate database objects in both the source and target servers.
On each server set the GGSCHEMA in the global parameter file.
47
[oracle@source]$ sqlplus / as sysdba
SQL> CREATE USER gg01 IDENTIFIED BY gg01;
SQL> GRANT CONNECT, RESOURCE, DBA TO gg01;
[oracle@source]$ ggsci
GGSCI (source) 1> EDIT PARAMS ./GLOBALS
Create GoldenGate Subdirectories
On each server create subdirectories for GoldenGate using the CREATE SUBDIRS command.
48
[oracle@source ]$ ggsci
GGSCI (source) 1> CREATE SUBDIRS
[oracle@target ]$ ggsci
GGSCI (target) 1> CREATE SUBDIRS
Enable GoldenGate Replication
Connect to database and enable goldengate replication.
[oracle@source]$ sqlplus / as sysdba
49
Run Role Setup Script in the Source Server
50
[oracle@source]$ sqlplus / as sysdba
Navigating Golden Gate
51
GG Process Status
52
Status | Meaning |
STARTING | Process just started, not ready yet |
RUNNING | Active |
STOPPED | Process is normally stopped |
ABENDED | Process is terminated, or abnormally ended |
GG Process Status
53
GG Process Status
54
GG Process Status
55
info <extract_name>, showch
56
If you do "info <extract_name>, showch", it will show you the recovery checkpoint and current checkpoint for the redo log reading position. Those output has SCN and timestamp info in it. The recovery checkpoint tracks the oldest open transaction Extract is reading from. The current checkpoint tracks the last committed transaction's SCN Extract just finished processing before stop.
RBA (Relative Byte Address)
The relative byte address (RBA) is the location within the trail file to indicate the current transaction. It is basically a marker within the trail file to identify the location of the transaction.
GG Directory Structure
57
Directory | Contained Files |
dirrpm | Parameter files |
dirpcs | Process status files |
dirchk | Checkpoint files |
dirdef | Database definition files |
dirdat | Stores the trail files |
dirtmp | Temporary files |
dirrpt | Report files/ Process specific alert logs |
[oracle@source]$ ggsci
GGSCI (source) 1> CREATE SUBDIRS
dirrpt
58
[oracle@source]$ ggsci
GGSCI (source) 1> View report EX1
dirrpt
Abended alert in EX1.rpt
Running status in EX1.rpt
59
dirrpt
Abended alert in dp1.rpt
60
GoldenGate Commands
61
Data Transformation Using Column Conversion Functions (Used with extract and replicat parameter files)
62
GGSCI COMMANDS
63
GGSCI COMMANDS
64
Native non-GGSCI COMMANDS
65
DEFGEN
LOGDUMP
Native non-GGSCI COMMANDS
66
Trail File Structure
Configure GoldenGate
67
Prepare Databases
Enable Forced Logging in source database
Enable Minimal Supplemental Logging so that rows updated on Source can be uniquely identified at Target and updated
68
[oracle@source]$ sqlplus / as sysdba
SQL> SELECT force_logging FROM v$database;
SQL> ALTER DATABASE FORCE LOGGING;
SQL> ALTER SYSTEM SWITCH LOGFILE;
[oracle@source]$ sqlplus / as sysdba
SQL> SELECT supplemental_log_data_min FROM v$database;
SQL> ALTER DATABASE ADD SUPPLEMENTAL LOG DATA;
Prepare Test Environment
Create Test User
69
[oracle@source]$ sqlplus / as sysdba
SQL> CREATE USER hr IDENTIFIED BY hr;
SQL> GRANT CONNECT, RESOURCE, DBA TO hr;
Configure Checkpoint Table
70
Configure VMs
71
Prepare VMs for Test Purpose
72
Configure GoldenGate
Unidirectional (source to target)
73
74
EX1
DP1
REP1
75
Configure Process Parameter files in Source server
76
Configure Supplemental Logging for Replicated Tables
On the source server configure supplemental logging for all tables that will be replicated.
Here, we will replicate all tables of HR schema.
Supplemental logging can be configured by any user that has privileges to modify the underlying database table.
[oracle@source]$ ggsci
GGSCI (source) 1> DBLOGIN USERID hr@//localhost:1521, PASSWORD oracle
GGSCI (source) 2> ADD TRANDATA hr.*
77
Configure Parameter Files in source server
78
Configure Manager Parameters
On both servers configure the MGR parameters.
The above command created the file : /u01/app/GG_HOME/dirprm/mgr.prm
Add the following parameters to the parameter file:
PORT 7809
DYNAMICPORTLIST 7810-7820
79
Configure Extract Parameters
On the source server, create the parameter file for Extract ex1:
[oracle@source]$ ggsci
GGSCI (source) 1> EDIT PARAMS ex1
The above command created the file /u01/app/GG_HOME/dirprm/ex1.prm
Add the following parameters to the new file:
80
Configure Datapump Parameters
On the source server create the parameter file for Data Pump
process dp1:
[oracle@source]$ ggsci
GGSCI (source) 1> EDIT PARAMS dp1
The above command created the file /home/oracle/goldengate/dirprm/dp1.prm
Add the following parameters to the new file:
81
Add Processes in Source server
Add the Extract Process: On the source server add the Extract process (ex1)
GGSCI (source) 1> ADD EXTRACT ex1, TRANLOG, BEGIN NOW
Add the Extract Trail: On the source server add the Extract trail (/home/oracle/goldengate/dirdat/ex)
GGSCI (source) 2>ADD EXTTRAIL /u01/app/GG_HOME/dirdat/ex, EXTRACT ex1
Add the Data Pump Process: On the source server add the Data Pump process (dp1)
GGSCI (source) 3> ADD EXTRACT dp1 EXTTRAILSOURCE/u01/app/GG_HOME/dirdat/ex
Add the Data Pump Trail: On the source server add the Data Pump trail (/u01/app/GG_HOME/dirdat/rt). This trail is created on the target server. However, the name is required in order to set up the Data Pump process on the source server.
GGSCI (source) 4> ADD RMTTRAIL /u01/app/GG_HOME/dirdat/rt, EXTRACT dp1
82
Add Processes in Source server
83
Configure Process Parameter files in Target server
84
Configure Checkpoint Table
85
[oracle@target]$ ggsci
GGSCI (target) 1> DBLOGIN USERID gg01@//localhost:1521, PASSWORD gg01
GGSCI (target) 1> ADD CHECKPOINTTABLE gg01.checkpointtable
GGSCI (target) 1> Edit params ./GLOBALS
Configure Parameter Files in Target Server
86
Configure Replicat Parameters
87
Add Replicat
On the target server add the Replication process (rep1)
[oracle@target]$ ggsci
GGSCI (target) 1> ADD REPLICAT rep1, EXTTRAIL /u01/app/GG_HOME/dirprm/dirdat/rt
88
Start Processes in Both Server
First start the GoldenGate manager and replicat processes on the target followed by the GoldenGate manager and extract processes on the source system.
89
Source
90
On the source server, start the GoldenGate manager:
[oracle@source]$ ggsci
GGSCI (source) 1> START MANAGER
GGSCI (source) 2> START EXTRACT ex1
GGSCI (source) 10> INFO EXTRACT ex1
On the source server, start the Data Pump (dp1):
GGSCI (source) 3> START EXTRACT dp1
GGSCI (source) 5> INFO EXTRACT dp1
Target
91
On the target server,
start the Replicat process (rep1):
[oracle@target]$ ggsci
GGSCI (target) 1> START REPLICAT rep1
GGSCI (target) 2> INFO REPLICAT rep1
Configure GoldenGate
Bidirectional
92
93
EXA
DPA
REPB
REPA
EXB
DPB
94
95
Some key considerations before setting up bidirectional replication using Oracle GoldenGate.
Add Trandata for in both serverA and serverB
Add checkpoint table in both serverA and serverB
96
Configure Parameterfiles in ServerA
97
Configure Parameter Files in ServerA
98
Configure Parameter Files in ServerA
Use the HANDLECOLLISIONS parameters to control whether or not Replicat tries to resolve duplicate-record and missing-record errors when applying SQL on the target.
When Oracle GoldenGate applies the replicated changes, HANDLECOLLISIONS provides Replicat with error-handling logic for these collisions.
The option EXCLUDEUSER or EXCLUDEUSERID of the parameter tranlogoptions explicitly avoid the re-capture of the transactions applied by specified user.
This requires using a dedicated Oracle GoldenGate user so that transactions applied by this user are eliminated - avoiding re-sending the transaction back to the originated system
99
Add processes
100
Configure Parameterfiles in ServerB
101
Configure Parameter Files in ServerB
102
Add processes
103
Testing in Some Specific Cases
104
Suggestions for Testing
105
Checking UPDATE and DELETE operation
106
107
Checking CLOB datatype
108
109
Instructions
110
id int not null primary key,
clobtest CLOB);
Checking BLOB datatype
111
112
Instructions
113
id int not null primary key,
blob_data BLOB
);
Insert files as BLOB datatype
Export BLOB file to other files
114
DECLARE
l_file UTL_FILE.FILE_TYPE;
l_buffer RAW(32767);
l_amount BINARY_INTEGER := 32767;
l_pos INTEGER := 1;
l_blob BLOB;
l_blob_len INTEGER;
BEGIN
SELECT blob_data
INTO l_blob
FROM tab1
WHERE id = 1;
l_blob_len := DBMS_LOB.getlength(l_blob);
l_file := UTL_FILE.fopen('BLOB_DIR','cat2.jpg','wb', 32767);
WHILE l_pos <= l_blob_len LOOP
DBMS_LOB.read(l_blob, l_amount, l_pos, l_buffer);
UTL_FILE.put_raw(l_file, l_buffer, TRUE);
l_pos := l_pos + l_amount;
END LOOP;
UTL_FILE.fclose(l_file);
EXCEPTION
WHEN OTHERS THEN
IF UTL_FILE.is_open(l_file) THEN
UTL_FILE.fclose(l_file);
END IF;
RAISE;
END;
/
DECLARE
l_bfile BFILE;
l_blob BLOB;
l_dest_offset INTEGER := 1;
l_src_offset INTEGER := 1;
BEGIN
INSERT INTO tab1 (id, blob_data)
VALUES (2, empty_blob())
RETURN blob_data INTO l_blob;
l_bfile := BFILENAME('BLOB_DIR', 'sunflower.jpg');
DBMS_LOB.fileopen(l_bfile, DBMS_LOB.file_readonly);
DBMS_LOB.loadblobfromfile (
dest_lob => l_blob,
src_bfile => l_bfile,
amount => DBMS_LOB.lobmaxsize,
dest_offset => l_dest_offset,
src_offset => l_src_offset);
DBMS_LOB.fileclose(l_bfile);
END;
/
Supported Datatypes
115
Data types, objects and operations that are supported by Oracle GoldenGate
There are different types for replication support:
116
Data types, objects and operations that are supported by Oracle GoldenGate
117
Preparing the database for Oracle Golden Gate
118
Thank You
119