32

Oracle OpenWorld 2010 - Consolidating Microsoft SQL Server Databases into an Oracle 11g Cluster

Embed Size (px)

Citation preview

Page 1: Oracle OpenWorld 2010 - Consolidating Microsoft SQL Server Databases into an Oracle 11g Cluster
Page 2: Oracle OpenWorld 2010 - Consolidating Microsoft SQL Server Databases into an Oracle 11g Cluster

Consolidating Microsoft SQL Server Databases into an Oracle 11g ClusterDylan KuceraDirector – Data ArchitectureOntario Teachers’ Pension Plan

Oracle OpenWorld 2010– S313546Sunday September 19, 20103:00pm-4:00pm

Page 3: Oracle OpenWorld 2010 - Consolidating Microsoft SQL Server Databases into an Oracle 11g Cluster

Agenda

• Gaining buy-in for a DW migration• Adoption of a new DW• Oracle Migration Workbench• Views over Transparent Gateway• Stored Procedure stubs over TG• Oracle Streams

Page 4: Oracle OpenWorld 2010 - Consolidating Microsoft SQL Server Databases into an Oracle 11g Cluster

Gaining buy-in for a DW migration

• Patience isn’t just a virtue, it is a

requirement

• Start thinking about metrics before

anything else

• Tie every message about the DW to

business requirements

Page 5: Oracle OpenWorld 2010 - Consolidating Microsoft SQL Server Databases into an Oracle 11g Cluster

Gaining buy-in for a DW migration

• Scalability• Don’t just focus on RAC• Locking Model

• Writers do not block Readers• No Lock Escalation

• Workload Balancing

• Availability• RAC• Extprocs and links to foreign DB’s run out of

process• Flashback

Page 6: Oracle OpenWorld 2010 - Consolidating Microsoft SQL Server Databases into an Oracle 11g Cluster

Gaining buy-in for a DW migration

• Environment Capability• PL/SQL capabilities may simplify your

deployments (Language constructs,

packages)• Advanced DW features eg. Materialized Views

• Maintainability• Oracle Enterprise Manager• Less replication = lower support costs

• Fit with strategic deployment• Best, if you are lucky enough!

Page 7: Oracle OpenWorld 2010 - Consolidating Microsoft SQL Server Databases into an Oracle 11g Cluster

A new Data Warehouse – If we build it, will they come?

• Promotion• Skills Development• Mentoring• Standards• Architectural Reviews• Controls

Page 8: Oracle OpenWorld 2010 - Consolidating Microsoft SQL Server Databases into an Oracle 11g Cluster

Oracle Migration (Workbench)

• OMW can help fast-track code

migration• Result may not conform to your standards

• Can be used for tables as well, but• Do you want to adjust model?• What about the legacy DW?

Page 9: Oracle OpenWorld 2010 - Consolidating Microsoft SQL Server Databases into an Oracle 11g Cluster

OMW – Capturing a SQL Server model

Page 10: Oracle OpenWorld 2010 - Consolidating Microsoft SQL Server Databases into an Oracle 11g Cluster

OMW – Captured T-SQL Procedure

Page 11: Oracle OpenWorld 2010 - Consolidating Microsoft SQL Server Databases into an Oracle 11g Cluster

OMW – Converted PL/SQL Procedure

Page 12: Oracle OpenWorld 2010 - Consolidating Microsoft SQL Server Databases into an Oracle 11g Cluster

OMW – But what about the legacy?

• Big bang – not possible or risky• Migrating consumers will take time

• Take a staged approach• Transparent Gateway• Oracle Streams

Page 13: Oracle OpenWorld 2010 - Consolidating Microsoft SQL Server Databases into an Oracle 11g Cluster

Views employing Transparent Gateway

CREATE OR REPLACE VIEW PLAY.VALUE_TABLE_SAMPLE ASSELECT "IDENTIFIER" AS ID_, "VALUE" AS VALUE_, FILE_DATE AS FILE_DATEFROM SampleLegacyTable@MSSQL

