Wednesday, October 26, 2016

Golden Gate : logdump >>  Find BAD or Corrupt trail files :

/path/ggs]$ logdump

Logdump 1 >open /opt/oracle/ggs/dirdat/ff000042
Current LogTrail is /opt/oracle/ggs/dirdat/ff000042
Logdump 2 >ghdr on
Logdump 4 >pos last
Reading forward from RBA 7702542
Logdump 5 >sfh prev
Scanned   16384 bytes
Scanned   32768 bytes
Scanned   49152 bytes
Scanned   65536 bytes
Scanned   65564 bytes and did not find a header
Logdump 6 >pos 0
Reading forward from RBA 0
Logdump 7 >count
Bad record found at RBA 7631536, format 5.50 Header token)     <<<<<<< Bad Files hence Trail file corrupted
0000 0000                                         | ....
LogTrail /opt/oracle/ggs/dirdat/ff000042 has 8861 records
Total Data Bytes           6592327
  Avg Bytes/Record             743
Insert                        5900
FieldComp                       42
LargeObject                   2918
Others                           1
After Images                  8860

Average of 5891 Transactions
    Bytes/Trans .....       1191
    Records/Trans ...          1
    Files/Trans .....          0

Logdump 8 >exit
Example of JDBC THIN and THICK client: Oracle 11g/12c with SCAN IP

THIN Client:
jdbc:oracle:thin:@(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = vip_db1.com)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = vip_db2.com)(PORT = 1521)) (LOAD_BALANCE = ON)(FAILOVER = ON))
(CONNECT_DATA = (SERVER = DEDICATED)(SERVICE_NAME = SERVICE_NAME.COM)(FAILOVER_MODE = (TYPE = SELECT)(METHOD = BASIC))))

Thick Client:

SERVICE_NAME.COM =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = SCAN_NAME.com)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = SERVICE_NAME.COM) ) )
What are the various Golden Gate sub directories for?
 
Question What are the functions of the various sub directories within the Golden Gate installation directory?
  • dirchk
Contains the checkpoint files created by Extract and Replicat processes, which store current read and write positions to support data accuracy and fault tolerance. Written in internal GoldenGate format. File name format is <group name><sequence number>.<ext> where <sequence number> is a sequential number appended to aged files and <ext> is either cpe for Extract checkpoint files or cpr for Replicate checkpoint files. Do not edit these files.
Examples: ext1.cpe rep1.cpr
  • dirdat
The default location for Golden Gate trail files and extract files created by Extract processes to store records of extracted data for further processing, either by the Replicate process or another application or utility. Written in internal Golden Gate format. File name format is a user-defined two-character prefix followed by either a six-digit sequence number (trail files) or the user-defined name of the associated Extract process group (extract files). Do not edit these files.
Examples: rt000001 finance
  • dirdef
The default location for data definitions files created by the DEFGEN utility to contain source or target data definitions used in a heterogeneous synchronization environment. Written in external ASCII. File name format is a user-defined name specified in the DEFGEN parameter file. These files may be edited to add definitions for newly created tables. If you are unsure of how to edit a definitions file, contact GoldenGate technical support.
Example: defs.dat
  • dirpcs
Default location for status files. File name is <group>.<extension> where <group> is the name of the group and <extension> is either pce (Extract), pcr (Replicat), or pcm (Manager). These files are only created while a process is running. The file shows the program name, the process name, the port and process id that is running. Do not edit these files.
Examples: mgr.pcm ext.pce
  • dirprm
The default location for GoldenGate parameter files created by GoldenGate users to store run-time parameters for GoldenGate process groups or utilities. Written in external ASCII format. File name format is <group name/user-defined name>.prm or mgr.prm. These files may be edited to change GoldenGate parameter values. They can be edited directly from a text editor or by using the EDIT PARAMS command in GGSCI.
Examples: defgen.prm finance.prm

  • dirrpt
The default location for process report files created by Extract, Replicat, and Manager processes to report statistical information relating to a processing run. Written in external ASCII format. File name format is <group name><sequence number>.rpt where <sequence number> is a sequential number appended to aged files. Do not edit these files.
Examples: ABC.rpt MGR4.rpt
  • dirsql
The default location for scripts created by the TRIGGEN utility to contain SQL syntax for creating GoldenGate logging triggers and GoldenGate log tables. Written in external format.
File name format is a user-defined name or the defaults of GGSLOG (table-creation script) or the table name (trigger-creation script), with the extension of .sql. These scripts can be edited if needed.
Examples: ggslog.sql account.sql
  • dirtmp
The default location for storing large transactions when the size exceeds the allocated memory size. Do not edit these files.
Golden Gate Sync Using EXPDP and IMPDP :

1. Find CURRENT_SCN or FLASHBACK SCN:
select CURRENT_SCN, dbms_flashback.get_system_change_number from v$database;
 
2. No need to stop the EXRACT and REPLICATE
   Source: EXPDP with FLASHBACK_SCN = 999999999
   scp expdp dump file to target server 

3. Target: IMPDP – import Metadata and data
STOP EXTRACT 
STOP REPLICATE
Added following command into REPLICATE.prm file for NEW TABLE only:
MAP Schema_Name.New_Table_Name ,TARGET Schema_Name.New_Table_Name ,
FILTER ( @GETENV ("TRANSACTION", "CSN") > 999999999);
START EXTRACT 
START REPLICATE
Golden Gate Sync Using EXPDP and IMPDP :

1. Find CURRENT_SCN or FLASHBACK SCN:
select CURRENT_SCN, dbms_flashback.get_system_change_number from v$database;
 
2. No need to stop the EXRACT and REPLICATE
   Source: EXPDP with FLASHBACK_SCN = 999999999
   scp expdp dump file to target server 

3. Target: IMPDP – import Metadata and data
STOP EXTRACT 
STOP REPLICATE
Added following command into REPLICATE.prm file for NEW TABLE only:
MAP Schema_Name.New_Table_Name ,TARGET Schema_Name.New_Table_Name ,
FILTER ( @GETENV ("TRANSACTION", "CSN") > 999999999);
START EXTRACT 
START REPLICATE

GoldenGate Installation : 11.2

Golden Gate Software:
GG Software:        Oracle Golden Gate v11.2.1.0.20 or Higher
Oracle Database:    Oracle 11gR2
Operating System:   Linux x86_64

 Source database Pre-request : 
ARCHIVE LOG LIST -- Database must be archive log mode
ADD SUPPLEMENTAL LOG DATA -- Enable supplement logging
RECYCLEBIN=OFF – Keep recycle bin off
ENABLE_GOLDENGATE_REPLICATION = TRUE -- Enable GG parameter

Installation of GG binaries: Source and Target  :
Setup environment:
export GG_HOME=/opt/oracle/ggs
export PATH=$PATH:/opt/oracle/ggs
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/opt/oracle/ggs

Download Golden Gate software from Oracle.com
cd $GG_HOME
unzip p18322848_1121020_Linux-x86-64.zip
tar -xvf fbo_ggs_Linux_x64_ora11g_64bit.tar
cd $GG_HOME

./ggsci
  GGSCI (nydevdb01) 1> create subdirs
  Creating subdirectories under current directory /opt/oracle/ggs
  Parameter files                /opt/oracle/ggs/dirprm: already exists
  Report files                   /opt/oracle/ggs/dirrpt: created
  Checkpoint files               /opt/oracle/ggs/dirchk: created
  Process status files           /opt/oracle/ggs/dirpcs: created
  SQL script files               /opt/oracle/ggs/dirsql: created
  Database definitions files     /opt/oracle/ggs/dirdef: created
  Extract data files             /opt/oracle/ggs/dirdat: created
  Temporary files                /opt/oracle/ggs/dirtmp: created
  Stdout files                   /opt/oracle/ggs/dirout: created
  GGSCI (nydevdb01) 2>exit
  mkdir discard
  Golden Gate software has been successfully installed.

Create Golden Gate Users: Source and Target:
 Source User Name: GGS_EXT
Target User Name: GGS_REP

Create a Table space GG_DATA – 2G Size –AUTOEXTEND ON
CREATE USER GGS_EXT IDENTIFIED BY GG_USER
DEFAULT TABLESPACE GG_DATA TEMPORARY TABLESPACE TEMP PROFILE DEFAULT ACCOUNT UNLOCK;

GRANT CONNECT, RESOURCE TO GG_USER;
GRANT SELECT ANY DICTIONARY, SELECT ANY TABLE TO GG_USER;
GRANT SELECT ANY TRANSACTION TO GG_USER;
GRANT FLASHBACK ANY TABLE TO GG_USER;
GRANT EXCUTE ON DBMS_FLASHBACK TO GG_USER;
GRANT EXECUTE ON UTL_FILE TO GG_USER;
GRANT CREATE ANY TABLE TO GG_USER;
GRANT INSERT ANY TABLE TO GG_USER;
GRANT UPDATE ANY TABLE TO GG_USER;
GRANT DELETE ANY TABLE TO GG_USER;
GRANT DROP ANY TABLE TO GG_USER;
GRANT UNLIMITED TABLESPACE TO GG_USER;
EXEC DBMS_GOLDENGATE_AUTH.GRANT_ADMIN_PRIVILEGE('GG_USER');

 GG Installation Verification: 
./ggsci
GGSCI> START MGR
GGSCI> INFO ALL
GGSCI>DBLOGIN USERID GGS_EXT, PASSWORD *****  
Successfully logged into database.


If need DDL Replication, run following Golden Gate scripts at Source database : 
 sqlplus / as sysdba
@marker_setup.sql  Enter Oracle GoldenGate schema name:GG_USER
@ddl_setup.sql     Enter Oracle GoldenGate schema name:GG_USER
@role_setup.sql    Enter Oracle GoldenGate schema name:GG_USER
grant ggs_ggsuser_role to GG_USER;
@ddl_enable;
--@ddl_pin GGATE; (optional)
--@sequence (optional)

 


 

GoldenGate integration in clusterware

 1. To start/stop manager - It will start golden on a node where GG VIP is running:
$ crsctl start res ggate
$ crsctl stop res ggate

2. To start manager on a specific node:
$ crsctl stop res ggate
$ crsctl start res ggate -n nodename -f

3. To relocate goldengate resource from existing node to new node:
$ crsctl relocate resource ggate –s existing_node –n new_node –f 

4.If below parameters are added in mgr.prm then replicat/extract will be started along with manager as well.:
AUTOSTART EXTRACT *
AUTORESTART EXTRACT *
AUTOSTART REPLICAT *
AUTORESTART REPLICAT *

 Steps to integrate GoldenGate in to clusterware:

 1. As a root user create an application VIP for Oracle GoldenGate :
appvipcfg create -network=1 -ip= XX.XX.XX.XX -vipname=app-oragg-vip -user=root
 
2. As a root user set read and execute privilege for ORACLE and GRID user on newly added application VIP:
 
crsctl setperm resource app-oragg-vip -u user:oracle:r-x
crsctl setperm resource app-oragg-vip -u user:grid:r-x
 
3. As an Oracle user start application VIP resource :
 crsctl start resource app-oragg-vip
 
4. Prepare action script for handling GoldenGate resource in a cluster. 
 
5. As an Oracle users add clusterware resource for it:
crsctl add resource ggate -type cluster_resource -attr "ACTION_SCRIPT=
/path/ggs/gg_action.sh,CHECK_INTERVAL=30, START_DEPENDENCIES=
'hard(app-oragg-vip,ora.asm) pullup(app-oragg-vip)', STOP_DEPENDENCIES=
'hard(app-oragg-vip)'" 

6.As a root make Oracle as an owner of GoldenGate resource in the cluster :
 
 crsctl setperm resource ggate -o oracle
 
7. As an Oracle user start GoldenGate resource :
  crsctl start res ggate

Oracle Support Documents referred –

1. Doc ID - 1112506.1

2. Doc ID - 1313703.1