29

Click here to load reader

Cross Platform DB Migration using RMAN - Proligenceproligence.com/pres/nzoug16/xplatform_mig.pdfLongtime Oracle Technologist DocID: ... • Truly zero-downtime solution ... Cross Platform

  • Upload
    hahuong

  • View
    267

  • Download
    7

Embed Size (px)

Citation preview

Page 1: Cross Platform DB Migration using RMAN - Proligenceproligence.com/pres/nzoug16/xplatform_mig.pdfLongtime Oracle Technologist DocID: ... • Truly zero-downtime solution ... Cross Platform

Cross Platform DB Migration using RMAN

Arup NandaLongtime Oracle Technologist

DocID: P91101Date: 20160930

Why This Session?• Cross Platform DB Migration

– Data Pump Export/Import• Outage Time

• Space needed

– Transportable Tablespace• Outage Time

– Data Guard• Has to be same platform

– RMAN Duplicate• Outage Time

Cross Platform DB Migration Using RMAN2

• Golden Gate• Truly zero-downtime solution• Expensive.

Page 2: Cross Platform DB Migration using RMAN - Proligenceproligence.com/pres/nzoug16/xplatform_mig.pdfLongtime Oracle Technologist DocID: ... • Truly zero-downtime solution ... Cross Platform

Requirement

Cross Platform DB Migration Using RMAN3

What to expect• Cross-platform migration

• Without using GoldenGate

• Minimal downtime allowed

Cross Platform DB Migration Using RMAN4

Page 3: Cross Platform DB Migration using RMAN - Proligenceproligence.com/pres/nzoug16/xplatform_mig.pdfLongtime Oracle Technologist DocID: ... • Truly zero-downtime solution ... Cross Platform

What not to expect• Not a general purpose migration discussion

• Not a prescription for every situation

• Feel free to copy and use the scripts; but use at your own risk

Cross Platform DB Migration Using RMAN5

Cross Platform DB Migration Using RMAN6

Data Guard

Page 4: Cross Platform DB Migration using RMAN - Proligenceproligence.com/pres/nzoug16/xplatform_mig.pdfLongtime Oracle Technologist DocID: ... • Truly zero-downtime solution ... Cross Platform

Byte Order

Cross Platform DB Migration Using RMAN7

1234 4321Left to Right Right to Left

1 2 3 4 1 2 3 4

103 102 101 100 100 101 102 103

Endian.

Data Guard?• Data Guard Support for Heterogeneous Primary and Physical

Standbys in Same Data Guard Configuration (Doc ID 413484.1)

Cross Platform DB Migration Using RMAN8

PLATFORM_ID PLATFORM_NAMERelease name

PLATFORM_IDs supported within the same Data Guard configuration when using Data Guard Redo Apply (Physical Standby)

2 Solaris[tm] OE (64-bit)Solaris Operating System (SPARC) (64-bit)

26 - See Support Note: 1982638.1 and Note: 414043.1

3 HP-UX (64-bit)HP-UX PA-RISC

34 - Oracle 10g onward, see Support Note: 395982.1 and Note:414043.1

Page 5: Cross Platform DB Migration using RMAN - Proligenceproligence.com/pres/nzoug16/xplatform_mig.pdfLongtime Oracle Technologist DocID: ... • Truly zero-downtime solution ... Cross Platform

Same Endian Format Bugs• Possible bugs, e.g. 13104881 ORA-600 [6101] DATA CORRUPTION

IN 11.2.0.2 WINDOWS TO LINUX STANDBY DUPLICATION

Cross Platform DB Migration Using RMAN9

Cross Platform DB Migration Using RMAN10

Transportable Tablespace

Page 6: Cross Platform DB Migration using RMAN - Proligenceproligence.com/pres/nzoug16/xplatform_mig.pdfLongtime Oracle Technologist DocID: ... • Truly zero-downtime solution ... Cross Platform

Cross Platform DB Migration Using RMAN11

TS1

f1.dbf

TS1plugin

f1.dbf

Transporting the tablespace TS1

Must be read only.

Cross Platform DB Migration Using RMAN12

RMAN Incremental Merge

