52
1 What do I really need to know when upgrading Thomas Kyte http://asktom.oracle.com/

1 What do I really need to know when upgrading Thomas Kyte

Embed Size (px)

Citation preview

1

What do I really need to know when upgrading

Thomas Kytehttp://asktom.oracle.com/

2

So … What Does Oracle Database 11g Mean To Me?

Change

3

Small Change – but think about it…

Let’s Go

Green

4

Small Change – but think about it…

ops$tkyte%ORA11GR2> create table t

2 as

3 select substr(object_name, 1, 1 ) str, all_objects.*

4 from all_objects

5 order by dbms_random.random;

Table created.

ops$tkyte%ORA11GR2> create index t_idx on t(str,object_name);

Index created.

ops$tkyte%ORA11GR2> begin

2 dbms_stats.gather_table_stats

3 ( user, 'T',

4 method_opt => 'for all indexed columns size 254',

5 estimate_percent=>100 );

6 end;

7 /

PL/SQL procedure successfully completed.

5

Small Change – but think about it…

ops$tkyte%ORA11GR2> select count(subobject_name) from t t1 where str = 'T';

--------------------------------------------------------------------------------------

| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |

--------------------------------------------------------------------------------------

| 0 | SELECT STATEMENT | | 1 | 19 | 296 (0)| 00:00:04 |

| 1 | SORT AGGREGATE | | 1 | 19 | | |

| 2 | TABLE ACCESS BY INDEX ROWID| T | 292 | 5548 | 296 (0)| 00:00:04 |

|* 3 | INDEX RANGE SCAN | T_IDX | 292 | | 4 (0)| 00:00:01 |

--------------------------------------------------------------------------------------

6

Small Change – but think about it…

ops$tkyte%ORA11GR2> insert into t

2 select 'T', all_objects.*

3 from all_objects

4 where rownum <= 1;

1 row created.

ops$tkyte%ORA11GR2> begin

2 dbms_stats.gather_table_stats

3 ( user, 'T',

4 method_opt => 'for all indexed columns size 254',

5 estimate_percent=>100 );

6 end;

7 /

PL/SQL procedure successfully completed.

7

Small Change – but think about it…

ops$tkyte%ORA11GR2> select count(subobject_name) from t t2 where str = 'T';

---------------------------------------------------------------------------

| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |

---------------------------------------------------------------------------

| 0 | SELECT STATEMENT | | 1 | 19 | 297 (1)| 00:00:04 |

| 1 | SORT AGGREGATE | | 1 | 19 | | |

|* 2 | TABLE ACCESS FULL| T | 293 | 5567 | 297 (1)| 00:00:04 |

---------------------------------------------------------------------------

9

What do you have from the past…

•Online Parameter Changes•Online Major Memory Changes•Online Schema Evolution•Online Index Creates•Quiesce•Rolling Upgrades•Online Disk reconfiguration (ASM)•Online Cross Platform Tablespace Transport•Full Database Transports•And more….

10

What do you need to know?Test To Scale

SQL Plan Management

The ability to forget and let it go

Never

Stopping

Planning Ahead

11© 2010 Oracle Corporation 11

First – what do we need to do?

12

Database Upgrade Process: Steps

1. Analyze & gather information about environment2. Determine the upgrade path and choose upgrade method3. Prepare backup / recovery strategy and clone database to test 4. Establish performance baseline/metrics before upgrade 5. Develop a test plan for database, applications, and reports 6. Test upgraded database with applications and reports7. Ensure adequate performance by comparing metrics gathered

before and after upgrade8. Remediate regressions, e.g, tune queries, update database

parameters, call Support, etc.9. Go Live!

Planning AheadForget and let it go

ASH and AWR

Test To ScaleSQL Plan Management

Never Stopping

13© 2010 Oracle Corporation 13

ASH/AWR

14

Automatic Workload Repository (AWR)

T1 T2 T3 T4

You can report on:

T2-T1

T3-T2

T3-T1

T4-T3

T4-T2

T4-T1

Shutdown/startup

You can report on:

T3-T2

T4-T3

T4-T2

select * from dba_hist_snapshot;

• Every N-Units of time, data is flushed from memory to disk (a snapshot)

• You can generate reports that cover any range of time (n-units of time at a time)

• We simply “subtract”

15

Active Session History (ASH)

Point in time:

V$SESSION

V$SESSION_WAIT

SGA Circular

Buffer – sized

By CPU_COUNT

Short term memory:

V$ACTIVE_SESSION_HISTORYLong term memory:

DBA_HIST_ACTIVE_SESS_HISTORY

Every hour or

2/3rds full in SGA

•V$ACTIVE_SESSION_HISTORY – about every second of activity•DBA_HIST_ACTIVE_SESS_HISTORY – every 10 seconds of activity•On demand flush•When ever in memory buffer (V$) is 2/3rds full•Retained using AWR retention policies

16© 2010 Oracle Corporation 16

SQL Plan Management

17

SQL Plan ManagementPhase 1 - Capture

• Run applications to create a baseline– OPTIMIZER_CAPTURE_SQL_PLAN_BASELINES=TRUE

Plan History

HJ

HJ

GB

Plan BaselineParse

HJ

HJ

GB

Repeated plans will be added to the SQL Plan Baseline during this phase

SQL MANAGEMENT BASEResiding in SYSAUX TS.

Will occupy max. 10% of SYSAUX.Weekly job will delete plans

not used in 53 weeks [default].

18

SQL Plan ManagementPhase 2 - Selection

• New Plans are generated (because something changed)• But are not trusted

– OPTIMIZER_CAPTURE_SQL_PLAN_BASELINES=FALSE

New plan will be added to the Plan History but it won't be used unless and until it has been verified

Hard Parse

NL

NL

GB

Plan History

Plan Baseline

HJ

HJ

GB

GB

NL

NL

GB

NL

NL

GB

NL

NL

HJ

HJ

GB

HJ

HJ

GB

19

SQL Plan ManagementPhase 3 – Evolution

• Plans are verified – by testing the performance of the new plan in the background– Automagically or Manually

Plan History

Plan Baseline

GB

NL

NL

DBA

GB

HJ

HJ

Equal or better plans can be added to the SQL Plan Baseline GB

NL

NL

Inefficient plan willbe kept in the

Plan History

GB

NL

NL

Automatic Job

20

Upgrade Scenario

• Your 9i application is already in 11g for whatever reason• You’d like to have ‘query plan stability’

– Coupled with the opportunity to use better plans – do not want to be frozen

• The steps would be….

21

SQL Plan Management – Parameterize

Plan History

Plan Baseline

GB

NL

NL

GB

HJ

HJ

GB

NL

NL

Repeatable plans will be addedto the Plan Baseline upon 2ndexecution

OPTIMIZER_FEATURES_ENABLE=9.2.0OPTIMIZER_CAPTURE_SQL_PLAN_BASELINES=TRUE

STS

GB

NL

NL

Now: Differentplans createdwith OFE=11will be added tothe Plan Historyfor later verification

OPTIMIZER_FEATURES_ENABLE=11.2.0OPTIMIZER_CAPTURE_SQL_PLAN_BASELINES=FALSE

22

Upgrade Scenario

• Your application is in 9i• You’d like to have ‘query plan stability’

– Coupled with the opportunity to use better plans – do not want to be frozen

• You will be changing platforms during the upgrade (not doing a direct upgrade of the database)

• The steps would be….

23

SQL Plan Management – Outlines

STS SS

Capture query outlines on the production system

Exp/imp outlines toNew system

exp impexpdp impdp

DB-Link ...

Plan History

Plan Baseline

GB

NL

NL

GB

HJ

HJ

GB

NL

NL

DBMS_SPM.MIGRATE_STORED_OUTLINE3

24

Upgrade Scenario

• Same Scenario but your application is in 10g• You’d like to have ‘query plan stability’

– Coupled with the opportunity to use better plans – do not want to be frozen

• You will be changing platforms during the upgrade (not doing a direct upgrade of the database)

• The steps would be….

25

SQL Plan Management – Tuning Pack

STS

Staging

Table

exp impexpdp impdp

DB-Link ...

STS

Plan History

Plan Baseline

GB

NL

NL

GB

HJ

HJ

GB

NL

NL

10.2 plans will becomethe SQL Plan Baseline

GB

NL

NL

3

26

Upgrade Scenario

• You would like to deploy from development to production..

• You would like to deploy at a customer site…• And you want to start with a stable set of plans

– Using better plans only after they have been verified

