0% found this document useful (0 votes)
68 views29 pages

Upgrade - Xplatform - Mig

RMAN can be used to perform a cross-platform database migration with minimal downtime. The migration involves taking a full backup of the database on the source platform and converting the byte order if needed. Incremental backups are applied to the backup sets and the datafiles are switched to the converted image copies to perform an immediate recovery on the target platform. Block change tracking can be enabled to improve the performance of incremental backups.

Uploaded by

duonghn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
68 views29 pages

Upgrade - Xplatform - Mig

RMAN can be used to perform a cross-platform database migration with minimal downtime. The migration involves taking a full backup of the database on the source platform and converting the byte order if needed. Incremental backups are applied to the backup sets and the datafiles are switched to the converted image copies to perform an immediate recovery on the target platform. Block change tracking can be enabled to improve the performance of incremental backups.

Uploaded by

duonghn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 29

Cross Platform DB Migration

using RMAN

Arup Nanda
Longtime Oracle Technologist

DocID: P91101Date: 20160930

Why This Session?


• Cross Platform DB Migration • Golden Gate
– Data Pump Export/Import • Truly zero-downtime solution
• Outage Time • Expensive.
• Space needed
– Transportable Tablespace
• Outage Time
– Data Guard
• Has to be same platform
– RMAN Duplicate
• Outage Time

Cross Platform DB Migration Using RMAN


2
Requirement

Cross Platform DB Migration Using RMAN


3

What to expect
• Cross-platform migration
• Without using GoldenGate
• Minimal downtime allowed

Cross Platform DB Migration Using RMAN


4
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 RMAN


5

Data Guard

Cross Platform DB Migration Using RMAN


6
Byte Order

1234 4321
Left to Right Right to Left

1 2 3 4 1 2 3 4

103 102 101 100 100 101 102 103


Endian.
Cross Platform DB Migration Using RMAN
7

Data Guard?
• Data Guard Support for Heterogeneous Primary and Physical
Standbys in Same Data Guard Configuration (Doc ID 413484.1)
PLATFORM_ID PLATFORM_NAME PLATFORM_IDs supported within the same
Release name Data Guard configuration when using Data
Guard Redo Apply (Physical Standby)
2 Solaris[tm] OE (64-bit) 2
Solaris Operating System (SPARC) (64- 6 - See Support Note: 1982638.1 and Note:
bit) 414043.1
3
HP-UX (64-bit)
3 4 - Oracle 10g onward, see Support Note:
HP-UX PA-RISC
395982.1 and Note:414043.1

Cross Platform DB Migration Using RMAN


8
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 RMAN


9

Transportable Tablespace

Cross Platform DB Migration Using RMAN


10
plugin
TS1 TS1

Must be read
f1.dbf f1.dbf
only.

Transporting the tablespace TS1

Cross Platform DB Migration Using RMAN


11

RMAN Incremental Merge

Cross Platform DB Migration Using RMAN


12
Default Recovery

Backup

Sun (Full) Mon Tue Wed Thu

Recovery

Sun (Full) Mon Tue Wed Thu

Cross Platform DB Migration Using RMAN


13

Merged Backup

Database

Full Backup

Incr.

Cross Platform DB Migration Using RMAN


14
Merge Backup
backup incremental
level 1
for recover of copy
with tag weekly
database;
recover
copy of database
with tag weekly;

Cross Platform DB Migration Using RMAN


15

Recovery Scenario

Current

Sun (Full) Mon Tue Wed Thu

Modified

Full Full Full Full Full

Mon Tue Wed Thu

Cross Platform DB Migration Using RMAN


16
Immediate Recovery
Database Use the image copy
Full Backup as main datafile
Incr.

RMAN> switch datafile 5 to copy;

Cross Platform DB Migration Using RMAN


17

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 RMAN


18
BCT
• Command:
alter database enable
block 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 RMAN


19

Immediate Recovery
Database Use the image copy
Full Backup as main datafile
Incr.

RMAN> switch datafile 5 to copy;

Cross Platform DB Migration Using RMAN


20
plugin
TS1 TS1

f1.dbf f1.dbf

Incremental backup apply


Image Copy

Cross Platform DB Migration Using RMAN


21

Endian Conversion

plugin
TS1 TS1

f1.dbf Endian f1.dbf


Conversion

Image Copy
Incremental backup apply

Cross Platform DB Migration Using RMAN


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

PLATFORM_ID PLATFORM_NAME ENDIAN_FORMAT


----------- ----------------------------------- --------------
1 Solaris[tm] OE (32-bit) Big
2 Solaris[tm] OE (64-bit) Big
3 HP-UX (64-bit) Big
4 HP-UX IA (64-bit) Big
5 HP Tru64 UNIX Little
6 AIX-Based Systems (64-bit) Big
7 Microsoft Windows IA (32-bit) Little
8 Microsoft Windows IA (64-bit) Little
9 IBM zSeries Based Linux Big
10 Linux IA (32-bit) Little
11 Linux IA (64-bit) Little
12 Microsoft Windows 64-bit for AMD Little
13 Linux 64-bit for AMD Little
15 HP Open VMS Little
16 Apple Mac OS Big

Cross Platform DB Migration Using RMAN


23

RMAN Endian Conversion


• At source host (TS must be read only)
RMAN> convert tablespace users
2> to platform 'HP-UX (64-bit)'
3> format='/home/oracle/rman_bkups/%N_%f';
• At target
RMAN> convert tablespace users, maints
2> to platform 'HP-UX (64-bit)'
3> format='/home/oracle/rman_bkups/%N_%f'
4> parallelism = 5;
http://www.oracle.com/technetwork/articles/sql/week16-10gdba-094518.html

