Monday, May 25, 2020

Oracle GoldenGate 12c

Oracle GoldenGate Processes

  • Manager:
It is required for Stop and Start GoldenGate Extract, Pump and Replicat processes
  • Extract:
It reads database from online redo log files and optionally from archive log files and write data to local or remote trail files
  • Data Pump Extract:
It reads data from local trail file and writes data to remote trail over the TCP/IP network. It is an optional process but highly recommended
  • Collector:
It receives data from Pump Extract and writes data to remote trail files
  • Replicat:
It reads data from remote trail files and write to the database one transaction at a time
  • Trails and Files:
Trails files are required for continuous data replication. These files are canonical structured files which only GoldenGate process can read
  • Checkpoints:
It provides the transaction recovery in case GoldenGate processes stopped abnormally.
  • Wallet:
It is a secure common storage for User IDs and Passwords. It is highly recommended to use wallet for secure credentials.

Below diagram explains the logical architecture of an Oracle GoldenGate online replication.
GoldenGate TopologiesOracle GoldenGate modular architecture provides the ability to extract DML & DDL changes across variety of Topologies.
Oracle GoldenGate Utilities

  • GGSCI
GoldenGate Software Command Line Interface (GGSCI) is used to add, stop, start and manage GoldenGate Processes.
  • DEFGEN
This utility produces file containing a definition of the layouts of the source tables
  • LOGDUMP
It enables you to search or display information stored in the GoldenGate trails and file
  • REVERSE
It reorders operations within GoldenGate trail files in reverse sequence
  • KEYGEN
It is used to generate random hex keys. Needed only if you do not use wallet
  • INITIAL LOAD
- File to Replicat
Extract process write data to trail files and Replicat loads data using SQL on target DB
- File to Database Utility
Extract process write data to text files and Replicat loads data using DB utility on target
- Direct Load
Extract process gives data directly to Replicat & Replicat loads data using SQL on target
- Direct Bulk Load
Extract process gives data directly to Replicat & Replicat loads data using DB utility

Oracle GoldenGate 11g/12c Installation
Download latest Oracle GoldenGate 11g/12c from https://support.oracle.com

- Oracle GoldenGate 11g Installation
Login as OGG software owner
$ cd /ggs/home
$ $ p18918679_1121017_Linux-x86-64.zip
$ tar -xvof *.tar
$ ./ggsci
GGSCI> create subdirs
GGSCI> info all

- Oracle GoldenGate 12c Installation
Login as OGG software owner
$ unzip p27111516_122022_Linux-x86-64.zip
$ cd fbo_ggs_Linux_x64_shiphome/Disk1/response/
$ cp oggcore.rsp /u01/stage/
$ cd /u01/stage/
Open the response and edit the following parameters
$ vi oggcore.rsp
INSTALL_OPTION=ORA11g
SOFTWARE_LOCATION=/u01/app/oracle/product/ogg/12.2.0.22/gghome
START_MANAGER=true
MANAGER_PORT=7809
DATABASE_LOCATION=/u01/app/oracle/product/12.2.0/dbhome
INVENTORY_LOCATION=/u01/app/oraInventory
UNIX_GROUP_NAME=oinstall
$ ./runInstaller -silent -responseFile /u01/stage/oggcore.rsp

Below screenshot of non-silent based installation.


Now install like above on the second server as well and then check the status of manager service. 


ggsci> start mgr

If parameter file does not exist in 'dirprm' directory then create a parameter file and then start the manager service.

ggsci> edit param mgr

Minimum parameter required is the PORT=<port_number> and then the manager service will start on that port.

ggsci> start mgr
ggsci> info all

Below we will see the One-way replication in both CLASSIC and INTEGRATED ways,

The main difference between the classic capture and integrated capture modes is that in the classic capture the extract reads the Oracle database online redo log files/archive log files to capture changes while in the integrated capture mode the database log mining server reads the redo log files and captures changes. 
LCR (Logical Change Record) 



About Classic Capture


In classic capture mode, the Oracle GoldenGate Extract process captures data changes from the Oracle redo or archive log files on the source system or from shipped archive logs on a standby system. The following diagram illustrates the configuration of an Extract in classic capture mode.

Classic capture supports most Oracle data types fully, with restricted support for the complex data types. Classic capture is the original Oracle GoldenGate capture method. You can use classic capture for any source Oracle RDBMS that is supported by Oracle GoldenGate, with the exception of the multitenant container database.