• The steps would be….

27

SQL Plan Management - New Application

DBMS_SPM.UNPACK_STGTAB_BASELINE

Plan Baseline

GB

NL

NL

GB

HJ

HJ

GB

NL

NL

3

@Vendor

Plan Baseline

GB

NL

NL

GB

HJ

HJ

GB

NL

NL

DBMS_SPM.CREATE_STGTAB_BASELINE

DBMS_SPM.PACK_STGTAB_BASELINE

Staging

Table

exp impexpdp impdp

@Customer

Staging

Table

28© 2010 Oracle Corporation 28

Test to Scale

29

Database Replay Overview

• Replay actual production database workload in test environment• Identify, analyze and fix potential instabilities before making

changes to production

• Capture Workload in Production–Capture full production workload with real load, timing & concurrency

characteristics (9i, 10g, 11g)–Move the captured workload to test system (11g)

• Replay Workload in Test–Make the desired changes in test system–Replay workload with full production characteristics–Honor commit ordering

• Analyze & Report–Errors–Data divergence –Performance divergence

Analysis & Reporting

30

Supported Changes

Changes Supported•Database Upgrades, Patches

•Schema, Parameters

•RAC nodes, Interconnect

•OS Platforms, OS Upgrades

•CPU, Memory

•Storage

•Etc.

ClientClient

…Client

Middle Tier

Storage

Recording of External Client

Requests

Changes Unsupported

(there are other tools

for that)

31

Step 1: Workload Capture

File 1

File 2

File n

Production System

File System

ClientClient

…Client

Middle Tier

Storage

•All external client requests captured in binary files

•System background and internal activity excluded

•Minimal overhead–Avoids function call when possible–Buffered I/O

• Independent of client protocol

•Can capture on 9i, 10g, and 11g and replay on 11g

•Capture load for interesting time period, e.g., peak workload, month-end processing, etc.

32

Step 2: Process Workload Files

File 1

File 2

File n

MetadataReplay Files

Test System

File 1

File 2

File n

Capture Files

•Setup test system –Application data should be same as production system as of capture start time

–Use RMAN, Snapshot Standby, imp/exp, Data Pump, etc. to create test system

–Make change: upgrade db and/or OS, change storage, migrate platforms, etc.

•Processing transforms captured data into replayable format

•Once processed, workload can be replayed many times

•For RAC copy all capture files to single location for processing or use shared file system

33

Step 3: Replay Workload

• Replays workload preserving timing, concurrency and dependencies of the capture system

• Replay Client is a special program that consumes processed workload and sends requests to the replay system

• Clients interpret captured calls into sequence of OCI calls and submit to database

• For high concurrency workloads, it may be necessary to start multiple clients

Test System

Replay Clients

File 1

File 2

File n

Replay FilesMetadata

34

Analysis & Reporting

• Error Divergence: For each call error divergence is reported–New: Error encountered during replay not seen during capture–Not Found: Error encountered during capture not seen during replay–Mutated: Different error produced in replay than during capture

• Data Divergence–Replay: Number of rows returned by each call are compared and

divergences reported–User: Application level validation scripts

• Performance Reporting–Capture and Replay Report: Provides high-level performance

information–ADDM Report: Provides in-depth performance analysis–AWR, ASH Report: Facilitates comparative or skew analysis

35

Transport SQL

SQL Performance Analyzer: Overview

……

…Client

Capture SQL

Middle Tier

Storage

Oracle DB

Re-execute SQL

Production Test

* No middle & application tier setup required

Make Changes / Tuning Regressions

• If adequate spare cycles available, optionally execute SQL here

36

SQL Performance Analyzer: WorkflowProduction Test

Capture SQL (STS)

Transport STS

Execute SQL Pre-change

Execute SQL Post-change

Compare Perf.

Steps (1) (2) (3) (4) (5)

(6) Reiterate

(7)

No

Yes

(7)

Done?

Make Change

Production Change / Tuning Deployment

Tuned System

37© 2010 Oracle Corporation 37

The Ability to forget And let it go

38

Flashback for Rapid Recovery from Human Error

FlashbackDatabase

FlashbackData Archive

and Transaction

FlashbackTables

FlashbackQuery

39

Restore Points•Restore point – specifies a jump label–Named Restore Point