Cross Platform DB Migration Using RMAN


24
Steps
Source Target
1 Take RMAN Image Copy
2 Copy to Target
3 Convert Endian Format
4 Take Incremental Backup
5 Copy to target
Loop
6 Convert Endian Format
7 Apply Incremental to the Image Copy
8 Make Tablespace Read Only
9 Take Final RMAN Incremental Backup
Outage 10 Apply Incremental to Image Copy
11 Use Image Copy as Source for
Transported Tablespace
Cross Platform DB Migration Using RMAN
25

Steps

Cross Platform DB Migration Using RMAN


26
.Create a Target DB
• Create a database with all minimum tablespaces
• SYSTEM, SYSAUX, etc.
• No user tablespaces

Cross Platform DB Migration Using RMAN


27

.Export Metadata
• Export all metadata from source system
expdp ... dumpfile=metadata_full.dmp full=y
content=metadata_only
exclude=user,role,role_grant,profile
exclude=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 RMAN


28
.Take an Image Copy Backup
• RMAN Image Copy
• We divided the files into multiple sets.
RMAN> backup as copy tag 'set001' datafile
11,12,13,14 format '/imgbak1/file%f.bkp;
• Parallelize the image copy creation process
• Restart if something fails

Cross Platform DB Migration Using RMAN


29

Pipe the Image Copy

Source System Target System


Unix Pipe

Cross Platform DB Migration Using RMAN


30
Use NAS

Source System Target System

NAS

Cross Platform DB Migration Using RMAN


31

.Convert the Image Copy


• On the target system
• If the endian format is different
RMAN> 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 RMAN


32
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 RMAN


33

.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 RMAN


34
Convert Endian-ness
• If needed, as shown earlier

Cross Platform DB Migration Using RMAN


35

.Apply the Incrementals dbms_backup_restore.restoresetpiece


(
declare handle => '/incbk1/bk42.bkp',
l_dev varchar2(4000); tag => null,
l_hdl varchar2(4000); fromdisk => true,
l_tag varchar2(4000); recid => 0,
l_done Boolean;
stamp => 0
);
begin
l_dev := sys.dbms_backup_restore.deviceallocate;
dbms_backup_restore.applysetdatafile dbms_backup_restore.restorebackuppiece
(check_logical=>false, cleanup=>false); (
done => l_done,
dbms_backup_restore.applydatafileto ( params => null,
dfnumber => 42, outhandle => l_hdl,
toname => '/dbloc/f42.dbf', outtag => l_tag,
fuzziness_hint => 0, failover => failover
max_corrupt => 0, );
islevel0 => 0,
recid => 0, dbms_backup_restore.restorecancel (true);
stamp => 0 dbms_backup_restore.devicedeallocate;
); end;
/

Cross Platform DB Migration Using RMAN


36
Repeat Until Day 0
• Take Incremental Backup
• Convert at Target
• Apply to Image Copy

Cross Platform DB Migration Using RMAN


37

D-Day

Cross Platform DB Migration Using RMAN


38
.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 RMAN


39

Outage Starts

Cross Platform DB Migration Using RMAN


40
.Make Tablespaces Read Only
• On the Source Database
begin
for tsname in (
select tablespace_name
from dba_tablespaces
where 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 RMAN


41

.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 RMAN


42
.Take Metadata Export
• Metadata export of all user tablespaces
expdp ... exclude=table_statistics
exclude=index_statistics dumpfile=transport.dmp
• Excluding the stats since we take them separately

Cross Platform DB Migration Using RMAN


43

11 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 RMAN


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

Cross Platform DB Migration Using RMAN


45

13 Plug the TS’es in


• Import all transportable tablespaces.
impdp dumpfile=transport.dmp
transport_datafiles='/db/f42.dbf','/db/f43.dbf',…
• Note the location of the files
• It’s the image copy location

Cross Platform DB Migration Using RMAN


46
14 Make it Read Write
• The plugged in TS’es are all Read Only
begin
for tsname in (
select tablespace_name
from dba_tablespaces
where 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 RMAN


47

15 Import Rest of the Objects


• Import all other objects
– Except stats
impdp ... dumpfile=full.dmp full=y
exclude=table_statistics
exclude=index_statistics

Cross Platform DB Migration Using RMAN


48
16 Adjust Sequences
• Sequence caches could have been used
• Options
1. 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 RMAN


49

17 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 RMAN


50
18 Recompile Invalid Objects
• Some objects may have become invalid
• Compile them
SQL> @$OH/rdbms/admin/utlrp.sql

Cross Platform DB Migration Using RMAN


51

19 Gather Stats
• Optimizer stats are not present, yet
• Options:
1. Gather fresh stats
2. Reinstate stats from the source

Cross Platform DB Migration Using RMAN


52
FINISHED!

Cross Platform DB Migration Using RMAN


53

If NAS was used …

Source System Target System

NAS

Cross Platform DB Migration Using RMAN


54
Create the DB on the SAN

Source System Target System

RMAN Duplicate
Database
NAS SAN

Cross Platform DB Migration Using RMAN


55

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 RMAN


56
Thank You!
Blog: arup.blogspot.com Download this session here.
Tweeter: @ArupNanda
Facebook.com/ArupKNanda
Cross Platform DB Migration Using RMAN 57

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy