Sie sind auf Seite 1von 41

<Insert Picture Here>

Minimal Downtime Upgrade with Transportable Tablespaces


Igor Melnikov Oracle Corporation

Agenda

Basics

Transport

Demo

Info

Agenda

Basics

Transport

Demo

Info

Challenges
During an upgrade or a patchset apply catupgrd.sql or catpatch.sql have to be run
Depending on installed options this can take some time Database is not available during upgrade or patching

Idea:
Prepare an empty database in a new already upgraded - $OH Transport all data into the new database Catpatch/catupgrd.sql are already executed there Have minimal downtime

Basics
Transportable Tablespaces is available sind Oracle 8i New in Oracle 9i:
Different block sizes

New in Oracle 10g:


Cross platform

New in Oracle 10gR2:


More platforms supported Transportable Database possible with RMAN

Basics
TTS procedure: Database 1
Read Only

Database 2

Copy files exp metadata

imp metadata

Read Write

Basics
Cross platform: v$transportable_platform

Little Endian
HP Open VMS HP Tru64 UNIX
Linux IA (32-bit) Linux IA (64-bit) Linux 64-bit for AMD FILE

COPY

Microsoft Windows IA (64-bit) Microsoft Windows 64-bit for AMD Microsoft Windows IA (32-bit) Solaris Operating System (x86)

RMAN c o n v e r t

Big Endian
FILE COPY Apple Mac OS HP-UX (64-bit) HP-UX IA (64-bit)

AIX-Based Systems (64-bit) IBM zSeries Based Linux IBM Power Based Linux Solaris[tm] OE (32-bit) Solaris[tm] OE (64-bit)

Basics
TTS cross platform
RMAN creates a file copy Can be done on source or target system Takes ca. the same amount of time as a backup Example:

RMAN> CONVERT TABLESPACE users,example TO PLATFORM 'Linux IA (32-bit)' FORMAT='/tmp/transport_linux/%U';

Agenda

Basics

Transport

Demo

Info

Concept
10.2.0.1
Identical mountpoint

10.2.0.2

Database 1
Create

Database 2

Import of nonsegment user data


(views, synonyms etc.)

Transport

Workflow
SOURCE database env. TARGET database env.

Prepare SOURCE system Create TS scripts Create USER scripts Create EXP/IMP scripts Set tablespace READ ONLY

Installe software and patchset Create `empty database Create USER

Import tablespace metadata


Import non-segment user objects

Export TS metadata
Export non-segment obj. Shutdown Immediate Copy datafiles

Set tablespaces READ WRITE


Run ALTER USER script Recompile INVALID OBJECTS

Transport within a few minutes ...

Lets go ...

Workflow
SOURCE database env. TARGET database env.

Prepare SOURCE system Create TS scripts Create USER scripts Create EXP/IMP scripts Set tablespace READ ONLY

Installe software and patchset Create `empty database Create USER

Import tablespace metadata


Import non-segment user objects

Export TS metadata
Export non-segment obj. Shutdown Immediate Copy datafiles

Set tablespaces READ WRITE


Run ALTER USER script Recompile INVALID OBJECTS

Step 1: Preparation of SOURCE


Install software into a seperate $OH
Choose identical database option Check DBA_REGISTRY
SQL> select comp_name, version, status from dba_registry; COMP_NAME ---------------------------------Oracle Database Catalog Views Oracle Database Packages and Types Oracle Workspace Manager Oracle Enterprise Manager VERSION ----------10.2.0.1.0 10.2.0.1.0 10.2.0.1.0 10.2.0.1.0 STATUS ------VALID VALID VALID VALID

Hint: Use Home Cloning in EM Apply patchset to this $OH

Workflow
SOURCE database env. TARGET database env.

Prepare SOURCE system Create TS scripts Create USER scripts Create EXP/IMP scripts Set tablespace READ ONLY

Installe software and patchset Create `empty database Create USER

Import tablespace metadata


Import non-segment user objects

Export TS metadata
Export non-segment obj. Shutdown Immediate Copy datafiles

Set tablespaces READ WRITE


Run ALTER USER script Recompile INVALID OBJECTS

Step 2: Preparation of TARGET


Create a new database
Use DBCA for a script

Database must contain SYSTEM, TEMP, UNDO and SYSAUX (since 10g) only

Step 2: Preparation of TARGET


CREATE DATABASE script identical charactersets!!
CREATE DATABASE "TARGET"
MAXINSTANCES 8 MAXLOGHISTORY 1 MAXLOGFILES 16 MAXLOGMEMBERS 10 MAXDATAFILES 1000 DATAFILE 'C:\oracle\oradata\TARGET\system01.dbf' SIZE 300M REUSE AUTOEXTEND ON NEXT 10240K MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL SYSAUX DATAFILE 'C:\oracle\oradata\TARGET\sysaux01.dbf' SIZE 120M REUSE AUTOEXTEND ON NEXT 10240K MAXSIZE UNLIMITED SMALLFILE DEFAULT TEMPORARY TABLESPACE TEMP TEMPFILE 'C:\oracle\oradata\TARGET\temp01.dbf' SIZE 20M REUSE AUTOEXTEND ON NEXT 640K MAXSIZE UNLIMITED SMALLFILE UNDO TABLESPACE "UNDOTBS1" DATAFILE 'C:\oracle\oradata\TARGET\undotbs01.dbf' SIZE 100M REUSE AUTOEXTEND ON NEXT 5120K MAXSIZE UNLIMITED CHARACTER SET WE8ISO8859P15 NATIONAL CHARACTER SET AL16UTF16 LOGFILE GROUP 1 ('C:\oracle\oradata\TARGET\redo01.log') SIZE 10000K, GROUP 2 ('C:\oracle\oradata\TARGET\redo02.log') SIZE 10000K, GROUP 3 ('C:\oracle\oradata\TARGET\redo03.log') SIZE 10000K USER SYS IDENTIFIED BY oracle USER SYSTEM IDENTIFIED BY oracle;

Workflow
SOURCE database env. TARGET database env.

Prepare SOURCE system Create TS scripts Create USER scripts Create EXP/IMP scripts Set tablespace READ ONLY

Installe software and patchset Create `empty database Create USER

Import tablespace metadata


Import non-segment user objects

Export TS metadata
Export non-segment obj. Shutdown Immediate Copy datafiles

Set tablespaces READ WRITE


Run ALTER USER script Recompile INVALID OBJECTS

Step 3: Preparation of SOURCE


No user objects in SYSTEM tablespace allowed theyve to be moved into a data tablespace
SELECT owner, segment_name,segment_type FROM dba_segments WHERE tablespace_name='SYSTEM' AND owner not in
('SYS','SYSTEM','DBSNMP','OUTLN','WMSYS','ORDSYS', 'ORDPLUGINS','MDSYS','CTXSYS','XDB','ANONYMOUS');

Take note of Invalid Objects


SELECT owner, object_name, object_type FROM dba_objects WHERE status='INVALID';

Step 3: Preparation of SOURCE


Tablespaces have to be self contained:
exec DBMS_TTS.TRANSPORT_SET_CHECK('USERS,EXAMPLE', TRUE);

SQL> SELECT * FROM TRANSPORT_SET_VIOLATIONS;

Step 3: Preparation of SOURCE


SYSAUX tablespace beginning with 10g:
Automatic Workload Repository AWR can be moved out of SYSAUX with DBMS_SWRF EM repository Users SYSMAN and DBSNMP have to be exported Other repositories Use MOVE_PROCEDURE in V$SYSAUX_OCCUPANTS to move repositories into a seperate tablespace which has to be transported, too. On target system use the same procedure to move repositories back into SYSAUX See also: Note:243246.1

Workflow
SOURCE database env. TARGET database env.

Prepare SOURCE system Create TS scripts Create USER scripts Create EXP/IMP scripts Set tablespace READ ONLY

Installe software and patchset Create `empty database Create USER

Import tablespace metadata


Import non-segment user objects

Export TS metadata
Export non-segment obj. Shutdown Immediate Copy datafiles

Set tablespaces READ WRITE


Run ALTER USER script Recompile INVALID OBJECTS

Step 4: Create Scripts


Create scripts for:
1. Set tablespaces read-only and read-write
SELECT 'alter tablespace ' || tablespace_name || ' read only;' FROM dba_tablespaces WHERE contents='PERMANENT' AND tablespace_name !='SYSTEM' / TS_READ_ONLY.SQL SELECT 'alter tablespace ' || tablespace_name || ' read write;' FROM dba_tablespaces WHERE contents='PERMANENT' AND tablespace_name !='SYSTEM' / TS_READ_WRITE.SQL

2. CREATE and ALTER user statements 3. Parameterfiles for metadata Exp/Imp

Step 4: Create Scripts


Create scripts for:
Set tablespaces read-only and read-write 2. CREATE and ALTER user statements
set escape \ set heading off SELECT substr(dbms_metadata.get_ddl('USER', username),1, instr(dbms_metadata.get_ddl('USER',username), '\''\',1,2)) || ';' FROM dba_users; CREATE_USER.SQL SELECT 'ALTER USER ' || username || ' TEMPORARY TABLESPACE ' || temporary_tablespace || ' DEFAULT TABLESPACE ' || default_tablespace || ';' FROM dba_users; ALTER_USER.SQL

1.

3. Parameterfiles for metadata Exp/Imp

Step 4: Create Scripts


Create scripts for:
Set tablespaces read-only and read-write CREATE and ALTER user statements 3. Parameterfiles for metadata Exp/Imp For export on SOURCE
file=exp_tts.dmp buffer=65536 constraints=y triggers=y grants=y transport_tablespace=y tablespaces=(EXAMPLE, USERS) EXP_META.PAR

1. 2.

For import on TARGET


file=exp_tts.dmp buffer=100000 transport_tablespace=y tablespaces=(EXAMPLE, USERS) datafiles=(C:\oracle\oradata\TARGET\EXAMPLE01.DBF, C:\oracle\oradata\TARGET\USERS01.DBF) IMP_META.PAR

Workflow
SOURCE database env. TARGET database env.

Prepare SOURCE system Create TS scripts Create USER scripts Create EXP/IMP scripts Set tablespace READ ONLY

Installe software and patchset Create `empty database Create USER