You can use classic capture to support the following:

  • UDTs, VARRAYs, NOLOGGING LOBs with source database compatibility set below 11.2.0.0.0.
  • Transparent Data Encryption support with source database compatibility set below 11.0.0.0.0.
  • SECUREFILE LOB support with source database compatibility set below 11.2.0.0.0.
  • NOLOGGING LOB support with source database compatibility set below 11.2.0.0.0.

About Integrated Capture


In integrated capture mode, the Oracle GoldenGate Extract process interacts directly with a database logmining server to receive data changes in the form of logical change records (LCR). Below picture illustrates the configuration of Extract in integrated capture mode.
Integrated capture supports more data and storage types as compared to classic capture, and the support is more transparent.
The following are some additional benefits of integrated capture:

  • Because integrated capture is fully integrated with the database, no additional setup is required to work with Oracle RAC, ASM, and TDE.
  • Integrated capture uses the database logmining server to access the Oracle redo stream, with the benefit of being able to automatically switch between different copies of archive logs or different mirrored versions of the online logs. Thus integrated capture can transparently handle the absence of a log file caused by disk corruption, hardware failure, or operator error, assuming that additional copies of the archived and online logs are available
  • Integrated capture enables faster filtering of tables.
  • Integrated capture handles point-in-time recovery and RAC integration more efficiently.
  • Integrated capture features integrated log management. The Oracle Recovery Manager (RMAN) automatically retains the archive logs that are needed by Extract.
  • Integrated capture is the only mode that supports capture from a multitenant container database. One Extract can mine multiple pluggable databases within a multitenant container database.
  • For a release 11.2.0.4 source database and later (with source compatibility set to 11.2.0.4 or higher), the capture of DDL is performed by the logmining server asynchronously and requires no special triggers, tables, or other database objects to be installed. Oracle GoldenGate upgrades can be performed without stopping user applications. The use of a DDL trigger and supporting objects is required when Extract is in integrated mode with an Oracle 11g source database that is earlier than version 11.2.0.4.
  • Because integrated capture and integrated apply are both database objects, the naming of the objects follow the same rules as other Oracle Database objects
Oracle GoldenGate One-Way Replication Setup – Classic
High-levels to configure Oracle GoldenGate one-way replication in CLASSIC mode.
- Install OGG software on source and Target
- Configure OGG Manager process on source and target
GGSCI> Edit params mgr
PORT 7809
PURGEOLDEXTRACTS /ggs/home/dirdat/*, USECHECKPOINTS, MINKEEPDAYS 2
- Enable DB Supplemental logging on
SQL> alter database add supplemental log data;
SQL> select supplemental_log_data_min from v$database;
- Add Trandata on tables
GGSCI> dblogin userid ggs, password xxxxx
GGSCI> Add trandata SCOTT.*
- Configure Extract & Pump Extract Processes on source
GGSCI> edit params ext
EXTRACT intext
USERID ggs, PASSWORD xxxxx
EXTTRAIL ./dirdat/et
TABLE SCOTT.*;
GGSCI> add extract test, tranlog, begin now
GGSCI> add exttrail /ggs/home/dirdat/ex2c157a/et, extract ext, megabytes 100
GGSCI> start ext
GGSCI> edit params pext
EXTRACT pext
RMTHOST 192.168.10.1, MGRPORT 7809
RMTTRAIL /ggs/home/dirdat/rt
PASSTHRU
TABLE SCOTT.*;
GGSCI> add extract pext, exttrailsource /ggs/home/dirdat/et
GGSCI> add rmttrail /ggs/home/dirdat/rt, extract ptest, megabytes 100
GGSCI> start pext
- Perform Initial using your desired method (Expdp/impdp, RMAN, and so on)
$ expdp userid = ggs/xxxx flashback_scn = xxxxx directory = EXP_DIR dumpfile = expdp_src.dmp logfile = expdp_src.log status=60 schemas = SCOTT
$ impdp userid = ggs/xxxx directory = IMP_DIR dumpfile = expdp_src.dmp logfile = impdp_tgt.log status=60 remap_schemas = SCOTT:SCOTT
- Create checkpoint table
$ ./ggsci
GGSCI> dblogin userid ggs, password xxxx
GGSCI> add checkpointtable ggs.chkpoint_table
GGSCI> edit params ./GLOBALS
CHECKPOINTTABLE GGS.CHKPOINT_TABLE
GGSCI> exit
- Configure Replicat on Target
GGSCI> edit params rep
REPLICAT REP
USERID ggs, PASSWORD xxxxxx
ASSUMTARGETDEFS
MAP SCOTT.*, TARGET SCOTT.*;
GGSCI> dblogin userid ggs, password xxxxx
GGSCI> add replicat rep, exttrail /ggs/home/dirdat/rt
GGSCI> start replicat
GGSCI> info rep

Oracle GoldenGate One-Way Replication Setup – Integrated (12c)

[11.2.0.4 and above]

on source database
1. (a)SQL> alter system set ENABLE_GOLDENGATE_REPLICATION=true;

(b) Now create a common privileged user that has privilege to read data from different schemas. Create a user in container database with prefix c##. In 12c this user is common to all the pluggables present.

SQL> CREATE USER c##ogguser identified by oracle123;

2. SQL> alter database add supplemental log data (all) columns;
SQL> SELECT SUPPLEMENTAL_LOG_DATA_ALL from V$DATABASE;

SQL> ALTER SESSION SET CONTAINER=pdborcl;

3. SQL> GRANT DBA TO C##ogguser container=ALL;
Note: Database should be in archive log mode.

on target database
SQL> ALTER SYSTEM SET ENABLE_GOLDENGATE_REPLICATION=TRUE;
SQL> CREATE USER C##ogguser identified by oracle123 default tablespace ggs_tblsp;
SQL> ALTER SESSION SET CONTAINER=pdb2;
SQL> grant dba to c##ogguser;

Create Datastore
GGSCI> create wallet
GGSCI> add credentialstore
GGSCI> alter credentialstore add user ggs
GGSCI> info credentialStore
GGSCI> dblogin useridalias ggs

GGSCI> add trandata SCOTT.* ALLCOLS

Integrated Extract
SQL> EXEC DBMS_GOLDENGATE_AUTH.GRANT_ADMIN_PRIVILEGE(grantee => 'GGUSER');
$ cd $GGS_HOME
$ ./ggsci
GGSCI> EDIT PARAMS intext

EXTRACT intext
dblogin useridalias ggs
RMTHOST 192.168.10.1, MGRPORT 7809
TRANLOGOPTIONS INTEGRATEDPARAMS (MAX_SGA_SIZE 100)
RMTTRAIL ./dirdat/ie
TABLE SCOTT.*;

GGSCI> ADD EXTRACT intext, INTEGRATED TRANLOG, BEGIN NOW
GGSCI> dblogin useridalias ggs
GGSCI> REGISTER EXTRACT intext, DATABASE
GGSCI> ADD RMTTRAIL ./dirdat/ie, EXTRACT intext
GGSCI> start extract intext

Login to the source database and query the $GOLDENGATE_CAPTURE view to get the information about the integrated extract.
SQL> select sid, serial#,CAPTURE_NAME,STATE, SGA_USED from V$GOLDENGATE_CAPTURE;

Integrated Replicat
$ cd $GGS_HOME
$ ./ggsci
GGSCI> dblogin useridalias ggs
GGSCI> add checkpointtable ggs.chkpoint_table
GGSCI> edit params ./GLOBALS
CHECKPOINTTABLE GGS.CHKPOINT_TABLE
GGSCI> exit
GGSCI> Edit Param rint

Replicat rint
DBOPTIONS INTEGRATEDPARAMS(parallelism 6)
assumetargetdefs
discardfile ./dirrpt/rint.dsc, Purge
dblogin useridalias ggs
Map scott.*, target scott.*;

GGSCI> dblogin useridalias ggs
GGSCI> add Replicat rint Integrated exttrail ./dirdat/ie
GGSCI> Start Replicat rint
GGSCI> info all
SQL> connect / as sysdba
SQL> column replicat_name format a30
SQL> column server_name format a30
SQL> select replicat_name,server_name from DBA_GOLDENGATE_INBOUND;

Oracle GoldenGate Patching (12c)
It is assumed that base OGG software version 12.2.0.1.0 or 12.2.0.1.1 or 12.1.2.1.0 or 12.1.2.1.1 is already installed.
Steps:
Download and unzip patch in staging area
$ cd /stage
$ unzip *.zip  unzip patch
$ cd $GG_HOME
$ ./ggsci
GGSCI> version
$ export ORACLE_HOME=/u01/app/oracle/product/ogg/12.2.0.1.1/ogghome1
$ export PATH=$PATH:/u01/app/oracle/product/12.2.0/orcl/OPatch
$ opatch version
$ opatch lsinventory
$ ./ggsci
GGSCI> STOP ER *
GGSCI> STOP MANAGER
$ cd /stage/<patch_number>
$ opatch apply
$ export ORACLE_HOME=/u01/app/oracle/product/11.2.0/orcl
$ ./ggsci
GGSCI> START MANAGER
GGSCI> START ER *

Oracle GoldenGate Upgrade (12c)
It is assumed that we are upgrade OGG from 12.2.0.1.0 to 12.2.0.1.1
Steps:
Download and unzip patch in staging area
$ cd /stage
$ unzip *.zip  unzip patch
$ cd $GG_HOME
$ ./ggsci
GGSCI> stop er *
GGSCI> stop mgr!
$ cd /u01/app/oracle/product/ogg/12.2/ogghome1
$ cd ..
$ cp -pR ogghome1 ogghome1_bkp
$ cd /stage/xxx/Disk1
$ ./runInstaller  follow the on screen details to complete the installation
$ cd $GG_HOME
$ ./ggsci -v
$ cd /u01/app/oracle/product/ogg/12.2/ogghome1_bkp
cp -pR dir* $GG_HOME
$ ./ggsci
GGSCI> START MANAGER
GGSCI> START ER *

Oracle GoldenGate Initial Load Methods

  • Direct Load Method
- Create initial data load extract
$ cd $GG_HOME
$ ./ggsci
GGSCI> ADD EXTRACT ELOAD, SOURCEISTABLE
GGSCI> INFO EXTRACT ELOAD, TASKS
GGSCI> EDIT PARAMS ELOAD
EXTRACT ELOAD
USERID ggs, PASSWORD ggs
RMTHOST 10.10.10.2, MGRPORT 7809
RMTTASK REPLICAT, GROUP RLOAD
TABLE SCOTT.*;
GGSCI> ADD EXTRACT ELOAD, SOURCEISTABLE

- Create initial data Replicat process on target
$ cd $GG_HOME
$ ./ggsci
GGSCI> ADD REPLICAT RLOAD, SPECIALRUN
GGSCI> INFO RLOAD, TASKS
GGSCI> EDIT PARAMS RLOAD
REPLICAT RLOAD
USERID ggs, Password ggs
DISCARDFILE ./dirdat/rustarc.DSC, PURGE
BATCHSQL
MAP SCOTT.*, TARGET SCOTT.*;
GGSCI> ADD REPLICAT RLOAD, SPECIALRUN

- Start Initial Load on source only
GGSCI> start eload
GGSCI> info eload
GGSCI> info rload --> check on target

  • File to Replicat Method
- Create initial data load extract
$ cd $GG_HOME
$ ./ggsci
GGSCI> Edit Param eload
SOURCEISTABLE
USERID ggs, PASSWORD ggs
RMTHOST 10.10.10.2, MGRPORT 7809
-- Below rmtfile command will create 50 files of size 2GB each on target server
RMTFILE ./dirdat/el, maxfiles 50 MEGABYTES 2048
TABLE SCOTT.*;
GGSCI> exit
$ ./extract paramfile dirprm/eload.prm reportfile dirrpt/eload.rpt
$ ps -ef|grep eload
$ cat dirrpt/eload.rpt | more

- Create initial data Replicat process on target
$ cd $GG_HOME
$ ./ggsci
GGSCI> add rep rload, exttrail ./dirdat/el, nodbcheckpoint
GGSCI> EDIT PARAMS rload
Replicat RLOAD
USERID ggs, Password ggs
DISCARDFILE ./dirdat/rustarc.DSC, PURGE
DBOPTIONS SUPPRESSTRIGGERS
DBOPTIONS USEREPLICATIONUSER
BATCHSQL
MAP SCOTT.*, TARGET SCOTT.*;
GGSCI> start replicat rload
$ ps -ef|grep rload
$ cat dirrpt/rload.rpt | more

For any further queries please email me samiappsdba@gmail.com