implementación de replicacion dml unidireccional...

33
Implementación de Replicación DML Unidireccional mediante Oracle GoldenGate 1 Implementación de Replicación DML Unidireccional mediante Oracle GoldenGate Autor : Luis Alberto Flores Zapata Creado : 18-07-2016

Upload: truongtuyen

Post on 03-May-2018

214 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Implementación de Replicacion DML Unidireccional …orateam.com/wp-content/uploads/2016/07/...mediante-Oracle-Golden… · Implementación de Replicación DML Unidireccional mediante

Implementación de Replicación DML Unidireccional mediante Oracle GoldenGate

1

Implementación de Replicación DML Unidireccional mediante Oracle

GoldenGate

Autor : Luis Alberto Flores Zapata Creado : 18-07-2016

Page 2: Implementación de Replicacion DML Unidireccional …orateam.com/wp-content/uploads/2016/07/...mediante-Oracle-Golden… · Implementación de Replicación DML Unidireccional mediante

Implementación de Replicación DML Unidireccional mediante Oracle GoldenGate

2

Contenido 1. INTRODUCCION ......................................................................................................................................... 4

2. ALCANCE .................................................................................................................................................... 4

3. CARACTERISTICA DE LA PLATAFORMA ...................................................................................................... 5

3.1. ORIGEN.............................................................................................................................................. 5

3.2. DESTINO ............................................................................................................................................ 5

4. OBJETOS DE REPLICACION ......................................................................................................................... 5

5. CONFIGURACIONES DE BD STRMDB ......................................................................................................... 6

6. CREACION DE USUARIO ADMINISTRADOR DE GOLDENGATE EN LA BD STRMDB .................................... 6

7. CONFIGURACIONES DE BD RAC POCTEST .................................................................................................. 8

8. CREACION DE USUARIO ADMINISTRADOR DE GOLDENGATE EN LA BD RAC POCTEST ............................ 9

9. CREACION DE SERVICIO TAF PARA BD RAC POCTEST .............................................................................. 10

10. CONFIGURACION VARIABLES DE AMBIENTE ....................................................................................... 11

10.1. CONFIGURACION VARIABLES DE AMBIENTE STRMDB ............................................................... 11

10.2. CONFIGURACION VARIABLES DE AMBIENTE BD RAC POCTEST .................................................. 11

11. INSTALACION ORACLE GOLDENGATE .................................................................................................. 12

11.1. INSTALACION ORACLE GOLDENGATE EN ORIGEN (apps03) ...................................................... 12

11.2. INSTALACION ORACLE GOLDENGATE EN DESTINO (oraprd01- oraprd02) ................................. 13

12. CONFIGURAR LOS DIRECTORIOS DE GOLDENGATE ............................................................................. 15

12.1. CONFIGURAR LOS DIRECTORIOS DE GOLDENGATE EN ORIGEN (apps03) USANDO GGSCI ........ 15

12.2. CONFIGURAR LOS DIRECTORIOS DE GOLDENGATE EN DESTINO (oraprd01- oraprd02) USANDO

GGSCI 16

13. CONFIGURACIÓN D EL PARAMETER FILE GLOBALS ............................................................................. 16

13.1. PARAMETER FILE GLOBALS EN ORIGEN (apps03) ....................................................................... 16

13.2. PARAMETER FILE GLOBALS EN DESTINO (oraprd01- oraprd02) ................................................. 16

14. CONFIGURACIÓN DEL MANAGER PROCESS ........................................................................................ 17

14.1. MANAGER PROCESS EN ORIGEN (apps03) ................................................................................. 17

14.2. MANAGER PROCESS EN DESTINO (oraprd01- oraprd02) ........................................................... 17

15. CONFIGURACION DEL EXTRACT PROCESS ........................................................................................... 18

15.1. EXTRACT PROCESS EXHR01......................................................................................................... 18

15.2. AÑADIR EL EXTRACT PROCESS AL GOLDENGATE ........................................................................ 18

Page 3: Implementación de Replicacion DML Unidireccional …orateam.com/wp-content/uploads/2016/07/...mediante-Oracle-Golden… · Implementación de Replicación DML Unidireccional mediante

Implementación de Replicación DML Unidireccional mediante Oracle GoldenGate

3

15.3. AÑADIR SUPPLEMENTAL LOGIN A TODAS LAS TABLAS QUE SERÁN PARTE DE LA REPLICACION 19

15.4. AÑADIR EL TRAIL FILE LOCAL AL GOLDENGATE Y ASOCIARLO CON EL EXTRACT PROCESS ........ 19

15.5. REGISTRAR EL EXTRACT PROCESS, A FIN DE MANTENER LOS LOGS REQUERIDOS PARA LA

RECUPERACION ............................................................................................................................................ 20

16. CONFIGURACION DEL DATAPUMP PROCESS ...................................................................................... 20

16.1. DATA PUMP PROCESS DPHR01 ................................................................................................... 20

16.2. AÑADIR EL DATA PUMP PROCESS AL GOLDENGATE .................................................................. 20

16.3. AÑADIR EL TRAIL FILE REMOTO AL GOLDENGATE Y ASOCIARLO CON EL DATA PUMP PROCESS

21

17. CONFIGURACION DEL REPLICAT PROCESS .......................................................................................... 21

17.1. REPLICAT PROCESS TLHR01 ........................................................................................................ 21

17.2. CREAR UNA TABLA DE CHECKPOINT ........................................................................................... 22

17.3. AÑADIR EL REPLICAT PROCESS AL GOLDENGATE ....................................................................... 22

18. CARGA INICIAL ..................................................................................................................................... 22

18.1. OBTENER EL SCN ACTUAL DE LA BD STRMDB............................................................................. 22

18.2. REALIZAR EXPORT DATAPUMP DE TODAS LAS TABLAS DEL SCHEMA HR EN BD STRMDB ......... 23

18.3. REALIZAR IMPORT DATAPUMP DE TODAS LAS TABLAS DEL SCHEMA HR EN BD RAC POCTEST 24

19. ALTERAR LOS ATRIBUTOS DEL EXTRACT EXHR01 AL SCN UTILIZADO POR EL EXPORT ........................ 25

20. INICIAR EL MANAGER EN ORIGEN (apps03) ........................................................................................ 25

21. INICIAR EL MANAGER EN DESTINO (oraprd01- oraprd02) .................................................................. 26

22. PRUEBAS DE DML PARA VERIFICACION DE REPLICACION DE DATOS .................................................. 26

22.1. PRUEBA DE INSERT ..................................................................................................................... 26

22.2. PRUEBA DE DELETE ..................................................................................................................... 27

22.3. PRUEBA DE UPDATE ................................................................................................................... 28

23. ESTADISTICAS PROCESOS DE GOLDENGATE ........................................................................................ 29

23.1. ESTADISTICAS DEL EXTRACT PROCESS ........................................................................................ 29

23.2. ESTADISTICAS DEL DATAPUMP PROCESS ................................................................................... 30

23.3. ESTADISTICAS DEL REPLICAT PROCESS ....................................................................................... 32

24. MONITOREO DE GOLDENGATE ........................................................................................................... 33

24.1. REVISION DEL LOG DE ERRORES GOLDENGATE .......................................................................... 33

24.2. MONITOREO A TRAVÉS DE COMANDOS EN GGSCI .................................................................... 33

Page 4: Implementación de Replicacion DML Unidireccional …orateam.com/wp-content/uploads/2016/07/...mediante-Oracle-Golden… · Implementación de Replicación DML Unidireccional mediante

Implementación de Replicación DML Unidireccional mediante Oracle GoldenGate

4

1. INTRODUCCION Oracle GoldenGate es un software de alta performance para integración de datos en tiempo real y

replicación en ambientes heterogéneos. GoldenGate nos permite habilitar soluciones de alta

disponibilidad, integración de datos en tiempo real, captura de cambios de data transaccional,

replicación de datos, transformaciones, etc.

2. ALCANCE El presente documento tiene como finalidad indicar el detalle del procedimiento seguido para

realizar la implementación de replicación de DML (No DDL) de manera unidireccional.

Adicionalmente se da una vista rápida a la instalación de OGG, lo importante en este punto es

poder determinar la versión apropiada de OGG a instalar en el origen y destino según los

requerimientos de Sistema y Plataformas soportadas por cada versión de OGG.

Para determinar la versión de OGG a instalar revisar la siguiente documentación de Oracle:

http://www.oracle.com/technetwork/middleware/ias/downloads/fusion-certification-

100350.html. En la cual se indica lo siguiente:

• Para requerimientos de Sistema y Plataformas Soportadas para OGG 12c ir a sección:

� System Requirements and Supported Platforms for Oracle GoldenGate 12c (12.2.0.*) ( xls)

• Para requerimientos de Sistema y Plataformas Soportadas para OGG 11gR2 ir a sección:

� System Requirements and Supported Platforms for Oracle GoldenGate 11gR2 ( xls)

• Para requerimientos de Sistema y Plataformas Soportadas para OGG 11gR1 ir a sección:

� System Requirements and Supported Platforms for Oracle GoldenGate 11gR1 ( xls)

Para el presente laboratorio en el origen tenemos una BD single release 10.2.0.4 sobre HP-UX y en

el destino una BD RAC release 11.2.0.4 sobre Linux. Se replicaron todas las tablas del schema de

ejemplo HR.

La replicación de DDL no ha sido implementada, dado que para ello es necesario aplicar un parche

en el origen y como se ha indicado más arriba la finalidad del presente documento es realizar la

implementación de replicación de DML. Más adelante se publicará un documento en el que se

incluirá también la replicación de DDL.

El parche mencionado es requerido en las versiones previas a Oracle 11.2.0.2 . Al respecto la

documentación de Oracle indica aplicar el parche 10423000 si la versión de BD es inferior a

11.2.0.2 : https://docs.oracle.com/goldengate/1212/gg-

winux/GWURF/ggsci_commands066.htm#GWURF265.

Page 5: Implementación de Replicacion DML Unidireccional …orateam.com/wp-content/uploads/2016/07/...mediante-Oracle-Golden… · Implementación de Replicación DML Unidireccional mediante

Implementación de Replicación DML Unidireccional mediante Oracle GoldenGate

5

3. CARACTERISTICA DE LA PLATAFORMA A continuación se adjunta información básica tanto de la plataforma de Origen como Destino:

3.1. ORIGEN Tipo Base de Datos (Single/RAC) Servidor

Nombre BBDD

Nombre Instancia BBDD

Versión BBDD Sistema Operativo

Versión OGG

Single apps03 STRMDB STRMDB 10.2.0.4.0 HP-UX apps03 B.11.23 U ia64 11.2.1.0.1

3.2. DESTINO Tipo Base de Datos (Single/RAC) Servidores

Nombre BBDD

Nombre Instancia BD

Versión BBDD

Sistema Operativo

Versión OGG

RAC oraprd01 POCTEST POCTEST1 11.2.0.4.0 RHEL 5.11 (Tikanga) 12.2.0.1.1

oraprd02 POCTEST2 11.2.0.4.0 RHEL 5.11 (Tikanga) 12.2.0.1.1

4. OBJETOS DE REPLICACION Inicialmente en el origen tenemos la estructura y datos de los objetos y en el destino solamente la

estructura.

A continuación los objetos a ser replicados:

OWNER TABLE_NAME HR COUNTRIES HR DEPARTMENTS HR EMPLOYEES HR JOB_HISTORY HR JOBS HR LOCATIONS HR REGIONS HR T

Page 6: Implementación de Replicacion DML Unidireccional …orateam.com/wp-content/uploads/2016/07/...mediante-Oracle-Golden… · Implementación de Replicación DML Unidireccional mediante

Implementación de Replicación DML Unidireccional mediante Oracle GoldenGate

6

5. CONFIGURACIONES DE BD STRMDB SQL> ALTER DATABASE ADD SUPPLEMENTAL LOG DATA; Database altered. SQL> ALTER DATABASE FORCE LOGGING; Database altered. SQL> select name, supplemental_log_data_min, force_logging, log_mode from v$database; NAME SUPPLEME FOR LOG_MODE --------- -------- --- ------------ STRMDB YES YES ARCHIVELOG

Se recomienda realizar un “alter system switch logfile” para asegurarse

que el cambio sea aplicado en todos los subsiguientes redos.

SQL> ALTER SYSTEM SWITCH LOGFILE; System altered. SQL> alter system set recyclebin=off scope=spfile; System altered. SQL> show parameter recyclebin NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ recyclebin string OFF

6. CREACION DE USUARIO ADMINISTRADOR DE GOLDENGATE EN LA BD STRMDB

SQL> create tablespace GGTBS datafile '/strm/oracle/STRMDB01/oradata/POCGG/data/STRMDB/ggate01.dbf' size 5g autoextend on maxsize UNLIMITED; Tablespace created. SQL> create user ggadmin identified by ggadmin default tablespace GGTBS; User created. SQL> ALTER USER GGADMIN QUOTA UNLIMITED ON GGTBS; User altered. SQL> grant connect,resource, dba to ggadmin;

Page 7: Implementación de Replicacion DML Unidireccional …orateam.com/wp-content/uploads/2016/07/...mediante-Oracle-Golden… · Implementación de Replicación DML Unidireccional mediante

Implementación de Replicación DML Unidireccional mediante Oracle GoldenGate

7

Grant succeeded. SQL> ALTER USER GGADMIN DEFAULT ROLE ALL; User altered. SQL> GRANT EXECUTE ON utl_file TO GGADMIN; Grant succeeded. SQL> set pages 2000 lines 200 SQL> SELECT USERNAME, ACCOUNT_STATUS, DEFAULT_TABLESPACE,TEMPORARY_TABLESPACE,PROFILE FROM DBA_USERS WHERE USERNAME='GGADMIN'; USERNAME ACCOUNT_STATUS DEFAULT_TABLESPACE TEMPORARY_TABLESPACE PROFILE ------------------------------ -------------------------------- ------------------------------ ------------------------------ ------------------------------ GGADMIN OPEN GGTBS TEMP DEFAULT

Otorgar Privilegios adicionales para Administrador de OGG en Oracle 10g (MOS Doc ID

1577081.1)

SQL> exec dbms_streams_auth.grant_admin_privilege('GGADMIN');

PL/SQL procedure successfully completed.

SQL> grant insert on system.logmnr_restart_ckpt$ to GGADMIN;

Grant succeeded.

SQL> grant update on sys.streams$_capture_process to GGADMIN;

Grant succeeded.

SQL> grant become user to GGADMIN;

Grant succeeded.

Es necesario otorgar estos privilegios para evitar los siguientes errores al momento de registrar el

Proceso de EXTRACT:

2016-05-12 23:39:26 ERROR OGG-01755 Cannot register or unregister EXTRACT EXHR01

because of the following SQL error: OCI Error ORA-06550: line 1, column 3128:

PL/SQL: ORA-00942: table or view does not exist

ORA-06550: line 1, column 3117:

Page 8: Implementación de Replicacion DML Unidireccional …orateam.com/wp-content/uploads/2016/07/...mediante-Oracle-Golden… · Implementación de Replicación DML Unidireccional mediante

Implementación de Replicación DML Unidireccional mediante Oracle GoldenGate

8

PL/SQL: SQL Statement ignored (status = 6550). See Extract user privileges in the Oracle

GoldenGate for Oracle Installation and Setup Guide.

7. CONFIGURACIONES DE BD RAC POCTEST SQL> ALTER DATABASE ADD SUPPLEMENTAL LOG DATA; Database altered. SQL> ALTER DATABASE FORCE LOGGING; Database altered. SQL> select name, instance_name, supplemental_log_data_min, force_logging, log_mode from v$database, gv$instance; NAME INSTANCE_NAME SUPPLEME FOR LOG_MODE --------- ---------------- -------- --- ------------ POCTEST POCTEST1 YES YES ARCHIVELOG POCTEST POCTEST2 YES YES ARCHIVELOG Aplicar nuevamente “alter system switch logfile”. SQL> ALTER SYSTEM SET recyclebin = OFF; ALTER SYSTEM SET recyclebin = OFF * ERROR at line 1: ORA-02096: specified initialization parameter is not modifiable with this option SQL> ALTER SYSTEM SET recyclebin = OFF DEFERRED; System altered. [oracle@oraprd01 dirprm]$ sqlplus " / as sysdba" SQL*Plus: Release 11.2.0.4.0 Production on Tue Jul 5 17:54:09 2016 Copyright (c) 1982, 2013, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production With the Partitioning, Real Application Clusters, OLAP, Data Mining and Real Application Testing options SQL> show parameter RECYCLEBIN NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ recyclebin string OFF

Habilitar GoldenGate Replication a nivel de Base de Datos para todas las

instancias del RAC, esto es aplicable para 11.2.0.4 y versiones

Page 9: Implementación de Replicacion DML Unidireccional …orateam.com/wp-content/uploads/2016/07/...mediante-Oracle-Golden… · Implementación de Replicación DML Unidireccional mediante

Implementación de Replicación DML Unidireccional mediante Oracle GoldenGate

9

superiores. Para mayor información revisar documentación de Oracle sobre

Habilitar GoldenGate en la Base de Datos: https://docs.oracle.com/goldengate/1212/gg-winux/GIORA/setup.htm#GIORA983. SQL> show parameter enable_goldengate_replication NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ enable_goldengate_replication boolean FALSE SQL> alter system set ENABLE_GOLDENGATE_REPLICATION=true scope=both sid='*'; System altered. SQL> show parameter enable_goldengate_replication NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ enable_goldengate_replication boolean TRUE

Si no habilitamos este parámetro al momento de iniciar el Extract o

Replicat vamos a tener errores como:

2016-07-06 15:58:30 ERROR OGG-02091 Oracle GoldenGate Delivery for Oracle, tlhr01.prm: Operation not supported because enable_goldengate_replication is not set to true. 2016-07-06 15:58:30 ERROR OGG-01668 Oracle GoldenGate Delivery for Oracle, tlhr01.prm: PROCESS ABENDING.

8. CREACION DE USUARIO ADMINISTRADOR DE GOLDENGATE EN LA BD RAC POCTEST

SQL> create tablespace GGTBS datafile size 5G autoextend on maxsize UNLIMITED; Tablespace created. SQL> create user ggadmin identified by ggadmin default tablespace GGTBS; User created. SQL> ALTER USER GGADMIN QUOTA UNLIMITED ON GGTBS; User altered. SQL> grant connect,resource, dba to ggadmin; Grant succeeded. SQL> ALTER USER GGADMIN DEFAULT ROLE ALL; User altered. SQL> GRANT EXECUTE ON utl_file TO GGADMIN; Grant succeeded.

Page 10: Implementación de Replicacion DML Unidireccional …orateam.com/wp-content/uploads/2016/07/...mediante-Oracle-Golden… · Implementación de Replicación DML Unidireccional mediante

Implementación de Replicación DML Unidireccional mediante Oracle GoldenGate

10

SQL> set pages 2000 lines 200 SQL> SELECT USERNAME, ACCOUNT_STATUS, DEFAULT_TABLESPACE,TEMPORARY_TABLESPACE,PROFILE FROM DBA_USERS WHERE USERNAME='GGADMIN'; USERNAME ACCOUNT_STATUS DEFAULT_TABLESPACE TEMPORARY_TABLESPACE PROFILE ------------------------------ -------------------------------- ------------------------------ ------------------------------ ------------------------------ GGADMIN OPEN GGTBS TEMP DEFAULT

9. CREACION DE SERVICIO TAF PARA BD RAC POCTEST [oracle@oraprd01 ~]$ srvctl status database -d POCTEST -v Instance POCTEST1 is running on node oraprd01. Instance status: Open. Instance POCTEST2 is running on node oraprd02. Instance status: Open. [oracle@oraprd01 ~]$ srvctl add service -d POCTEST -s POCTEST_SRV -r POCTEST1,POCTEST2 -e SESSION -m BASIC [oracle@oraprd01 ~]$ srvctl status service -d POCTEST Service POCTEST_SRV is not running. [oracle@oraprd01 ~]$ srvctl start service -d POCTEST [oracle@oraprd01 ~]$ srvctl status service -d POCTEST Service POCTEST_SRV is running on instance(s) POCTEST1,POCTEST2 [oracle@oraprd01 ~]$ srvctl config service -d POCTEST Service name: POCTEST_SRV Service is enabled Server pool: POCTEST_POCTEST_SRV Cardinality: 2 Disconnect: false Service role: PRIMARY Management policy: AUTOMATIC DTP transaction: false AQ HA notifications: false Failover type: SESSION Failover method: BASIC TAF failover retries: 0 TAF failover delay: 0 Connection Load Balancing Goal: LONG Runtime Load Balancing Goal: NONE TAF policy specification: NONE Edition: Preferred instances: POCTEST1,POCTEST2 Available instances:

Para mayor información sobre Server Control Utility Reference revisar documentación de Oracle:

https://docs.oracle.com/cd/E11882_01/rac.112/e41960/srvctladmin.htm#i1008562 .

Añadir en $ORACLE_HOME/network/admin/tnsnames.ora de cada uno los nodos el siguiente

string de conexión:

POCTEST_SRV = (DESCRIPTION =

Page 11: Implementación de Replicacion DML Unidireccional …orateam.com/wp-content/uploads/2016/07/...mediante-Oracle-Golden… · Implementación de Replicación DML Unidireccional mediante

Implementación de Replicación DML Unidireccional mediante Oracle GoldenGate

11

(ADDRESS = (PROTOCOL = TCP)(HOST = racprod-scan)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = POCTEST_SRV) ) )

10. CONFIGURACION VARIABLES DE AMBIENTE

10.1. CONFIGURACION VARIABLES DE AMBIENTE STRMDB Configurar las variables de ambiente requeridas:

$ pwd /home/oracle $ cat STRMDB.env export ORACLE_HOME=/oracle/app/oracle/product/database/10.2.0 export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$PATH export ORA_NLS10=/oracle/app/oracle/product/database/10.2.0/nls/data export GGHOME=/oggh/oracle/STRMDB/src/POCOGG/app/GoldenGate export ORACLE_SID=STRMDB export LD_LIBRARY_PATH=$ORACLE_HOME/lib/:$GGHOME alias ggsci=$GGHOME/ggsci

10.2. CONFIGURACION VARIABLES DE AMBIENTE BD RAC POCTEST Para el caso de un RAC el Filesystem en donde se va a instalar GoldenGate debe ser un Filesystem

compartido que se pueda ver en todos los nodos del RAC, en este caso los binarios de GoldenGate

se instalaron en el ACFS (Oracle ASM Cluster File System) /u02/app/oracle/oradata/datastore. Por

lo cual los binarios son vistos en ambos nodos del RAC.

[oracle@oraprd01 ~]$ pwd /home/oracle [oracle@oraprd01 ~]$ cat POCTEST1.env ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE ORACLE_HOME=/u01/app/oracle/product/11.2.0.4/dbhome_1; export ORACLE_HOME ORACLE_SID=POCTEST1; export ORACLE_SID PATH=/usr/sbin:$PATH; export PATH PATH=$ORACLE_HOME/bin:$PATH; export PATH export GGHOME=/u02/app/oracle/oradata/datastore/OGG export LD_LIBRARY_PATH=$ORACLE_HOME/lib export PATH=$PATH:$HOME/bin:$GGHOME alias ggsci=$GGHOME/ggsci NLS_DATE_FORMAT='DD-MM-YYYY HH24:Mi:SS' ; export NLS_DATE_FORMAT

[oracle@oraprd02 ~]$ pwd /home/oracle [oracle@oraprd02 ~]$ cat POCTEST2.env ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE ORACLE_HOME=/u01/app/oracle/product/11.2.0.4/dbhome_1; export ORACLE_HOME

Page 12: Implementación de Replicacion DML Unidireccional …orateam.com/wp-content/uploads/2016/07/...mediante-Oracle-Golden… · Implementación de Replicación DML Unidireccional mediante

Implementación de Replicación DML Unidireccional mediante Oracle GoldenGate

12

ORACLE_SID=POCTEST2; export ORACLE_SID PATH=/usr/sbin:$PATH; export PATH PATH=$ORACLE_HOME/bin:$PATH; export PATH export GGHOME=/u02/app/oracle/oradata/datastore/OGG export LD_LIBRARY_PATH=$ORACLE_HOME/lib export PATH=$PATH:$HOME/bin:$GGHOME alias ggsci=$GGHOME/ggsci NLS_DATE_FORMAT='DD-MM-YYYY HH24:Mi:SS' ; export NLS_DATE_FORMAT

11. INSTALACION ORACLE GOLDENGATE

11.1. INSTALACION ORACLE GOLDENGATE EN ORIGEN (apps03) De acuerdo a Oracle Golden Gate Certification Matrix 11gR2 (11.2.1.x), las versión de OGG para

HP-UX 11i (11.23) que soportan BD Oracle 10.2.0.4+ es OGG 11.2.1.0.1. Por lo tanto procedemos a

descargar de la página de Oracle dicha versión y procedemos a instalarla.

$ unzip V32440-01.zip Archive: V32440-01.zip inflating: ggs_HPUX_ia64_ora10g_64bit.tar inflating: OGG_WinUnix_Rel_Notes_11.2.1.0.1.pdf inflating: Oracle GoldenGate 11.2.1.0.1 README.doc inflating: Oracle GoldenGate 11.2.1.0.1 README.txt $ ls -ltr total 607360 -rw-rw-r-- 1 oracle oinstall 236400640 Apr 24 2012 ggs_HPUX_ia64_ora10g_64bit.tar -rw-r--r-- 1 oracle oinstall 220546 Apr 27 2012 OGG_WinUnix_Rel_Notes_11.2.1.0.1.pdf -rw-r--r-- 1 oracle oinstall 24390 May 1 2012 Oracle GoldenGate 11.2.1.0.1 README.txt -rw-r--r-- 1 oracle oinstall 93696 May 1 2012 Oracle GoldenGate 11.2.1.0.1 README.doc -rw------- 1 oracle oinstall 74212422 Mar 7 17:20 V32440-01.zip $ tar -xvf ggs_HPUX_ia64_ora10g_64bit.tar

Page 13: Implementación de Replicacion DML Unidireccional …orateam.com/wp-content/uploads/2016/07/...mediante-Oracle-Golden… · Implementación de Replicación DML Unidireccional mediante

Implementación de Replicación DML Unidireccional mediante Oracle GoldenGate

13

11.2. INSTALACION ORACLE GOLDENGATE EN DESTINO (oraprd01- oraprd02)

De acuerdo a Oracle Golden Gate Certification Matrix 12c (12.2.0.*), las versión de OGG para RHEL

5 64 Bit que soportan BD Oracle 11.2.0.1+ es OGG 12.2.0.1.1. Por lo tanto procedemos a

descargar de la página de Oracle dicha versión y procedemos a instalarla.

[oracle@oraprd01 GG]$ pwd /u01/app/oracle/software/GG [oracle@oraprd01 GG]$ unzip V100692-01.zip

[oracle@oraprd01 GG]$ ls -ltr total 465216 drwxr-xr-x 3 oracle oinstall 4096 Dec 12 2015 fbo_ggs_Linux_x64_shiphome -rw-r--r-- 1 oracle oinstall 1559 Jan 18 20:12 OGG-12.2.0.1-README.txt -rw-r--r-- 1 oracle oinstall 282294 Jan 18 20:13 OGG-12.2.0.1.1-ReleaseNotes.pdf -rw-r--r-- 1 root root 475611228 May 2 16:23 V100692-01.zip [oracle@cloda11 GG]$ cd fbo_ggs_Linux_x64_shiphome/ [oracle@cloda11 fbo_ggs_Linux_x64_shiphome]$ ls Disk1 [oracle@cloda11 fbo_ggs_Linux_x64_shiphome]$ cd Disk1/ [oracle@cloda11 Disk1]$ pwd /u01/app/oracle/software/GG/fbo_ggs_Linux_x64_shiphome/Disk1 [oracle@cloda11 Disk1]$ ls -ltr total 16 drwxr-xr-x 4 oracle oinstall 4096 Dec 12 2015 install drwxr-xr-x 11 oracle oinstall 4096 Dec 12 2015 stage -rwxr-xr-x 1 oracle oinstall 918 Dec 12 2015 runInstaller drwxrwxr-x 2 oracle oinstall 4096 Dec 12 2015 response [oracle@cloda11 Disk1]$ ./runInstaller Starting Oracle Universal Installer... Checking Temp space: must be greater than 120 MB. Actual 11547 MB Passed Checking swap space: must be greater than 150 MB. Actual 18707 MB Passed Checking monitor: must be configured to display at least 256 colors. Actual 16777216 Passed Preparing to launch Oracle Universal Installer from /tmp/OraInstall2016-07-18_11-33-

49PM. Please wait ...

Page 14: Implementación de Replicacion DML Unidireccional …orateam.com/wp-content/uploads/2016/07/...mediante-Oracle-Golden… · Implementación de Replicación DML Unidireccional mediante

Implementación de Replicación DML Unidireccional mediante Oracle GoldenGate

14

Page 15: Implementación de Replicacion DML Unidireccional …orateam.com/wp-content/uploads/2016/07/...mediante-Oracle-Golden… · Implementación de Replicación DML Unidireccional mediante

Implementación de Replicación DML Unidireccional mediante Oracle GoldenGate

15

STEP 3 SUMMARY

Global Settings - Source Location: /u01/app/oracle/software/GG/fbo_ggs_Linux_x64_shiphome

- Disk Space: required 786 MB available 299,5 GB

- Install Option: Oracle GoldenGate for Oracle Database 11g

Installation Details - Software Location: /u02/app/oracle/oradata/datastore/OGG

- Start Manager:false

Al finalizar la instalación (Finish) aparece The installation of Oracle GoldenGate was successful.

Para mayor información acerca de la instalación de OGG 12c revisar

documentación de Oracle

http://www.oracle.com/webfolder/technetwork/tutorials/obe/fmw/goldengate/12c/OGG12c_Ins

tallation/index.html

12. CONFIGURAR LOS DIRECTORIOS DE GOLDENGATE

12.1. CONFIGURAR LOS DIRECTORIOS DE GOLDENGATE EN ORIGEN (apps03) USANDO GGSCI

GGSCI (apps03) 1> create subdirs Creating subdirectories under current directory /oggh/oracle/STRMDB/src/POCOGG/app/GoldenGate Parameter files /oggh/oracle/STRMDB/src/POCOGG/app/GoldenGate/dirprm: already exists Report files /oggh/oracle/STRMDB/src/POCOGG/app/GoldenGate/dirrpt: created Checkpoint files /oggh/oracle/STRMDB/src/POCOGG/app/GoldenGate/dirchk: created Process status files /oggh/oracle/STRMDB/src/POCOGG/app/GoldenGate/dirpcs: created SQL script files /oggh/oracle/STRMDB/src/POCOGG/app/GoldenGate/dirsql: created Database definitions files /oggh/oracle/STRMDB/src/POCOGG/app/GoldenGate/dirdef: created Extract data files /oggh/oracle/STRMDB/src/POCOGG/app/GoldenGate/dirdat: created Temporary files /oggh/oracle/STRMDB/src/POCOGG/app/GoldenGate/dirtmp: created Stdout files /oggh/oracle/STRMDB/src/POCOGG/app/GoldenGate/dirout: created

Page 16: Implementación de Replicacion DML Unidireccional …orateam.com/wp-content/uploads/2016/07/...mediante-Oracle-Golden… · Implementación de Replicación DML Unidireccional mediante

Implementación de Replicación DML Unidireccional mediante Oracle GoldenGate

16

12.2. CONFIGURAR LOS DIRECTORIOS DE GOLDENGATE EN DESTINO (oraprd01- oraprd02) USANDO GGSCI

GGSCI (oraprd01) 1> create subdirs Creating subdirectories under current directory /u02/app/oracle/oradata/datastore/OGG Parameter files /u02/app/oracle/oradata/datastore/OGG/dirprm: already exists Report files /u02/app/oracle/oradata/datastore/OGG/dirrpt: created Checkpoint files /u02/app/oracle/oradata/datastore/OGG/dirchk: created Process status files /u02/app/oracle/oradata/datastore/OGG/dirpcs: created SQL script files /u02/app/oracle/oradata/datastore/OGG/dirsql: created Database definitions files /u02/app/oracle/oradata/datastore/OGG/dirdef: created Extract data files /u02/app/oracle/oradata/datastore/OGG/dirdat: created Temporary files /u02/app/oracle/oradata/datastore/OGG/dirtmp: created Credential store files /u02/app/oracle/oradata/datastore/OGG/dircrd: created Masterkey wallet files /u02/app/oracle/oradata/datastore/OGG/dirwlt: created Dump files /u02/app/oracle/oradata/datastore/OGG/dirdmp: created

13. CONFIGURACIÓN D EL PARAMETER FILE GLOBALS El parameter file GLOBALS controla varias configuraciones entre la instancia de GoldenGate

entera.

13.1. PARAMETER FILE GLOBALS EN ORIGEN (apps03) $ ggsci Oracle GoldenGate Command Interpreter for Oracle Version 11.2.1.0.1 OGGCORE_11.2.1.0.1_PLATFORMS_120423.0230 HP/UX, IA64, 64bit (optimized), Oracle 10g on Apr 23 2012 22:20:31 Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights reserved. GGSCI (apps03) 1> view params ./GLOBALS GGSCHEMA ggadmin ENABLEMONITORING

13.2. PARAMETER FILE GLOBALS EN DESTINO (oraprd01- oraprd02) [oracle@oraprd01 OGG]$ ggsci Oracle GoldenGate Command Interpreter for Oracle Version 12.2.0.1.1 OGGCORE_12.2.0.1.0_PLATFORMS_151211.1401_FBO Linux, x64, 64bit (optimized), Oracle 11g on Dec 12 2015 00:54:38 Operating system character set identified as US-ASCII. Copyright (C) 1995, 2015, Oracle and/or its affiliates. All rights reserved. GGSCI (oraprd01) 1> view params ./GLOBALS

Page 17: Implementación de Replicacion DML Unidireccional …orateam.com/wp-content/uploads/2016/07/...mediante-Oracle-Golden… · Implementación de Replicación DML Unidireccional mediante

Implementación de Replicación DML Unidireccional mediante Oracle GoldenGate

17

GGSCHEMA ggadmin ENABLEMONITORING CHECKPOINTTABLE GGADMIN.CHK ALLOWOUTPUTDIR /u02/app/oracle/oradata/datastore/OGG/trailfiles/phr01 --xagenbale

14. CONFIGURACIÓN DEL MANAGER PROCESS El Manager Process es el responsable de administrar todos los procesos y operaciones de Oracle

GoldenGate dentro de una instancia GoldenGate. Esto incluye los procesos de Extract, Data Pump

y Replicat.