Page 14: Oracle OpenWorld 2010 - Consolidating Microsoft SQL Server Databases into an Oracle 11g Cluster

Pitfalls of Transparent Gateway - Views

DECLARE tDate DATE := '2008-12-31';BEGIN INSERT INTO PLAY.TEMP_SAMPLE_7445 (ID_, NAME_, PREV_VALUE, CURR_VALUE, VALUE_SUPPLIER, DATE_VALUE_CHANGED) SELECT ID_, '', '', '', 'SAMPLE', MAX(FILE_DATE) FROM PLAY.VALUE_TABLE_SAMPLE WHERE FILE_DATE <= tDate GROUP BY ID_;END;

Results in ORA-03113: end-of-file on communication channel

Alert log says ORA-07445: exception encountered: core dump [intel_fast_memcpy.A()+18] [ACCESS_VIOLATION] [ADDR:0x115354414B] [PC:0x52A9DFE] [UNABLE_TO_READ] []

Fixed in 11.1.0.6 Patch 10 and 11.1.0.7 Patch 7

Page 15: Oracle OpenWorld 2010 - Consolidating Microsoft SQL Server Databases into an Oracle 11g Cluster

CREATE PROCEDURE dbo.GetNHLTeamStats

@inDate DATETIME, @inTeam VARCHAR(8)

AS

SELECT SWEATER_NO, NAME, POINTS, FACE_OFF_PCTFROM NorthWind..NHL_PLAYER_STATSWHERE DATE = @inDate AND TEAM = @inTeam

Procs employing Transparent Gateway

Page 16: Oracle OpenWorld 2010 - Consolidating Microsoft SQL Server Databases into an Oracle 11g Cluster

CREATE OR REPLACE PROCEDURE PLAY.RPT_NHL_TEAM_STAT ( inDate DATE, inTeam VARCHAR2, RC1 IN OUT SYS_REFCURSOR) IS

tRC1_MS SYS_REFCURSOR;tSweater_No NUMBER;tName VARCHAR2(8);tPoints NUMBER;tFace_Off_Pct NUMBER;

BEGIN DELETE FROM PLAY.TEMP_NHL_TEAM_STAT; dbo.GetNHLTeamStats@MSSQL(inDate, inTeam, tRC1_MS);

LOOP FETCH tRC1_MS INTO tSweater_No, tName, tPoints, tFace_Off_Pct;

EXIT WHEN tRC1_MS%NOTFOUND; BEGIN INSERT INTO PLAY.TEMP_NHL_TEAM_STAT (SWEATER_NO, NAME_, POINTS, FACE_OFF_PCT) VALUES(tSweater_No, tName, tPoints, tFace_Off_Pct); END; END LOOP; CLOSE tRC1_MS; OPEN RC1 FOR SELECT SWEATER_NO, NAME_, POINTS, FACE_OFF_PCT FROM PLAY.TEMP_NHL_TEAM_STAT ORDER BY SWEATER_NO;

END RPT_NHL_TEAM_STAT ;

Procs employing Transparent Gateway

RECIPE:

1) Declare Variables for all MSSQL Result set columns

2) Call MSSQL Procedure

3) Fetch Result one row at a time

4) Insert row to Oracle Temporary Table

5) Open Ref Cursor result set

Page 17: Oracle OpenWorld 2010 - Consolidating Microsoft SQL Server Databases into an Oracle 11g Cluster

{CALL PLAY.RPT_NHL_TEAM_STATS ('2010-08-31', 'SJS')}

Results in ORA-06504: PL/SQL: Return types of Result Set variables or query do not match

Fixed in 11.1.0.7 Patch 7

Pitfalls of Transparent Gateway – Procs and Result Sets

Page 18: Oracle OpenWorld 2010 - Consolidating Microsoft SQL Server Databases into an Oracle 11g Cluster