•Similar to a bookmark•"Can be" - but no guarantee•Will be recorded to the control file

–Guaranteed Restore Point•Similar to storage snapshots•Overrides the FLASHBACK_RETENTION_TARGET•Attention: A guarantee restore point can stop the whole database

SQL> CREATE RESTORE POINT rpt;SQL> FLASHBACK DATABASE TO RESTORE POINT rpt;SQL> CREATE RESTORE POINT rpt;SQL> FLASHBACK DATABASE TO RESTORE POINT rpt;

SQL> CREATE RESTORE POINT grpt GUARANTEE FLASHBACK DATABASE;SQL> FLASHBACK DATABASE TO RESTORE POINT grpt;SQL> CREATE RESTORE POINT grpt GUARANTEE FLASHBACK DATABASE;SQL> FLASHBACK DATABASE TO RESTORE POINT grpt;

40© 2010 Oracle Corporation 40

Never Stopping

41

Rolling Database Upgrades

Major ReleaseUpgrades

Patch SetUpgrades

Cluster Software & Hardware Upgrades

Initial SQL Apply Config

ClientsRedo

Version X Version X1

BA

Switchover to B, upgrade A

Redo

4

Upgrade

X+1X+1

BA

Run in mixed mode to test

Redo

3X+1X

A B

Upgrade node B to X+1

Upgrade

LogsQueue

X2

X+1

A B

42

Online Application UpgradeEdition-based redefinition

•Code changes are installed in the privacy of a new edition•Data changes are made safely by writing only to new columns or new tables not seen by the old edition•An editioning view exposes a different projection of a table into each edition to allow each to see just its own columns•A crossedition trigger propagates data changes made by the old edition into the new edition’s columns, or (in hot-rollover) vice-versa

43

Editions & object visibility

Object_4

Object_3

Object_2

Object_1

Pre-upgrade edition

44

Editions & object visibility

Object_4

Object_3

Object_2

Object_1

Object_2

Object_1

Pre-upgrade edition

Post-upgrade edition

is child of

(inherited)

(inherited)

(inherited)

(inherited)

Object_4

Object_3

45

Editions & object visibility

Object_4

Object_3

Object_2

Object_1

Object_4*

Object_3*

Object_2

Object_1

Pre-upgrade edition

Post-upgrade edition

is child of

(actual)

(actual)

(inherited)

(inherited)

46© 2010 Oracle Corporation 46

Planning AheadUpgrade Planner

47© 2010 Oracle Corporation 47

My Oracle Support

PerformanceManagement

Enterprise Manager

Provisioning& Patching

ProblemDiagnosis

MOS-EM: Unified View, Integrated InformationBetween My Oracle Support and Enterprise Manager

Oracle

Customer

DatabasesOperating Systems Middleware Applications

Problem/SRManagement

ConfigurationManagement

KnowledgeManagement

Problem/SRManagement

ConfigurationManagement

KnowledgeManagement

4848

‘End-to-End’ Upgrade Lifecycle

My Oracle Support ó EM Grid Control Integrated solution can be leveraged throughout full lifecycle

Preparation

My Oracle Support

Upgrade Plan*

Sub-Phase

*Will be integrated in upcoming release

UpgradeUpgrade Post-UpgradePost-Upgrade

Upgrade Plan

Upgrade Testing Rehearsal Production

Upgrade Monitor & Maintain

Enterprise Manager – Grid Control

Real Application Testing Provisioning Monitoring

Phase

49

<Insert Picture Here>

How to get there

50© 2010 Oracle Corporation 50

Upgrade is easier!

•The upgrade to Oracle Database 11g is much easier than any upgrades to earlier Oracle releases

•Size of Upgrade guides:–8.1.7 - 512 pages–9.0.1 - 484 pages – 111 steps for an RDBMS with 9 components

–9.2.0 - 344 pages–10.1.0 - 170 pages –10.2.0 - 140 pages –11.1.0 - 186 pages–11.2.0 -178 pages

51

Documentation

–Note:785351.1  Upgrade Companion 11g Release 2

52

What are my upgrade paths?Predictable performance post-upgrade

10.2.0.2 10.2.0.2

11.1.0.6 11.1.0.6

10.1.0.510.1.0.5

9.2.0.89.2.0.8

11.211.2

SQL Plan ManagementAutomated SQL tuningReal Application Testing

53