14.1. MANAGER PROCESS EN ORIGEN (apps03) $ ggsci Oracle GoldenGate Command Interpreter for Oracle Version 11.2.1.0.1 OGGCORE_11.2.1.0.1_PLATFORMS_120423.0230 HP/UX, IA64, 64bit (optimized), Oracle 10g on Apr 23 2012 22:20:31 Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights reserved. GGSCI (apps03) 1> view params MGR -- Manager configuration Port 7809 -- List of Dynamic Ports DynamicPortList 7840-8352 -- Purge old logs OGG PurgeOldExtracts /oggh/oracle/STRMDB/src/POCOGG/app/GoldenGate/trailfiles/*, UseCheckpoints -- Autostart Autostart ER * AutoRestart Extract *, Retries 10, WaitMinutes 2, ResetMinutes 60

14.2. MANAGER PROCESS EN DESTINO (oraprd01- oraprd02) [oracle@oraprd01 OGG]$ ggsci Oracle GoldenGate Command Interpreter for Oracle Version 12.2.0.1.1 OGGCORE_12.2.0.1.0_PLATFORMS_151211.1401_FBO Linux, x64, 64bit (optimized), Oracle 11g on Dec 12 2015 00:54:38 Operating system character set identified as US-ASCII. Copyright (C) 1995, 2015, Oracle and/or its affiliates. All rights reserved.

Page 18: Implementación de Replicacion DML Unidireccional …orateam.com/wp-content/uploads/2016/07/...mediante-Oracle-Golden… · Implementación de Replicación DML Unidireccional mediante

Implementación de Replicación DML Unidireccional mediante Oracle GoldenGate

18

GGSCI (oraprd01) 1> view params MGR -- Manager configuration Port 7809 -- List of Dynamic Ports DynamicPortList 7840-8352 -- Purge old logs OGG PurgeOldExtracts /u02/app/oracle/oradata/datastore/OGG/trailfiles/*, UseCheckpoints -- Autostart Autostart ER * AutoRestart Extract *, Retries 10, WaitMinutes 2, ResetMinutes 60

15. CONFIGURACION DEL EXTRACT PROCESS El Extract Process va a llevar un registro de los cambios que son hechos en la Base de Datos

examinando a través de los redo logs. Como tal, el Extrac Process solamente correrá en el Origen.

15.1. EXTRACT PROCESS EXHR01 $ ggsci Oracle GoldenGate Command Interpreter for Oracle Version 11.2.1.0.1 OGGCORE_11.2.1.0.1_PLATFORMS_120423.0230 HP/UX, IA64, 64bit (optimized), Oracle 10g on Apr 23 2012 22:20:31 Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights reserved. GGSCI (apps03) 1> view params EXHR01 EXTRACT EXHR01 SETENV(NLS_LANG="AMERICAN_AMERICA.AL32UTF8") SETENV(ORACLE_HOME = "/oracle/app/oracle/product/database/10.2.0") USERID ggadmin@STRMDB, password ggadmin EXTTRAIL /oggh/oracle/STRMDB/src/POCOGG/app/GoldenGate/trailfiles/STRMDB/et DISCARDFILE /oggh/oracle/STRMDB/src/POCOGG/app/GoldenGate/trailfiles/ehr_discart.txt, MEGABYTES 50, APPEND DYNAMICRESOLUTION TABLE HR.*;

15.2. AÑADIR EL EXTRACT PROCESS AL GOLDENGATE GGSCI (apps03) 1> dblogin userid ggadmin@STRMDB password ggadmin Successfully logged into database. GGSCI (apps03) 2> add extract EXHR01, tranlog, begin now EXTRACT added.

GGSCI (apps03) 3> info all

Page 19: Implementación de Replicacion DML Unidireccional …orateam.com/wp-content/uploads/2016/07/...mediante-Oracle-Golden… · Implementación de Replicación DML Unidireccional mediante

Implementación de Replicación DML Unidireccional mediante Oracle GoldenGate

19

Program Status Group Lag at Chkpt Time Since Chkpt MANAGER STOPPED JAGENT STOPPED EXTRACT STOPPED EXHR01 00:00:00 00:00:05

15.3. AÑADIR SUPPLEMENTAL LOGIN A TODAS LAS TABLAS QUE SERÁN PARTE DE LA REPLICACION

GGSCI (apps03) 4> add trandata hr.* Logging of supplemental redo data enabled for table HR.COUNTRIES. Logging of supplemental redo data enabled for table HR.DEPARTMENTS. Logging of supplemental redo data enabled for table HR.EMPLOYEES. Logging of supplemental redo data enabled for table HR.JOBS. Logging of supplemental redo data enabled for table HR.JOB_HISTORY. Logging of supplemental redo data enabled for table HR.LOCATIONS. Logging of supplemental redo data enabled for table HR.REGIONS. Logging of supplemental redo log data is already enabled for table HR.T.

Con el siguiente query podemos validar de que Supplemental Login haya quedado habilitado en

las tablas indicadas más arriba:

SELECT LOG_GROUP_NAME, TABLE_NAME, DECODE(ALWAYS, 'ALWAYS', 'Unconditional', 'CONDITIONAL', 'Conditional') ALWAYS, LOG_GROUP_TYPE FROM DBA_LOG_GROUPS order by table_name;

15.4. AÑADIR EL TRAIL FILE LOCAL AL GOLDENGATE Y ASOCIARLO CON EL EXTRACT PROCESS

GGSCI (apps03) 12> ADD EXTTRAIL /oggh/oracle/STRMDB/src/POCOGG/app/GoldenGate/trailfiles/STRMDB/et, extract EXHR01, megabytes 50 EXTTRAIL added.

Page 20: Implementación de Replicacion DML Unidireccional …orateam.com/wp-content/uploads/2016/07/...mediante-Oracle-Golden… · Implementación de Replicación DML Unidireccional mediante

Implementación de Replicación DML Unidireccional mediante Oracle GoldenGate

20

15.5. REGISTRAR EL EXTRACT PROCESS, A FIN DE MANTENER LOS LOGS REQUERIDOS PARA LA RECUPERACION

GGSCI (apps03) 13> register extract EXHR01 logretention 2016-07-06 11:58:35 INFO OGG-01749 Successfully registered EXTRACT EXHR01 to start managing log retention at SCN 11417452149112. current_scn: 11417452149814 (v$database)

16. CONFIGURACION DEL DATAPUMP PROCESS El Data Pump Process es esencialmente un Extract Process secundario. La principal diferencia con

el Extract Process es que este en vez de extraer la información de los online redo logs, el Data

Pump Process la extrae del trail file local y la envía sobre la red a un trail file remoto en el Destino.

16.1. DATA PUMP PROCESS DPHR01 $ ggsci Oracle GoldenGate Command Interpreter for Oracle Version 11.2.1.0.1 OGGCORE_11.2.1.0.1_PLATFORMS_120423.0230 HP/UX, IA64, 64bit (optimized), Oracle 10g on Apr 23 2012 22:20:31 Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights reserved. GGSCI (apps03) 1> view params DPHR01 EXTRACT DPHR01 SETENV(ORACLE_HOME = "/oracle/app/oracle/product/database/10.2.0") PASSTHRU RMTHOST oraprd01, MGRPORT 7809 RMTTRAIL /u02/app/oracle/oradata/datastore/OGG/trailfiles/phr01/rt DISCARDFILE /oggh/oracle/STRMDB/src/POCOGG/app/GoldenGate/trailfiles/phr_discart.txt, MEGABYTES 50, APPEND TABLE HR.*;

16.2. AÑADIR EL DATA PUMP PROCESS AL GOLDENGATE GGSCI (apps03) 2> dblogin userid ggadmin@STRMDB password ggadmin

Successfully logged into database.

GGSCI (apps03) 7> add extract DPHR01, EXTTRAILSOURCE

/oggh/oracle/STRMDB/src/POCOGG/app/GoldenGate/trailfiles/STRMDB/et

EXTRACT added.

Page 21: Implementación de Replicacion DML Unidireccional …orateam.com/wp-content/uploads/2016/07/...mediante-Oracle-Golden… · Implementación de Replicación DML Unidireccional mediante

Implementación de Replicación DML Unidireccional mediante Oracle GoldenGate

21

16.3. AÑADIR EL TRAIL FILE REMOTO AL GOLDENGATE Y ASOCIARLO CON EL DATA PUMP PROCESS

GGSCI (apps03) 10> add rmttrail /u02/app/oracle/oradata/datastore/OGG/trailfiles/phr01/rt, extract DPHR01, megabytes 50 RMTTRAIL added.

GGSCI (apps03) 11> info all Program Status Group Lag at Chkpt Time Since Chkpt MANAGER STOPPED JAGENT STOPPED EXTRACT STOPPED DPHR01 00:00:00 00:07:00 EXTRACT STOPPED EXHR01 00:00:00 01:04:49

El tamaño del trail file remoto debería ser el mismo que el trail file local, en este caso ambos se

definieron de 50 MB.

17. CONFIGURACION DEL REPLICAT PROCESS El Replicat Process corre en el Destino, lee los trail files remotos, y luego reconstruye las

operaciones DML o DDL y las aplica en la BD destino.

17.1. REPLICAT PROCESS TLHR01 [oracle@oraprd01 ~]$ ggsci Oracle GoldenGate Command Interpreter for Oracle Version 12.2.0.1.1 OGGCORE_12.2.0.1.0_PLATFORMS_151211.1401_FBO Linux, x64, 64bit (optimized), Oracle 11g on Dec 12 2015 00:54:38 Operating system character set identified as US-ASCII. Copyright (C) 1995, 2015, Oracle and/or its affiliates. All rights reserved. GGSCI (oraprd01) 1> view params TLHR01 REPLICAT TLHR01 SETENV(ORACLE_HOME = "/u01/app/oracle/product/11.2.0.4/dbhome_1") USERID ggadmin@POCTEST_SRV, password ggadmin ASSUMETARGETDEFS HANDLECOLLISIONS REPERROR (DEFAULT, DISCARD) DISCARDFILE /u02/app/oracle/oradata/datastore/OGG/trailfiles/rhr_discart.txt, MEGABYTES 50, APPEND MAP HR.*, TARGET HR.*;

Page 22: Implementación de Replicacion DML Unidireccional …orateam.com/wp-content/uploads/2016/07/...mediante-Oracle-Golden… · Implementación de Replicación DML Unidireccional mediante

Implementación de Replicación DML Unidireccional mediante Oracle GoldenGate

22

17.2. CREAR UNA TABLA DE CHECKPOINT Usar ADD CHECKPOINTTABLE para crear una tabla de Checkpoint en la Base de Datos destino. El

Replicat Process usa la tabla para mantener un registro de su posición de lectura en el trail file

para propósitos de recovery.

GGSCI (oraprd01) 1> dblogin userid ggadmin@POCTEST_SRV password ggadmin Successfully logged into database. GGSCI (oraprd01 as ggadmin@POCTEST2) 3> ADD CHECKPOINTTABLE GGADMIN.CHK Successfully created checkpoint table GGADMIN.CHK.

17.3. AÑADIR EL REPLICAT PROCESS AL GOLDENGATE GGSCI (oraprd01 as ggadmin@POCTEST2) 4> ADD REPLICAT TLHR01, EXTTRAIL /u02/app/oracle/oradata/datastore/OGG/trailfiles/phr01/rt REPLICAT added.

GGSCI (oraprd01 as ggadmin@POCTEST2) 5> info all Program Status Group Lag at Chkpt Time Since Chkpt MANAGER STOPPED JAGENT STOPPED REPLICAT STOPPED TLHR01 00:00:00 00:00:04

18. CARGA INICIAL La carga inicial fue realizada a través de export e import datapump.

18.1. OBTENER EL SCN ACTUAL DE LA BD STRMDB SQL> show parameter db_name NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ db_name string STRMDB SQL> select CURRENT_SCN from v$database; CURRENT_SCN ----------- 11417452154573

Page 23: Implementación de Replicacion DML Unidireccional …orateam.com/wp-content/uploads/2016/07/...mediante-Oracle-Golden… · Implementación de Replicación DML Unidireccional mediante

Implementación de Replicación DML Unidireccional mediante Oracle GoldenGate

23

18.2. REALIZAR EXPORT DATAPUMP DE TODAS LAS TABLAS DEL SCHEMA HR EN BD STRMDB

Para el export utilizamos el parámetro FLASHBACK_SCN, ya que a través del mismo se especificará

el SCN (System Change Number) que el export usará . Para la carga inicial utilizaremos el SCN

obtenido anteriormente que es 11417452154573.

Adicionalmente se excluirán todos los índices, estadísticas, grants, triggers y constraints, ya que

como se comentó anteriormente en el destino ya tenemos la estructura.

Detalle del par file utilizado:

$ cat expdptbs_hr.par tables='HR.T', 'HR.JOB_HISTORY', 'HR.REGIONS', 'HR.LOCATIONS', 'HR.DEPARTMENTS', 'HR.JOBS', 'HR.EMPLOYEES', 'HR.COUNTRIES' DIRECTORY=TBS_GG DUMPFILE=hr_20160706_1.dmp LOGFILE=hr_20160706_1.log exclude=index,statistics,grant,trigger,constraint flashback_scn=11417452154573

Ejecutamos el export:

$ expdp \'/ as sysdba \' parfile=expdptbs_hr.par Export: Release 10.2.0.4.0 - 64bit Production on Wednesday, 06 July, 2016 15:22:52 Copyright (c) 2003, 2007, Oracle. All rights reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options Starting "SYS"."SYS_EXPORT_TABLE_01": '/******** AS SYSDBA' parfile=expdptbs_hr.par Estimate in progress using BLOCKS method... Processing object type TABLE_EXPORT/TABLE/TABLE_DATA Total estimation using BLOCKS method: 512 KB Processing object type TABLE_EXPORT/TABLE/TABLE Processing object type TABLE_EXPORT/TABLE/COMMENT . . exported "HR"."COUNTRIES" 6.085 KB 25 rows . . exported "HR"."DEPARTMENTS" 6.632 KB 27 rows . . exported "HR"."EMPLOYEES" 15.85 KB 108 rows . . exported "HR"."JOBS" 6.617 KB 19 rows . . exported "HR"."JOB_HISTORY" 6.585 KB 10 rows . . exported "HR"."LOCATIONS" 7.710 KB 23 rows . . exported "HR"."REGIONS" 5.312 KB 5 rows . . exported "HR"."T" 4.921 KB 2 rows Master table "SYS"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded

Page 24: Implementación de Replicacion DML Unidireccional …orateam.com/wp-content/uploads/2016/07/...mediante-Oracle-Golden… · Implementación de Replicación DML Unidireccional mediante

Implementación de Replicación DML Unidireccional mediante Oracle GoldenGate

24

****************************************************************************** Dump file set for SYS.SYS_EXPORT_TABLE_01 is: /bscs/oracle/BSCSDESA/oradata/STRBD/dmps/hr_20160706_1.dmp Job "SYS"."SYS_EXPORT_TABLE_01" successfully completed at 16:23:06

EN BD RAC POCTEST DESHABILITAR TODAS LAS FOREIGN KEY DE LAS TABLAS DE HR ANTES DEL

IMPORT DATAPUMP

alter table HR.JOB_HISTORY disable constraint JHIST_JOB_FK; alter table HR.JOB_HISTORY disable constraint JHIST_EMP_FK; alter table HR.JOB_HISTORY disable constraint JHIST_DEPT_FK; alter table HR.COUNTRIES disable constraint COUNTR_REG_FK; alter table HR.EMPLOYEES disable constraint EMP_MANAGER_FK; alter table HR.DEPARTMENTS disable constraint DEPT_LOC_FK; alter table HR.DEPARTMENTS disable constraint DEPT_MGR_FK; alter table HR.EMPLOYEES disable constraint EMP_DEPT_FK; alter table HR.EMPLOYEES disable constraint EMP_JOB_FK; alter table HR.LOCATIONS disable constraint LOC_C_ID_FK;

18.3. REALIZAR IMPORT DATAPUMP DE TODAS LAS TABLAS DEL SCHEMA HR EN BD RAC POCTEST

[oracle@oraprd01 scripts]$ cat impdptbs_hr.par tables='HR.T', 'HR.JOB_HISTORY', 'HR.REGIONS', 'HR.LOCATIONS', 'HR.DEPARTMENTS', 'HR.JOBS', 'HR.EMPLOYEES', 'HR.COUNTRIES' remap_schema=HR:HR remap_tablespace=USERS:USERS, EXAMPLE:EXAMPLE table_exists_action=truncate DIRECTORY=DATA_PUMP_DIR DUMPFILE=hr_20160706_1.dmp

Ejecutamos el import:

[oracle@oraprd01 scripts]$ impdp \'/ as sysdba \' parfile=impdptbs_hr.par Import: Release 11.2.0.4.0 - Production on Wed Jul 6 15:51:35 2016 Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production With the Partitioning, Real Application Clusters, OLAP, Data Mining and Real Application Testing options Master table "SYS"."SYS_IMPORT_TABLE_01" successfully loaded/unloaded Starting "SYS"."SYS_IMPORT_TABLE_01": "/******** AS SYSDBA" parfile=impdptbs_hr.par Processing object type TABLE_EXPORT/TABLE/TABLE

Page 25: Implementación de Replicacion DML Unidireccional …orateam.com/wp-content/uploads/2016/07/...mediante-Oracle-Golden… · Implementación de Replicación DML Unidireccional mediante

Implementación de Replicación DML Unidireccional mediante Oracle GoldenGate

25

Table "HR"."COUNTRIES" exists and has been truncated. Data will be loaded but all dependent metadata will be skipped due to table_exists_action of truncate Table "HR"."T" exists and has been truncated. Data will be loaded but all dependent metadata will be skipped due to table_exists_action of truncate Table "HR"."JOB_HISTORY" exists and has been truncated. Data will be loaded but all dependent metadata will be skipped due to table_exists_action of truncate Table "HR"."REGIONS" exists and has been truncated. Data will be loaded but all dependent metadata will be skipped due to table_exists_action of truncate Table "HR"."LOCATIONS" exists and has been truncated. Data will be loaded but all dependent metadata will be skipped due to table_exists_action of truncate Table "HR"."DEPARTMENTS" exists and has been truncated. Data will be loaded but all dependent metadata will be skipped due to table_exists_action of truncate Table "HR"."JOBS" exists and has been truncated. Data will be loaded but all dependent metadata will be skipped due to table_exists_action of truncate Table "HR"."EMPLOYEES" exists and has been truncated. Data will be loaded but all dependent metadata will be skipped due to table_exists_action of truncate Processing object type TABLE_EXPORT/TABLE/TABLE_DATA . . imported "HR"."COUNTRIES" 6.085 KB 25 rows . . imported "HR"."DEPARTMENTS" 6.632 KB 27 rows . . imported "HR"."EMPLOYEES" 15.85 KB 108 rows . . imported "HR"."JOBS" 6.617 KB 19 rows . . imported "HR"."JOB_HISTORY" 6.585 KB 10 rows . . imported "HR"."LOCATIONS" 7.710 KB 23 rows . . imported "HR"."REGIONS" 5.312 KB 5 rows . . imported "HR"."T" 4.921 KB 2 rows Processing object type TABLE_EXPORT/TABLE/COMMENT Job "SYS"."SYS_IMPORT_TABLE_01" successfully completed at Wed Jul 6 15:51:48 2016 elapsed 0 00:00:12

19. ALTERAR LOS ATRIBUTOS DEL EXTRACT EXHR01 AL SCN UTILIZADO POR EL EXPORT

GGSCI (apps03) 17> ALTER EXTRACT EXHR01, SCN 11417452154573 EXTRACT altered.

Importante comentar que antes de aplicar este comando se requiere que el Extract se encuentre

detenido.

20. INICIAR EL MANAGER EN ORIGEN (apps03) GGSCI (apps03) 18> start mgr Manager started. GGSCI (apps03) 19> info all Program Status Group Lag at Chkpt Time Since Chkpt MANAGER RUNNING JAGENT STOPPED EXTRACT RUNNING DPHR01 00:00:00 03:15:51

Page 26: Implementación de Replicacion DML Unidireccional …orateam.com/wp-content/uploads/2016/07/...mediante-Oracle-Golden… · Implementación de Replicación DML Unidireccional mediante

Implementación de Replicación DML Unidireccional mediante Oracle GoldenGate

26

EXTRACT RUNNING EXHR01 00:00:00 00:00:00

21. INICIAR EL MANAGER EN DESTINO (oraprd01- oraprd02) GGSCI (oraprd01) 8> start mgr Manager started. GGSCI (oraprd01) 9> info all Program Status Group Lag at Chkpt Time Since Chkpt MANAGER RUNNING JAGENT STOPPED REPLICAT RUNNING TLHR01 00:00:00 00:00:02

22. PRUEBAS DE DML PARA VERIFICACION DE REPLICACION DE DATOS

22.1. PRUEBA DE INSERT En Origen en tabla HR.EMPLOYEES procedemos a añadir 201 registros:

Page 27: Implementación de Replicacion DML Unidireccional …orateam.com/wp-content/uploads/2016/07/...mediante-Oracle-Golden… · Implementación de Replicación DML Unidireccional mediante

Implementación de Replicación DML Unidireccional mediante Oracle GoldenGate

27

En Destino en tabla HR.EMPLOYEES verificamos que se hayan replicado los 201 registros

insertados:

22.2. PRUEBA DE DELETE En Origen en tabla HR.EMPLOYEES procedemos a eliminar 101 registros:

Page 28: Implementación de Replicacion DML Unidireccional …orateam.com/wp-content/uploads/2016/07/...mediante-Oracle-Golden… · Implementación de Replicación DML Unidireccional mediante

Implementación de Replicación DML Unidireccional mediante Oracle GoldenGate

28

En Destino en tabla HR.EMPLOYEES verificamos que se hayan eliminado los 101 registros:

22.3. PRUEBA DE UPDATE En Origen en tabla HR.REGIONS procedemos a actualizar el REGION_ID 4, lo actualizamos de

‘Middle East and Africa’ a ‘Africa’:

Page 29: Implementación de Replicacion DML Unidireccional …orateam.com/wp-content/uploads/2016/07/...mediante-Oracle-Golden… · Implementación de Replicación DML Unidireccional mediante

Implementación de Replicación DML Unidireccional mediante Oracle GoldenGate

29

En Destino en tabla HR.EMPLOYEES verificamos que se haya actualizado el REGION_ID 4:

23. ESTADISTICAS PROCESOS DE GOLDENGATE

23.1. ESTADISTICAS DEL EXTRACT PROCESS El cual nos indican que hay 0 registros descartados en el proceso de Extract.

GGSCI (apps03) 13> stats EXHR01 Sending STATS request to EXTRACT EXHR01 ... Start of Statistics at 2016-07-14 14:34:25. Output to /oggh/oracle/STRMDB/src/POCOGG/app/GoldenGate/trailfiles/STRMDB/et: Extracting from HR.EMPLOYEES to HR.EMPLOYEES: *** Total statistics since 2016-07-14 12:23:45 *** Total inserts 402.00 Total updates 0.00 Total deletes 503.00 Total discards 0.00 Total operations 905.00 *** Daily statistics since 2016-07-14 12:23:45 ***

Page 30: Implementación de Replicacion DML Unidireccional …orateam.com/wp-content/uploads/2016/07/...mediante-Oracle-Golden… · Implementación de Replicación DML Unidireccional mediante

Implementación de Replicación DML Unidireccional mediante Oracle GoldenGate

30

Total inserts 402.00 Total updates 0.00 Total deletes 503.00 Total discards 0.00 Total operations 905.00 *** Hourly statistics since 2016-07-14 14:00:00 *** No database operations have been performed. *** Latest statistics since 2016-07-14 12:23:45 *** Total inserts 402.00 Total updates 0.00 Total deletes 503.00 Total discards 0.00 Total operations 905.00 Extracting from HR.REGIONS to HR.REGIONS: *** Total statistics since 2016-07-14 12:23:45 *** Total inserts 0.00 Total updates 1.00 Total deletes 0.00 Total discards 0.00 Total operations 1.00 *** Daily statistics since 2016-07-14 12:23:45 *** Total inserts 0.00 Total updates 1.00 Total deletes 0.00 Total discards 0.00 Total operations 1.00 *** Hourly statistics since 2016-07-14 14:00:00 *** No database operations have been performed. *** Latest statistics since 2016-07-14 12:23:45 *** Total inserts 0.00 Total updates 1.00 Total deletes 0.00 Total discards 0.00 Total operations 1.00 End of Statistics.

23.2. ESTADISTICAS DEL DATAPUMP PROCESS El cual nos indican que hay 0 registros descartados en el proceso de DataPump:

GGSCI (apps03) 14> stats DPHR01 Sending STATS request to EXTRACT DPHR01 ... Start of Statistics at 2016-07-14 14:35:06.

Page 31: Implementación de Replicacion DML Unidireccional …orateam.com/wp-content/uploads/2016/07/...mediante-Oracle-Golden… · Implementación de Replicación DML Unidireccional mediante

Implementación de Replicación DML Unidireccional mediante Oracle GoldenGate

31

Output to /u02/app/oracle/oradata/datastore/OGG/trailfiles/phr01/rt: Extracting from HR.EMPLOYEES to HR.EMPLOYEES: *** Total statistics since 2016-07-14 12:23:46 *** Total inserts 402.00 Total updates 0.00 Total deletes 503.00 Total discards 0.00 Total operations 905.00 *** Daily statistics since 2016-07-14 12:23:46 *** Total inserts 402.00 Total updates 0.00 Total deletes 503.00 Total discards 0.00 Total operations 905.00 *** Hourly statistics since 2016-07-14 14:00:00 *** No database operations have been performed. *** Latest statistics since 2016-07-14 12:23:46 *** Total inserts 402.00 Total updates 0.00 Total deletes 503.00 Total discards 0.00 Total operations 905.00 Extracting from HR.REGIONS to HR.REGIONS: *** Total statistics since 2016-07-14 12:23:46 *** Total inserts 0.00 Total updates 1.00 Total deletes 0.00 Total discards 0.00 Total operations 1.00 *** Daily statistics since 2016-07-14 12:23:46 *** Total inserts 0.00 Total updates 1.00 Total deletes 0.00 Total discards 0.00 Total operations 1.00 *** Hourly statistics since 2016-07-14 14:00:00 *** No database operations have been performed. *** Latest statistics since 2016-07-14 12:23:46 *** Total inserts 0.00 Total updates 1.00 Total deletes 0.00 Total discards 0.00 Total operations 1.00 End of Statistics.

Page 32: Implementación de Replicacion DML Unidireccional …orateam.com/wp-content/uploads/2016/07/...mediante-Oracle-Golden… · Implementación de Replicación DML Unidireccional mediante

Implementación de Replicación DML Unidireccional mediante Oracle GoldenGate

32

23.3. ESTADISTICAS DEL REPLICAT PROCESS El cual nos indican que hay 0 registros descartados en el proceso de Replicat:

GGSCI (oraprd01) 10> stats TLHR01 Sending STATS request to REPLICAT TLHR01 ... Start of Statistics at 2016-07-14 14:38:28. Replicating from HR.EMPLOYEES to HR.EMPLOYEES: *** Total statistics since 2016-07-14 12:26:47 *** Total inserts 402.00 Total updates 0.00 Total deletes 503.00 Total discards 0.00 Total operations 905.00 *** Daily statistics since 2016-07-14 12:26:47 *** Total inserts 402.00 Total updates 0.00 Total deletes 503.00 Total discards 0.00 Total operations 905.00 *** Hourly statistics since 2016-07-14 14:00:00 *** No database operations have been performed. *** Latest statistics since 2016-07-14 12:26:47 *** Total inserts 402.00 Total updates 0.00 Total deletes 503.00 Total discards 0.00 Total operations 905.00 Replicating from HR.REGIONS to HR.REGIONS: *** Total statistics since 2016-07-14 12:26:47 *** Total inserts 0.00 Total updates 1.00 Total deletes 0.00 Total discards 0.00 Total operations 1.00 *** Daily statistics since 2016-07-14 12:26:47 *** Total inserts 0.00 Total updates 1.00 Total deletes 0.00 Total discards 0.00 Total operations 1.00 *** Hourly statistics since 2016-07-14 14:00:00 *** No database operations have been performed. *** Latest statistics since 2016-07-14 12:26:47 ***

Page 33: Implementación de Replicacion DML Unidireccional …orateam.com/wp-content/uploads/2016/07/...mediante-Oracle-Golden… · Implementación de Replicación DML Unidireccional mediante

Implementación de Replicación DML Unidireccional mediante Oracle GoldenGate

33

Total inserts 0.00 Total updates 1.00 Total deletes 0.00 Total discards 0.00 Total operations 1.00 End of Statistics.

24. MONITOREO DE GOLDENGATE

24.1. REVISION DEL LOG DE ERRORES GOLDENGATE El log de errores de GoldenGate se encuentra en el $GGHOME, y se llama ggserr.log.

REVISION DEL LOG DE GOLDENGATE EN ORIGEN (apps03)

REVISION DEL LOG DE GOLDENGATE EN DESTINO (oraprd01- oraprd02)

24.2. MONITOREO A TRAVÉS DE COMANDOS EN GGSCI Para mayor información acerca de estos comandos revisar documentación de

Oracle sobre Using the Information Commands in GGSCI:

https://docs.oracle.com/goldengate/1212/gg-

winux/GWUAD/wu_monitoring.htm#GWUAD636