Oracle Streams as an enabler of migration

Oracle Streams

ETL

Page 19: Oracle OpenWorld 2010 - Consolidating Microsoft SQL Server Databases into an Oracle 11g Cluster

Heterogeneous Streams – General Architecture

Diagram Adapted from “Oracle Database 11g: Oracle Streams Replication, An Oracle White Paper, July 2007”

Page 20: Oracle OpenWorld 2010 - Consolidating Microsoft SQL Server Databases into an Oracle 11g Cluster

Heterogeneous Streams – Example

Legacy Microsoft SQL Server Data Warehouse:

TABLE NorthWind.dbo.NHL_PLAYER_STATS ( DATE DATETIME, TEAM VARCHAR(8), SWEATER_NO INT, NAME VARCHAR(128), BIRTH_DATE DATETIME, POINTS INT, FACE_OFF_PCT FLOAT )

New Oracle Data Warehouse:TABLE PLAY. NHL_PLAYER_STAT ( DATE_ DATE, TEAM VARCHAR2(8), SWEATER_NO NUMBER, NAME_ VARCHAR2(128), BIRTH_DATE DATE, POINTS NUMBER, FACE_OFF_PCT NUMBER );

Page 21: Oracle OpenWorld 2010 - Consolidating Microsoft SQL Server Databases into an Oracle 11g Cluster

BEGIN DBMS_APPLY_ADM.CREATE_APPLY( queue_name => 'SAMPLE_STREAM_Q', apply_name => 'SAMPLE_APPLY_NORTHWIND', apply_captured => TRUE, apply_database_link => 'MSSQL_STREAMS_NORTHWIND'); END; /BEGINDBMS_STREAMS_ADM.ADD_TABLE_RULES( table_name => 'PLAY.NHL_PLAYER_STAT', streams_type => 'APPLY', streams_name => 'SAMPLE_APPLY_NORTHWIND', queue_name => 'SAMPLE_STREAM_Q', include_dml => true, include_ddl => false);END;/

Heterogeneous Streams – Heterogeneous Apply

Page 22: Oracle OpenWorld 2010 - Consolidating Microsoft SQL Server Databases into an Oracle 11g Cluster

Heterogeneous Streams – Heterogeneous Apply Transforms

BEGINDBMS_STREAMS_ADM.RENAME_TABLE( rule_name => 'NHL_PLAYER_STAT2283', from_table_name => 'PLAY.NHL_PLAYER_STAT', to_table_name => '"dbo".NHL_PLAYER_STATS', step_number => 0, operation =>'ADD');END;/BEGIN DBMS_STREAMS_ADM.RENAME_COLUMN( rule_name => 'NHL_PLAYER_STAT2283', table_name => 'PLAY.NHL_PLAYER_STAT', from_column_name => '"DATE_"', to_column_name => '"DATE"', value_type => '*', step_number => 0, operation => 'ADD');END;/

Page 23: Oracle OpenWorld 2010 - Consolidating Microsoft SQL Server Databases into an Oracle 11g Cluster

Heterogeneous Streams – Before inserts to Captured Oracle table

Page 24: Oracle OpenWorld 2010 - Consolidating Microsoft SQL Server Databases into an Oracle 11g Cluster

Heterogeneous Streams – Insert some rows into Captured Oracle table