Page 7: Cross Platform DB Migration using RMAN - Proligenceproligence.com/pres/nzoug16/xplatform_mig.pdfLongtime Oracle Technologist DocID: ... • Truly zero-downtime solution ... Cross Platform

Default Recovery

Backup

Sun (Full) Mon Tue Wed Thu

Recovery

Sun (Full) Mon Tue Wed Thu

Cross Platform DB Migration Using RMAN13

Merged Backup

Database

Full Backup

Incr.

Cross Platform DB Migration Using RMAN14

Page 8: Cross Platform DB Migration using RMAN - Proligenceproligence.com/pres/nzoug16/xplatform_mig.pdfLongtime Oracle Technologist DocID: ... • Truly zero-downtime solution ... Cross Platform

Merge Backupbackup incremental level 1 for recover of copy with tag weekly database; recover copy of database with tag weekly;

Cross Platform DB Migration Using RMAN15

Recovery Scenario

Current

Sun (Full) Mon Tue Wed Thu

Modified

Full

Mon Tue Wed Thu

Full Full Full Full

Cross Platform DB Migration Using RMAN16

Page 9: Cross Platform DB Migration using RMAN - Proligenceproligence.com/pres/nzoug16/xplatform_mig.pdfLongtime Oracle Technologist DocID: ... • Truly zero-downtime solution ... Cross Platform

Immediate Recovery

Cross Platform DB Migration Using RMAN17

Database

Full Backup

Incr.

Use the image copy as main datafile

RMAN> switch datafile 5 to copy;

BCT File• Incremental backup still goes through the files to see which

blocks changed

• Adds to time and performance

• Enter – Block Change Tracking

Cross Platform DB Migration Using RMAN18

Page 10: Cross Platform DB Migration using RMAN - Proligenceproligence.com/pres/nzoug16/xplatform_mig.pdfLongtime Oracle Technologist DocID: ... • Truly zero-downtime solution ... Cross Platform

BCT• Command:

alter database enableblock change tracking using file'/home/oracle/orabackup/bct_prodb2.dbf';

• Must be available to all instances of RAC.• Size approx 10MB per 1 TB• Test: select * from v$block_change_tracking;• Ensure: select used_change_tracking from v$backup_datafile;

Cross Platform DB Migration Using RMAN19

Immediate Recovery

Cross Platform DB Migration Using RMAN20

Database

Full Backup

Incr.

Use the image copy as main datafile

RMAN> switch datafile 5 to copy;

Page 11: Cross Platform DB Migration using RMAN - Proligenceproligence.com/pres/nzoug16/xplatform_mig.pdfLongtime Oracle Technologist DocID: ... • Truly zero-downtime solution ... Cross Platform

Cross Platform DB Migration Using RMAN21

TS1

f1.dbf

TS1plugin

f1.dbf

Image CopyIncremental backup apply

Endian Conversion

Cross Platform DB Migration Using RMAN22

TS1

f1.dbf

TS1plugin

f1.dbf

Image CopyIncremental backup apply

Endian Conversion

Page 12: Cross Platform DB Migration using RMAN - Proligenceproligence.com/pres/nzoug16/xplatform_mig.pdfLongtime Oracle Technologist DocID: ... • Truly zero-downtime solution ... Cross Platform

Convert Byte Order• First, find the platformSQL> select * from v$transportable_platform order by platform_id;

PLATFORM_ID PLATFORM_NAME ENDIAN_FORMAT----------- ----------------------------------- --------------

1 Solaris[tm] OE (32-bit) Big2 Solaris[tm] OE (64-bit) Big3 HP-UX (64-bit) Big4 HP-UX IA (64-bit) Big5 HP Tru64 UNIX Little6 AIX-Based Systems (64-bit) Big7 Microsoft Windows IA (32-bit) Little8 Microsoft Windows IA (64-bit) Little9 IBM zSeries Based Linux Big

10 Linux IA (32-bit) Little11 Linux IA (64-bit) Little12 Microsoft Windows 64-bit for AMD Little13 Linux 64-bit for AMD Little15 HP Open VMS Little16 Apple Mac OS Big

Cross Platform DB Migration Using RMAN23

RMAN Endian Conversion• At source host (TS must be read only)

RMAN> convert tablespace users2> to platform 'HP-UX (64-bit)'3> format='/home/oracle/rman_bkups/%N_%f';

• At targetRMAN> convert tablespace users, maints

2> to platform 'HP-UX (64-bit)'3> format='/home/oracle/rman_bkups/%N_%f'4> parallelism = 5;

Cross Platform DB Migration Using RMAN24

http://www.oracle.com/technetwork/articles/sql/week16-10gdba-094518.html

Page 13: Cross Platform DB Migration using RMAN - Proligenceproligence.com/pres/nzoug16/xplatform_mig.pdfLongtime Oracle Technologist DocID: ... • Truly zero-downtime solution ... Cross Platform

Steps

Cross Platform DB Migration Using RMAN25

Source Target

1 Take RMAN Image Copy

2 Copy to Target

3 Convert Endian Format

4 Take Incremental Backup

5 Copy to target

6 Convert Endian Format

7 Apply Incremental to the Image Copy

8 Make Tablespace Read Only

9 Take Final RMAN Incremental Backup

10 Apply Incremental to Image Copy

11 Use Image Copy as Source for Transported Tablespace

Outage

Loop

Cross Platform DB Migration Using RMAN26

Steps

Page 14: Cross Platform DB Migration using RMAN - Proligenceproligence.com/pres/nzoug16/xplatform_mig.pdfLongtime Oracle Technologist DocID: ... • Truly zero-downtime solution ... Cross Platform

.Create a Target DB• Create a database with all minimum tablespaces

• SYSTEM, SYSAUX, etc.

• No user tablespaces

Cross Platform DB Migration Using RMAN27

.Export Metadata• Export all metadata from source system

expdp ... dumpfile=metadata_full.dmp full=y content=metadata_onlyexclude=user,role,role_grant,profileexclude=table_statistics exclude=index_statistics

• Excluding users, roles, profiles, etc. (will do later)

• Excluding statistics– Exporting stats are time consuming

– more so during import

Cross Platform DB Migration Using RMAN28

Page 15: Cross Platform DB Migration using RMAN - Proligenceproligence.com/pres/nzoug16/xplatform_mig.pdfLongtime Oracle Technologist DocID: ... • Truly zero-downtime solution ... Cross Platform

.Take an Image Copy Backup• RMAN Image Copy

• We divided the files into multiple sets.RMAN> backup as copy tag 'set001' datafile11,12,13,14 format '/imgbak1/file%f.bkp; • Parallelize the image copy creation process

• Restart if something fails

Cross Platform DB Migration Using RMAN29

Pipe the Image Copy

Cross Platform DB Migration Using RMAN30

Source System Target System

Unix Pipe

Page 16: Cross Platform DB Migration using RMAN - Proligenceproligence.com/pres/nzoug16/xplatform_mig.pdfLongtime Oracle Technologist DocID: ... • Truly zero-downtime solution ... Cross Platform

Use NAS

Cross Platform DB Migration Using RMAN31

Source System Target System

NAS

.Convert the Image Copy• On the target system

• If the endian format is differentRMAN> datafile '/imgbk1/users01.dbf'

2> format='/db/users01.dbf'3> parallelism = 16;

• No need to restore anything, yet.

• This becomes the Level 0 Image Copy

Cross Platform DB Migration Using RMAN32

Page 17: Cross Platform DB Migration using RMAN - Proligenceproligence.com/pres/nzoug16/xplatform_mig.pdfLongtime Oracle Technologist DocID: ... • Truly zero-downtime solution ... Cross Platform

Prepare for Incremental• Incremental from “what”?

– There is already another backup (the regular one)

• RMAN incremental has a “from SCN” clause.– http://arup.blogspot.com/2009/12/resolving-gaps-in-data-guard-apply.html

• Find the checkpoint SCN# select min(checkpoint_change#) from v$datafile;

• Record MIN-CKPT-NO.

Cross Platform DB Migration Using RMAN33

.Backup Incremental• Backup incremental:

backup incremental from scn <MIN-CKPT-NO> tablespace 'TS1' format '/incbk1/%U';

• The name doesn’t matter; the location does.

Cross Platform DB Migration Using RMAN34

Page 18: Cross Platform DB Migration using RMAN - Proligenceproligence.com/pres/nzoug16/xplatform_mig.pdfLongtime Oracle Technologist DocID: ... • Truly zero-downtime solution ... Cross Platform

Convert Endian-ness• If needed, as shown earlier

Cross Platform DB Migration Using RMAN35

.Apply the Incrementalsdeclare l_dev varchar2(4000); l_hdl varchar2(4000); l_tag varchar2(4000); l_done Boolean;

begin l_dev := sys.dbms_backup_restore.deviceallocate; dbms_backup_restore.applysetdatafile

(check_logical=>false, cleanup=>false);

dbms_backup_restore.applydatafileto ( dfnumber => 42, toname => '/dbloc/f42.dbf', fuzziness_hint => 0, max_corrupt => 0, islevel0 => 0, recid => 0, stamp => 0

);

Cross Platform DB Migration Using RMAN36

dbms_backup_restore.restoresetpiece(

handle => '/incbk1/bk42.bkp', tag => null, fromdisk => true, recid => 0, stamp => 0

);

dbms_backup_restore.restorebackuppiece(

done => l_done, params => null, outhandle => l_hdl, outtag => l_tag, failover => failover

);

dbms_backup_restore.restorecancel (true); dbms_backup_restore.devicedeallocate;end; /

Page 19: Cross Platform DB Migration using RMAN - Proligenceproligence.com/pres/nzoug16/xplatform_mig.pdfLongtime Oracle Technologist DocID: ... • Truly zero-downtime solution ... Cross Platform

Repeat Until Day 0• Take Incremental Backup

• Convert at Target

• Apply to Image Copy

Cross Platform DB Migration Using RMAN37

Cross Platform DB Migration Using RMAN38

D-Day

Page 20: Cross Platform DB Migration using RMAN - Proligenceproligence.com/pres/nzoug16/xplatform_mig.pdfLongtime Oracle Technologist DocID: ... • Truly zero-downtime solution ... Cross Platform

.Export Stats• Export the stats from the source

begin dbms_stats.create_stat_table

(<User1>,'USER1_STATS'); end;

• Repeat for all relevant users

• Alternative:dbms_stats.export_database_stats

('USER1_STATS','WHOLE_DB',user);

Cross Platform DB Migration Using RMAN39

Cross Platform DB Migration Using RMAN40

Outage Starts

Page 21: Cross Platform DB Migration using RMAN - Proligenceproligence.com/pres/nzoug16/xplatform_mig.pdfLongtime Oracle Technologist DocID: ... • Truly zero-downtime solution ... Cross Platform

.Make Tablespaces Read Only• On the Source Databasebegin

for tsname in ( select tablespace_namefrom dba_tablespaceswhere tablespace_name not in ('SYSTEM','SYSAUX') and contents = 'PERMANENT'

) loop execute immediate

'alter tablespace '||tsname.tablespace_name||' read only';

end loop; end; /

Cross Platform DB Migration Using RMAN41

.Export all Users, Roles, etc.• Take a datapump export of all users, roles, grants, etc.expdp ... full=y include=user,role,role_grant,profile

• Copy over to the target system

Cross Platform DB Migration Using RMAN42

Page 22: Cross Platform DB Migration using RMAN - Proligenceproligence.com/pres/nzoug16/xplatform_mig.pdfLongtime Oracle Technologist DocID: ... • Truly zero-downtime solution ... Cross Platform

.Take Metadata Export• Metadata export of all user tablespacesexpdp ... exclude=table_statisticsexclude=index_statistics dumpfile=transport.dmp

• Excluding the stats since we take them separately

Cross Platform DB Migration Using RMAN43

Final Incremental• Take a final incremental backup

• Apply it to the Image Copy at the target system

• Now the Image copy is up to date.

Cross Platform DB Migration Using RMAN44

11

Page 23: Cross Platform DB Migration using RMAN - Proligenceproligence.com/pres/nzoug16/xplatform_mig.pdfLongtime Oracle Technologist DocID: ... • Truly zero-downtime solution ... Cross Platform