Import tablespace metadata


Import non-segment user objects

Export TS metadata
Export non-segment obj. Shutdown Immediate Copy datafiles

Set tablespaces READ WRITE


Run ALTER USER script Recompile INVALID OBJECTS

Step 5: Accomplishment on SOURCE


Set tablespaces read-only:
SQL> @TS_READ_ONLY.SQL

Export metadata:
$ exp parfile=EXP_META.PAR

Export of non-segment user objects:


$ exp file=non_segment_user_data.dmp full=y rows=n constraints=n indexes=n

Shutdown database If required: copy the datafiles

Workflow
SOURCE database env. TARGET database env.

Prepare SOURCE system Create TS scripts Create USER scripts Create EXP/IMP scripts Set tablespace READ ONLY

Installe software and patchset Create `empty database Create USER

Import tablespace metadata


Import non-segment user objects

Export TS metadata
Export non-segment obj. Shutdown Immediate Copy datafiles

Set tablespaces READ WRITE


Run ALTER USER script Recompile INVALID OBJECTS

Step 6: Accomplishment on TARGET


Create the user:
SQL> @CREATE_USER.SQL

Import tablespace metadata:


$ imp parfile=IMP_META.PAR

Import of non-segment user objects:


$ imp file=non_segment_user_data.dmp full=y ignore=y Take note that youll most likely receive errors like ORA-955

Set tablespaces read-write:


SQL> @TS_READ_WRITE.SQL

Workflow
SOURCE database env. TARGET database env.

Prepare SOURCE system Create TS scripts Create USER scripts Create EXP/IMP scripts Set tablespace READ ONLY

Installe software and patchset Create `empty database Create USER

Import tablespace metadata


Import non-segment user objects

Export TS metadata
Export non-segment obj. Shutdown Immediate Copy datafiles

Set tablespaces READ WRITE


Run ALTER USER script Recompile INVALID OBJECTS

Step 6: Accomplishment on TARGET


Alter the users to have their default tablespaces etc.:
SQL> @ALTER_USER.SQL

Recompile if necessary
SQL> SELECT object_name, object_type, status FROM dba_objects WHERE status='INVALID'; SQL> @UTLRP.SQL

Agenda

Basics

Transport

Labs

Info

Agenda

Basics

Transport

Labs

Info

Customer Case
OTN Case Study: Amadeus
www.oracle.com/technology/deploy/availability/pdf/AmadeusProfile.pdf

Using a physical standby


Motivation:
No shutdown of primary database and no move of datafiles necessary Fallback possibility

Switch application on Server 1 to READ ONLY mode Activate physical standby on Server 2 Transport the tablespaces into fresh database on Server 2
9.2.0.5

9.2.0.3

9.2.0.3

Redo Apply Primary Database Physical Standby

TTS

Fresh' DB

Server 1

Server 2

Customer Case
OTN Case Study: The Hartford
http://www.oracle.com/technology/deploy/availability/pdf/TheHartfordProfile_XTTS.pdf

White Paper
Database Upgrade using Transportable Tablespaces
http://www.oracle.com/technology/deploy/availability/pdf/MAA_WP_10gR2_UpgradeTTS.pdf

Platform migration using Transportable Tablespaces


http://www.oracle.com/technology/deploy/availability/pdf/MAA_WP_10gR2_PlatformMigrationTTS.pdf

Things to know
Use same Characterset and National Characterset on SOURCE and TARGET database Use Data Pump instead of conventional exp/imp can be faster!!! Clone the ORACLE_HOMEs to be identical Afterwards rename TARGET with NID (Note:224266.1)

Take a complete backup theres no way to recover from SOURCE to TARGET!!!

Things to think about ...


Conventional upgrade with DBUA isnt much slower TTS takes a lot of preparation time TTS can be slower if:
Lots of objects in a tablespace Then the metadata export/import will slow down the procedure Lots of non-segment user objects Then the full export/import of these objects will take a long time (Large) datafiles have to be moved somewhere else

Very often an effective TTS strategy requires a database redesign!!!

<Insert Picture Here>

Oracle

Email : Igor.Melnikov@oracle.com Phone : +7 (495) 641 14 00 Direct: +7 (495) 641 14 42 Mobile: +7 (915) 205 26 27

Das könnte Ihnen auch gefallen