SQL> INSERT INTO PLAY.NHL_PLAYER_STAT (DATE_, TEAM, SWEATER_NO, NAME_, BIRTH_DATE, POINTS, FACE_OFF_PCT) 2 VALUES ('2010-08-31', 'VAN', 33, 'Henrik Sedin', '1980-09-26', 112, 49.5); 1 row insertedSQL> INSERT INTO PLAY.NHL_PLAYER_STAT (DATE_, TEAM, SWEATER_NO, NAME_, BIRTH_DATE, POINTS, FACE_OFF_PCT) 2 VALUES ('2010-08-31', 'PIT', 87, 'Sidney Crosby', '1987-08-07', 109, 55.9); 1 row insertedSQL> INSERT INTO PLAY.NHL_PLAYER_STAT (DATE_, TEAM, SWEATER_NO, NAME_, BIRTH_DATE, POINTS, FACE_OFF_PCT) 2 VALUES ('2010-08-31', 'WSH', 8, 'Alex Ovechkin', '1985-09-17', 109, 45.4); 1 row insertedSQL> INSERT INTO PLAY.NHL_PLAYER_STAT (DATE_, TEAM, SWEATER_NO, NAME_, BIRTH_DATE, POINTS, FACE_OFF_PCT) 2 VALUES ('2010-08-31', 'SJS', 19, 'Joe Thornton', '1979-07-02', 89, 53.9); 1 row insertedSQL> INSERT INTO PLAY.NHL_PLAYER_STAT (DATE_, TEAM, SWEATER_NO, NAME_, BIRTH_DATE, POINTS, FACE_OFF_PCT) 2 VALUES ('2010-08-31', 'OTT', 11, 'Daniel Alfredsson', '1972-12-11', 71, 35.0); 1 row insertedSQL> INSERT INTO PLAY.NHL_PLAYER_STAT (DATE_, TEAM, SWEATER_NO, NAME_, BIRTH_DATE, POINTS, FACE_OFF_PCT) 2 VALUES ('2010-08-31', 'CGY', 12, 'Jarome Iginla', '1977-07-01', 69, 47.0 ); 1 row insertedSQL> INSERT INTO PLAY.NHL_PLAYER_STAT (DATE_, TEAM, SWEATER_NO, NAME_, BIRTH_DATE, POINTS, FACE_OFF_PCT) 2 VALUES ('2010-08-31', 'TOR', 15, 'Tomas Kaberle', '1978-03-02', 49, NULL); 1 row inserted SQL> COMMIT; Commit complete

Page 25: Oracle OpenWorld 2010 - Consolidating Microsoft SQL Server Databases into an Oracle 11g Cluster

Heterogeneous Streams – After inserts to Captured Oracle table

Page 26: Oracle OpenWorld 2010 - Consolidating Microsoft SQL Server Databases into an Oracle 11g Cluster

Streams – NULL vs. Empty String

• Oracle treats empty string = NULL• Convert empty strings on SQL Server

target to NULL before streaming

• Could require business analysis and

application change

Page 27: Oracle OpenWorld 2010 - Consolidating Microsoft SQL Server Databases into an Oracle 11g Cluster

Heterogeneous Streams – Syncing tables containing Floats

Page 28: Oracle OpenWorld 2010 - Consolidating Microsoft SQL Server Databases into an Oracle 11g Cluster

Heterogeneous Streams – Syncing tables containing Floats

Page 29: Oracle OpenWorld 2010 - Consolidating Microsoft SQL Server Databases into an Oracle 11g Cluster

Heterogeneous Streams – Syncing tables containing Floats

Page 30: Oracle OpenWorld 2010 - Consolidating Microsoft SQL Server Databases into an Oracle 11g Cluster

Wrap-up

• Gaining buy-in for a DW migration• Oracle Migration Workbench• Views over Transparent Gateway• Stored Procedure stubs over TG• Oracle Streams

• Standards, metadata, education,

mentoring

Page 31: Oracle OpenWorld 2010 - Consolidating Microsoft SQL Server Databases into an Oracle 11g Cluster

Questions?

Dylan KuceraDirector – Data ArchitectureOntario Teachers’ Pension Plan

Oracle OpenWorld 2010– S313546Sunday September 19, 20103:00pm-4:00pm

Thank You! - I value your feedback!

Page 32: Oracle OpenWorld 2010 - Consolidating Microsoft SQL Server Databases into an Oracle 11g Cluster