Create Users • Create or users, roles, privileges, profiles, etc.impdp ... full=y include=user,role,role_grant,profile

Cross Platform DB Migration Using RMAN45

12

Plug the TS’es in• Import all transportable tablespaces.

impdp dumpfile=transport.dmptransport_datafiles='/db/f42.dbf','/db/f43.dbf',…

• Note the location of the files

• It’s the image copy location

Cross Platform DB Migration Using RMAN46

13

Page 24: Cross Platform DB Migration using RMAN - Proligenceproligence.com/pres/nzoug16/xplatform_mig.pdfLongtime Oracle Technologist DocID: ... • Truly zero-downtime solution ... Cross Platform

Make it Read Write• The plugged in TS’es are all Read Onlybegin

for tsname in ( select tablespace_namefrom dba_tablespaceswhere tablespace_name not in ('SYSTEM','SYSAUX') and contents = 'PERMANENT'

) loop execute immediate

'alter tablespace '||tsname.tablespace_name||' read write';

end loop; end; /

Cross Platform DB Migration Using RMAN47

14

Import Rest of the Objects• Import all other objects

– Except statsimpdp ... dumpfile=full.dmp full=y exclude=table_statisticsexclude=index_statistics

Cross Platform DB Migration Using RMAN48

15

Page 25: Cross Platform DB Migration using RMAN - Proligenceproligence.com/pres/nzoug16/xplatform_mig.pdfLongtime Oracle Technologist DocID: ... • Truly zero-downtime solution ... Cross Platform

Adjust Sequences• Sequence caches could have been used

• Options1. Drop all sequences and import them from source

1. Recompile all objects

2. Increment the values to use up to the cache value

Cross Platform DB Migration Using RMAN49

16

DB Links• DB links point to different hosts

• The may not be open for firewalls

• Check and adjust as needed

Cross Platform DB Migration Using RMAN50

17

Page 26: Cross Platform DB Migration using RMAN - Proligenceproligence.com/pres/nzoug16/xplatform_mig.pdfLongtime Oracle Technologist DocID: ... • Truly zero-downtime solution ... Cross Platform

Recompile Invalid Objects• Some objects may have become invalid

• Compile themSQL> @$OH/rdbms/admin/utlrp.sql

Cross Platform DB Migration Using RMAN51

18

Gather Stats• Optimizer stats are not present, yet

• Options:1. Gather fresh stats

2. Reinstate stats from the source

Cross Platform DB Migration Using RMAN52

19

Page 27: Cross Platform DB Migration using RMAN - Proligenceproligence.com/pres/nzoug16/xplatform_mig.pdfLongtime Oracle Technologist DocID: ... • Truly zero-downtime solution ... Cross Platform

Cross Platform DB Migration Using RMAN53

FINISHED!

If NAS was used …

Cross Platform DB Migration Using RMAN54

Source System Target System

NAS

Page 28: Cross Platform DB Migration using RMAN - Proligenceproligence.com/pres/nzoug16/xplatform_mig.pdfLongtime Oracle Technologist DocID: ... • Truly zero-downtime solution ... Cross Platform

Create the DB on the SAN

Cross Platform DB Migration Using RMAN55

Source System Target System

NAS SAN

RMAN Duplicate Database

Valuable Tips• Convert endian format at the target; not the source

– Doesn’t affect the source’s CPU

• Maximize parallelism in RMAN convert operation

• Importing statistics as a part of full export takes about 10X longer– Better off re-gathering stats

• Watch out for DB link invalidations due to new source host– Firewalls may need to be adjusted, ports need to be open

• Don’t skip sequence adjustment

Cross Platform DB Migration Using RMAN56

Page 29: Cross Platform DB Migration using RMAN - Proligenceproligence.com/pres/nzoug16/xplatform_mig.pdfLongtime Oracle Technologist DocID: ... • Truly zero-downtime solution ... Cross Platform

Thank You!Blog: arup.blogspot.com Download this session here.

Tweeter: @ArupNandaFacebook.com/ArupKNanda

57Cross Platform DB Migration Using RMAN