Migrate database to Exadata with DBMS_FILE_TRANSFER

lovestanford發表於2015-07-14
目前正在執行資料庫遷移業務,將移動的資料庫從IBM小雞遷移到X86 Server SAN的伺服器,遷移方法參考metalink的文件,值得借鑑和學習。
實際遷移step-step詳細步驟和中間過程待遷移完成之後再補上。

In this Document


Goal

Solution
  Introduction
  1. Initial setup (phase 1)
  1.1. Source database
  1.2. Destination database
  2. Transport datafiles (phase 2)
  2.1. Create the transport scripts on the source system
  2.2. Transfer the datafiles to the destination
  3. Incrementally updated backups (phase 3)
  3.1. Create incremental backups of the source datafiles
  3.2. Transfer incremental backups to destination
  3.3. Apply incremental backups on destination
  3.4. Determine the FROM SCN for next incremental backup
  4. Plug in transported tablespaces (phase 4)
  4.1. Make source tablespaces READ ONLY
  4.2. Final incremental backup
  4.3. Final incremental backup merge
  4.4. Import the transported tablespaces metadata
  4.5. Validate plugged in tablespaces at destination
  Conclusion

References


Applies to:

Oracle Database - Enterprise Edition - Version 10.2.0.1 to 12.1.0.1 [Release 10.2 to 12.1]
Oracle Solaris on SPARC (64-bit)
Linux x86-64

Goal

Database migration to Exadata can be accomplished in a number of ways, as discussed in
Oracle? Database High Availability Best Practices 11g Release 2 (11.2)
Chapter 14 Reducing Downtime for Planned Maintenance
Section 14.2.7 Database Platform or Location Migration.

One way to perform this task is the Transportable Tablespaces for Platform Migration. The method described in this document can be used to migrate any database (version 10.2 to 11.2.0.4), from any platform, to 11.2.0.4 and later on Exadata. We have successfully performed the migration from Solaris SPARC (database versions 10.2.0.1, 10.2.0.4 and 11.2.0.3), IBM AIX (database version 11.1.0.7) and Linux (database version 11.2.0.3) to 11.2.0.4 and 12.1.0.1.0 on Exadata.

Solution

Introduction

This document shows an example of the transportable tablespaces for platform migration from 10.2.0.4 on Solaris SPARC to 11.2.0.4 on Exadata. For more examples please see the attachments:




In the initial phase we determine which tablespaces from the source database will be migrated and make sure all datafiles for those tablespaces are available. We ensure the destination database is available and that it has the same character set and the national character set as the source database. We download the rman_xttconvert_1.4.zip from Doc ID 1389592.1, and configure our migration environment.

In the phase two, we transport the datafiles from the source to the destination, using the DBMS_FILE_TRANSFER package. More specifically, we run DBMS_FILE_TRANSFER.GET_FILE procedure in the destination database, to transfer the datafiles from the source and perform the endian conversion. Note that we do this with the fuzzy datafiles, i.e. all source datafiles are in read write mode during this phase.

In the phase three, we take incremental backups of the source datafiles we transferred, and merge them with the datafiles on the destination. The aim of this approach is to reduce the downtime of the source database, during the migration process. The incremental backups and the merge with the destination datafiles, allow us to keep the destination datafiles in near sync with the source, regardless of the time it takes to transfer the datafiles.

If the source database downtime (duration) is of no concern, there is no need to use the method described in this document. You could simply perform the transportable tablespace migration in three steps: create transportable tablespace set on source, transfer the datafiles and metadata to destination, and plug the tablespaces in at the destination.

In the phase four, we put the datafiles in in read only mode, take the final incremental backup, merge those backups, and plug in the tablespaces into the destination database. The total downtime is equivalent to the time it takes to complete this phase.

1. Initial setup (phase 1)

1.1. Source database

The source database (SPARCDB) version 10.2.0.4.0, is running on Solaris SPARC 64-bit:

[sparc]/export/home/oracle> env | egrep "ORACLE_SID|ORACLE_HOME"
ORACLE_SID=SPARCDB
ORACLE_HOME=/u01/app/oracle/product/10.2/dbhome_1

[sparc]/export/home/oracle> sqlplus / as sysdba

SQL> select * from v$version where banner like '%Database%';

BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi

SQL> select name, platform_id, platform_name from v$database;

NAME      PLATFORM_ID PLATFORM_NAME
--------- ----------- -----------------------
SPARCDB             2 Solaris[tm] OE (64-bit)


The tablespaces to be transported are TSPACE1, TSPACE2 and TSPACE3:

SQL> select t.name "Tablespace", f.file# "File#", f.name "Filename", f.status "Status"
from v$datafile f, v$tablespace t
where f.ts#=t.ts# and t.name like 'TSPACE%'
order by 1, 2;

Tablespace   File# Filename                            Status
----------- ------ --------------------------------------------    ------
TSPACE1          7  +DATA/brsparc/datafile/tspace1.263.851501029    ONLINE
TSPACE2          8  +DATA/brsparc/datafile/tspace2.262.851501039    ONLINE
TSPACE2          9  +DATA/brsparc/datafile/tspace2.260.851501057    ONLINE
TSPACE3         10 +DATA/brsparc/datafile/tspace3.261.851501069    ONLINE
TSPACE3         11 +DATA/brsparc/datafile/tspace3.259.851501077    ONLINE
TSPACE3         12 +DATA/brsparc/datafile/tspace3.258.851501083    ONLINE


Note that the tablespace TSPACE1 has a single datafile, TSPACE2 has two datafiles, and TSPACE3 has three datafiles.

The source directory object (for DBMS_FILE_TRANSFER) is SOURCEDIR:

SQL> create directory SOURCEDIR as '+DATA/brsparc/datafile';

Directory created.


The source database is in archivelog mode:

SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     31
Next log sequence to archive   33
Current log sequence           33


The TMPDIR environment variable is set as follows:

[sparc]/export/home/oracle> export TMPDIR=/export/home/oracle/xtt


The rman_xttconvert_1.4.zip was transferred and extracted to /export/home/oracle/xtt directory:

[sparc]/export/home/oracle/xtt> unzip rman_xttconvert_1.4.zip
Archive:  rman_xttconvert_1.4.zip
  inflating: xttcnvrtbkupdest.sql
  inflating: xttdbopen.sql
  inflating: xttdriver.pl
  inflating: xttprep.tmpl
  inflating: xtt.properties
  inflating: xttstartupnomount.sql


The parameters in the xtt.properties were defined as follows:

[sparc]/export/home/oracle/xtt> grep ^[a-z] xtt.properties
tablespaces=TSPACE1,TSPACE2,TSPACE3
platformid=2
srcdir=SOURCEDIR
dstdir=DESTDIR
srclink=SPARCLINK
dfcopydir=/export/home/oracle/stage_source
backupformat=/export/home/oracle/stage_source
stageondest=/home/oracle/stage_dest
backupondest=+RECO_EXA
asm_home=/u01/app/11.2.0.4/grid
asm_sid=+ASM2


Most of the parameters are self explanatory and are described in the xtt.properties file. Note that the platformid should be set to the source database platform id, obtained by querying v$database as shown above.

The xttconvert files, including the xtt.properties with the parameters defined in the previous step, were copied from the source to the destination server:

[sparc]/export/home/oracle> scp -r /export/home/oracle/xtt oracle@exadata:/home/oracle
oracle@exadata's password:
xttcnvrtbkupdest.sql                              100% 1390     1.4KB/s   00:00
xttdbopen.sql                                     100%   71     0.1KB/s   00:00
xttdriver.pl                                      100%   56KB  56.4KB/s   00:00
xttprep.tmpl                                      100% 9728     9.5KB/s   00:00
xtt.properties                                    100% 5326     5.2KB/s   00:00
xttstartupnomount.sql                             100%   52     0.1KB/s   00:00

1.2. Destination database

The destination database (EXADB) version 11.2.0.4.0, is running on Exadata (Linux x86 64-bit):

[oracle@exadata ~]$ env | egrep "ORACLE_SID|ORACLE_HOME"
ORACLE_SID=EXADB2
ORACLE_HOME=/u01/app/oracle/product/11.2.0.4/dbhome_1

[oracle@exadata ~]$ sqlplus / as sysdba

SQL> select * from v$version where banner like '%Database%';

BANNER
----------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

SQL> select name, platform_id, platform_name from v$database;

NAME      PLATFORM_ID PLATFORM_NAME
--------- ----------- ------------------------
EXADB             13 Linux x86 64-bit


NOTE: It is important that both the source and the destination database have the same character set and the national character set. In our case those are AL32UTF8 and UTF8:

SQL> select PARAMETER, VALUE
from v$nls_parameters
where PARAMETER in ('NLS_CHARACTERSET', 'NLS_NCHAR_CHARACTERSET');

PARAMETER                        VALUE
-------------------------------- --------------------------------
NLS_CHARACTERSET                 AL32UTF8
NLS_NCHAR_CHARACTERSET           UTF8


Database link to the source database is SPARCLINK:

SQL> create public database link SPARCLINK connect to system identified by welcome1 using 'SPARCDB';

Database link created.

SQL> select * from dual@SPARCLINK;

D
-
X


The destination directory object (for DBMS_FILE_TRANSFER) is DESTDIR:

SQL> create directory DESTDIR as '+DATA_EXA/EXADB/datafile';

Directory created.


The staging area on the destination server (xtt.properties::stageondest) is directory /home/oracle/stage_dest.

The TMPDIR environment variable is set as follows:

[oracle@exadata ~]$ export TMPDIR=/home/oracle/xtt

2. Transport datafiles (phase 2)

During this phase the datafiles are transferred from the source to the final location in the destination database. The endian conversion is performed automatically by the DBMS_FILE_TRANSFER package. The steps in this phase are run only once. The data being transported is fully accessible in the source database during this phase.

NOTE: The xttdriver.pl requires perl version 5.10 or later. Both Solaris 10 and Oracle RDBMS version 10.2.0.4 come with perl version 5.8. Ask your system administrator to install perl version 5.10, or get it from any Solaris 11 server running Oracle RDBMS version 11.2, as follows:

On Solaris 11 server with RDBMS version 11.2:

$ cd $ORACLE_HOME
$ tar cjf perl.tar.bz2 perl

On Solaris 10 server:

$ cd $ORACLE_HOME
$ mv perl perl_5.8
$ scp oracle@:/perl.tar.bz2 .
$ bunzip2 perl.tar.bz2
$ tar xf perl.tar -C perl
$ $ORACLE_HOME/perl/bin/perl -v | grep solaris
This is perl, v5.10.0 built for sun4-solaris-thread-multi-64

2.1. Create the transport scripts on the source system

On the source system, log in as the oracle user, set the environment to the source database, and set the TMPDIR:

[sparc]/export/home/oracle> . oraenv
ORACLE_SID = [oracle] ? SPARCDB
[sparc]/export/home/oracle> export TMPDIR=/export/home/oracle/xtt
[sparc]/export/home/oracle> cd $TMPDIR
[sparc]/export/home/oracle/xtt>


Run the 'perl xttdriver.pl -S':

[sparc]/export/home/oracle/xtt> $ORACLE_HOME/perl/bin/perl xttdriver.pl -S
Prepare source for Tablespaces:
                  'TSPACE1'  /home/oracle/stage_dest
xttpreparesrc.sql for 'TSPACE1' started at Sun Jun 29 08:13:19 2014
xttpreparesrc.sql for  ended at Sun Jun 29 08:13:19 2014
Prepare source for Tablespaces:
                  'TSPACE2'  /home/oracle/stage_dest
xttpreparesrc.sql for 'TSPACE2' started at Sun Jun 29 08:13:19 2014
xttpreparesrc.sql for  ended at Sun Jun 29 08:13:19 2014
Prepare source for Tablespaces:
                  'TSPACE3'  /home/oracle/stage_dest
xttpreparesrc.sql for 'TSPACE3' started at Sun Jun 29 08:13:19 2014
xttpreparesrc.sql for  ended at Sun Jun 29 08:13:20 2014


This step created the following files in the current (TMPDIR) directory:

1. xttplan.txt - containing the tablespace names, their current SCNs and their datafile numbers:


[sparc]/export/home/oracle/xtt> cat xttplan.txt
TSPACE1::::98877929
7
TSPACE2::::98877960
8
9
TSPACE3::::98878019
10
11
12


Those SCNs will be used in phase 3 (incrementally updated backups).

2. xttnewdatafiles.txt - containing the tablespace names, datafile numbers, the destination directory object name and the source filenames:

[sparc]/export/home/oracle/xtt> cat xttnewdatafiles.txt
::TSPACE1
7,DESTDIR:/tspace1.263.851501029
::TSPACE2
8,DESTDIR:/tspace2.262.851501039
9,DESTDIR:/tspace2.260.851501057
::TSPACE3
10,DESTDIR:/tspace3.261.851501069
11,DESTDIR:/tspace3.259.851501077
12,DESTDIR:/tspace3.258.851501083


3. getfile.sql - The PL/SQL script (formatting ours) that will be used at the destination to get the datafiles from the source:

[sparc]/export/home/oracle/xtt> cat getfile.sql

BEGIN
  DBMS_FILE_TRANSFER.GET_FILE(
    source_directory_object      => 'SOURCEDIR',
    source_file_name             => 'tspace1.263.851501029',
    source_database              => 'SPARCLINK',
    destination_directory_object => 'DESTDIR',
    destination_file_name        => 'tspace1_263_851501029');
END;
/

BEGIN
  DBMS_FILE_TRANSFER.GET_FILE(
    source_directory_object      => 'SOURCEDIR',
    source_file_name             => 'tspace2.262.851501039',
    source_database              => 'SPARCLINK',
    destination_directory_object => 'DESTDIR',
    destination_file_name        => 'tspace2_262_851501039');
END;
/

BEGIN
  DBMS_FILE_TRANSFER.GET_FILE(
    source_directory_object      => 'SOURCEDIR',
    source_file_name             => 'tspace2.260.851501057',
    source_database              => 'SPARCLINK',
    destination_directory_object => 'DESTDIR',
    destination_file_name        => 'tspace2_260_851501057');
END;
/

BEGIN
  DBMS_FILE_TRANSFER.GET_FILE(
    source_directory_object      => 'SOURCEDIR',
    source_file_name             => 'tspace3.261.851501069',
    source_database              => 'SPARCLINK',
    destination_directory_object => 'DESTDIR',
    destination_file_name        => 'tspace3_261_851501069');
END;
/

BEGIN
  DBMS_FILE_TRANSFER.GET_FILE(
    source_directory_object      => 'SOURCEDIR',
    source_file_name             => 'tspace3.259.851501077',
    source_database              => 'SPARCLINK',
    destination_directory_object => 'DESTDIR',
    destination_file_name        => 'tspace3_259_851501077');
END;
/

BEGIN
  DBMS_FILE_TRANSFER.GET_FILE(
    source_directory_object      => 'SOURCEDIR',
    source_file_name             => 'tspace3.258.851501083',
    source_database              => 'SPARCLINK',
    destination_directory_object => 'DESTDIR',
    destination_file_name        => 'tspace3_258_851501083');
END;
/

quit


Note the destination filenames (destination_file_name) with the underscore replacing the dot. Those will be the ASM aliases for the datafiles in the destination database.

4. xttpreparesrc.sql - the PL/SQL script used to create the files in this step.

5. xttprepare.cmd - the command script (empty at this step).

2.2. Transfer the datafiles to the destination

On the destination server, log in as the oracle user and set the environment to the destination database.

[oracle@exadata ~]$ env | egrep "ORACLE_SID|ORACLE_HOME"
ORACLE_SID=EXADB2
ORACLE_HOME=/u01/app/oracle/product/11.2.0.4/dbhome_1
[oracle@exadata ~]$ export TMPDIR=/home/oracle/xtt
[oracle@exadata ~]$ cd $TMPDIR


Copy the xttnewdatafiles.txt and getfile.sql files from the source server:

[oracle@exadata xtt]$ scp oracle@sparc.us.oracle.com:/export/home/oracle/xtt/xttnewdatafiles.txt .
Password:
xttnewdatafiles.txt                             100%   43     0.0KB/s   00:00

[oracle@exadata xtt]$ scp oracle@sparc.us.oracle.com:/export/home/oracle/xtt/getfile.sql .
Password:
getfile.sql                                     100%  477     0.5KB/s   00:00


Transfer the datafiles, by running 'xttdriver.pl -G'.

[oracle@exadata xtt]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -G
[oracle@exadata xtt]$


Note that this step does not produce any output. This step is going to take the bulk of the database migration time, as we are transferring all datafiles from the source to the destination.

When this step is complete, the datafiles being transported will reside in the final location where they will be used by the destination database. We can verify this with the asmcmd command:

[oracle@exadata xtt]$ asmcmd --privilege sysdba ls -l +DATA_EXA/EXADB/DATAFILE/tspace*
Type      Redund  Striped  Time             Sys  Name
                                            N    tspace1_263_851501029 => +DATA_EXA/EXADB/DATAFILE/FILE_TRANSFER.665.851538271
                                            N    tspace2_260_851501057 => +DATA_EXA/EXADB/DATAFILE/FILE_TRANSFER.663.851538285
                                            N    tspace2_262_851501039 => +DATA_EXA/EXADB/DATAFILE/FILE_TRANSFER.664.851538279
                                            N    tspace3_258_851501083 => +DATA_EXA/EXADB/DATAFILE/FILE_TRANSFER.660.851538319
                                            N    tspace3_259_851501077 => +DATA_EXA/EXADB/DATAFILE/FILE_TRANSFER.661.851538305
                                            N    tspace3_261_851501069 => +DATA_EXA/EXADB/DATAFILE/FILE_TRANSFER.662.851538297


Note the ASM alias names for the transported datafiles and the actual filenames (FILE_TRANSFER.nnn.kkkkkkkkk).

3. Incrementally updated backups (phase 3)

An incrementally updated backup is an RMAN datafile copy that is updated by an incremental backup. In this case, we will be using the datafile copies created with the DBMS_FILE_TRANSFER.GET_FILE, instead of RMAN BACKUP AS COPY. During this phase the incremental backups are created at the source database, transferred to the destination system and merged with the datafiles transferred in phase 2.

The steps in this phase may be run multiple times, to get the datafiles in the destination closer to the time/SCN of the datafiles on the source. The data being transported is fully accessible in the source database during this phase.

3.1. Create incremental backups of the source datafiles

On the source system, logged in as the oracle user, with the environment set to the source database, and the TMPDIR set, run the 'xttdriver.pl -i':

[sparc]/export/home/oracle/xtt> $ORACLE_HOME/perl/bin/perl xttdriver.pl -i
Prepare newscn for Tablespaces: 'TSPACE1'
Prepare newscn for Tablespaces: 'TSPACE2'
Prepare newscn for Tablespaces: 'TSPACE3'

rman target /  cmdfile /export/home/oracle/xtt/rmanincr.cmd

Recovery Manager: Release 10.2.0.4.0 - Production on Sun Jun 29 08:28:40 2014

Copyright (c) 1982, 2007, Oracle.  All rights reserved.

connected to target database: SPARCDB (DBID=261349099)

RMAN> set nocfau;
2> host 'echo ts::TSPACE1';
3> backup incremental from scn 98877929
4>   tag tts_incr_update tablespace 'TSPACE1' format
5>  '/export/home/oracle/stage_source/%U';
6> set nocfau;
7> host 'echo ts::TSPACE2';
8> backup incremental from scn 98877960
9>   tag tts_incr_update tablespace 'TSPACE2' format
10>  '/export/home/oracle/stage_source/%U';
11> set nocfau;
12> host 'echo ts::TSPACE3';
13> backup incremental from scn 98878019
14>   tag tts_incr_update tablespace 'TSPACE3' format
15>  '/export/home/oracle/stage_source/%U';
16>
executing command: SET NOCFAU
using target database control file instead of recovery catalog

ts::TSPACE1
host command complete

Starting backup at 29-JUN-14
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=141 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00007 name=+DATA/brsparc/datafile/tspace1.263.851501029
channel ORA_DISK_1: starting piece 1 at 29-JUN-14
channel ORA_DISK_1: finished piece 1 at 29-JUN-14
piece handle=/export/home/oracle/stage_source/0epc1pds_1_1 tag=TTS_INCR_UPDATE comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 29-JUN-14

executing command: SET NOCFAU

ts::TSPACE2
host command complete

Starting backup at 29-JUN-14
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00008 name=+DATA/brsparc/datafile/tspace2.262.851501039
input datafile fno=00009 name=+DATA/brsparc/datafile/tspace2.260.851501057
channel ORA_DISK_1: starting piece 1 at 29-JUN-14
channel ORA_DISK_1: finished piece 1 at 29-JUN-14
piece handle=/export/home/oracle/stage_source/0fpc1pdu_1_1 tag=TTS_INCR_UPDATE comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 29-JUN-14

executing command: SET NOCFAU

ts::TSPACE3
host command complete

Starting backup at 29-JUN-14
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00010 name=+DATA/brsparc/datafile/tspace3.261.851501069
input datafile fno=00011 name=+DATA/brsparc/datafile/tspace3.259.851501077
input datafile fno=00012 name=+DATA/brsparc/datafile/tspace3.258.851501083
channel ORA_DISK_1: starting piece 1 at 29-JUN-14
channel ORA_DISK_1: finished piece 1 at 29-JUN-14
piece handle=/export/home/oracle/stage_source/0gpc1pe0_1_1 tag=TTS_INCR_UPDATE comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 29-JUN-14

Recovery Manager complete.


This step created the following files in the current (TMPDIR) directory:

1. tsbkupmap.txt - containing the tablespace names, datafile numbers and the incremental backup pieces:

[sparc]/export/home/oracle/xtt> cat tsbkupmap.txt
TSPACE1::7=0epc1pds_1_1
TSPACE3::10,11,12=0gpc1pe0_1_1
TSPACE2::8,9=0fpc1pdu_1_1


2. incrbackups.txt - containing the actual location of the incremental backup pieces:

[sparc]/export/home/oracle/xtt> cat incrbackups.txt
/export/home/oracle/stage_source/0epc1pds_1_1
/export/home/oracle/stage_source/0gpc1pe0_1_1
/export/home/oracle/stage_source/0fpc1pdu_1_1


3. rmanincr.cmd - containing the RMAN scripts used to create the incremental backups.

4. xttdetnewfromscnsrc.sql - the PL/SQL script used to create the files in this step

5. xttplan.txt.new- after the first run of 'xttdriver.pl -i' this is just a copy of the xttplan.txt

3.2. Transfer incremental backups to destination

Transfer the incremental backups to the stageondest location on the destination system.

[sparc]/export/home/oracle/xtt> grep ^stageondest xtt.properties
stageondest=/home/oracle/stage_dest

[sparc]/export/home/oracle/xtt> scp `cat incrbackups.txt` oracle@exadata:/home/oracle/stage_dest
oracle@exadata's password:
0epc1pds_1_1                                100%   96KB  96.0KB/s   00:00
0gpc1pe0_1_1                                100%  224KB 224.0KB/s   00:00
0fpc1pdu_1_1                                100%  160KB 160.0KB/s   00:00

3.3. Apply incremental backups on destination

On the destination server, log in as the oracle user and set the environment to the destination database. Copy the xttplan.txt and tsbkupmap.txt files from the source system

[oracle@exadata ~]$ cd $TMPDIR
[oracle@exadata xtt]$ scp oracle@sparc.us.oracle.com:/export/home/oracle/xtt/xttplan.txt .
Password:
xttplan.txt                                 100%   75     0.1KB/s   00:00

[oracle@exadata xtt]$ scp oracle@sparc.us.oracle.com:/export/home/oracle/xtt/tsbkupmap.txt .
Password:
tsbkupmap.txt                               100%   81     0.1KB/s   00:00


Merge the incremental backups with the datafiles, by running 'xttdriver.pl -r':

[oracle@exadata xtt]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -r
Start rollforward
CONVERTED BACKUP PIECE+RECO_EXA/xtts_incr_backup_1404031692_1675_805

PL/SQL procedure successfully completed.

Entering RollForward
After applySetDataFile
Done: applyDataFileTo
Done: RestoreSetPiece
Done: RestoreBackupPiece

PL/SQL procedure successfully completed.

asmcmd rm +RECO_EXA/xtts_incr_backup_1404031692_1675_805  /u01/app/11.2.0.4/grid .. +ASM2
Can't locate strict.pm in @INC (@INC contains: /u01/app/11.2.0.4/grid/perl/lib/5.10.0/x86_64-linux-thread-multi /u01/app/11.2.0.4/grid/perl/lib/5.10.0 /u01/app/11.2.0.4/grid/perl/lib/site_perl/5.10.0/x86_64-linux-thread-multi
...
BEGIN failed--compilation aborted at /u01/app/11.2.0.4/grid/bin/asmcmdcore line 143.
ASMCMD:
CONVERTED BACKUP PIECE+RECO_EXA/xtts_incr_backup_1404031693_1675_871

PL/SQL procedure successfully completed.

Entering RollForward
After applySetDataFile
Done: applyDataFileTo
Done: RestoreSetPiece
Done: RestoreBackupPiece

PL/SQL procedure successfully completed.
...

End of rollforward phase


It is safe to ignore the "Can't locate strict.pm in @INC..." messages. We believe those are the result of the Perl pragma 'use strict' in the asmcmdcore.

At this step, the incremental backups were put in the backup destination and merged with the datafile copies.

Verify that the incremental backups are in the correct location:

[oracle@exadata xtt]$ grep ^backupondest xtt.properties
backupondest=+RECO_EXA

[oracle@exadata xtt]$ date
Sun Jun 29 18:52:11 EST 2014

[oracle@exadata xtt]$ asmcmd --privilege sysdba ls -ls +RECO_EXA/EXADB/BACKUPSET/2014_06_29
Type       Redund  Striped  Time             Sys  Block_Size  Blocks   Bytes     Space  Name
BACKUPSET  HIGH    COARSE   JUN 29 18:00:00  Y          8192      20  163840  12582912  nnndn0_0.1868.851539693
BACKUPSET  HIGH    COARSE   JUN 29 18:00:00  Y          8192      28  229376  12582912  nnndn0_0.1870.851539693
BACKUPSET  HIGH    COARSE   JUN 29 18:00:00  Y          8192      12   98304  12582912  nnndn0_0.1873.851539693

3.4. Determine the FROM SCN for next incremental backup

On the source system, logged in as the oracle user, with the environment set to the source database, and the TMPDIR set, run the 'xttdriver.pl -s':

[sparc]/export/home/oracle/xtt> $ORACLE_HOME/perl/bin/perl xttdriver.pl -s
Prepare newscn for Tablespaces: 'TSPACE1'
Prepare newscn for Tablespaces: 'TSPACE2'
Prepare newscn for Tablespaces: 'TSPACE3'

New /export/home/oracle/xtt/xttplan.txt with FROM SCN's generated


At this step the xttplan.txt file is copied to xttplan.txt. The 'FROM SCN' will be recorded in the xttplan.txt, next time the 'xttdriver.pl -i' is run (if required).

As noted earlier, the steps in phase 3 can be run as many times as required. For each additional run, we would run 'xttdriver.pl -i', copy the incremental backup, xttplan.txt and tsbkupmap.txt from the source to the destination, run 'xttdriver.pl -r' on the destination, and finally run 'xttdriver.pl -s' on the source.

In this example, I am not repeating steps in phase 3, and instead moving to phase 4.

4. Plug in transported tablespaces (phase 4)

During this phase the source datafiles are put in READ ONLY mode, and the destination datafiles are made consistent with the source by creating and merging the final incremental backups. Finally, the transportable tablespace metadata is imported into the destination database. The data being transported is accessible in READ ONLY mode until the end of this phase.

4.1. Make source tablespaces READ ONLY

On the source system, logged in as the oracle user, with the environment set to the source database, put the three tablespaces in READ ONLY mode:

[sparc]/export/home/oracle/xtt> sqlplus / as sysdba

SQL> alter tablespace TSPACE1 read only;

Tablespace altered.

SQL> alter tablespace TSPACE2 read only;

Tablespace altered.

SQL> alter tablespace TSPACE3 read only;

Tablespace altered.

SQL> exit

4.2. Final incremental backup

Create the final incremental backup by running 'xttdriver.pl -i':

[sparc]/export/home/oracle/xtt> $ORACLE_HOME/perl/bin/perl xttdriver.pl -i
Prepare newscn for Tablespaces: 'TSPACE1'
Prepare newscn for Tablespaces: 'TSPACE2'
Prepare newscn for Tablespaces: 'TSPACE3'

rman target /  cmdfile /export/home/oracle/xtt/rmanincr.cmd

Recovery Manager: Release 10.2.0.4.0 - Production on Sun Jun 29 09:31:54 2014
...

Recovery Manager complete.


Copy the incremental backups, the xttplan.txt and the tsbkupmap.txt to the destination server:

[sparc]/export/home/oracle/xtt> scp `cat incrbackups.txt` oracle@exadata:/home/oracle/stage_dest
oracle@exadata's password:
0ipc1t4g_1_1                               100%  160KB 160.0KB/s   00:00
0hpc1t4e_1_1                               100%   96KB  96.0KB/s   00:00
0jpc1t4i_1_1                               100%  224KB 224.0KB/s   00:00

[oracle@exadata xtt]$ scp oracle@sparc.us.oracle.com:/export/home/oracle/xtt/xttplan.txt .
Password:
xttplan.txt                                      100%   84     0.1KB/s   00:00

[oracle@exadata xtt]$ scp oracle@sparc.us.oracle.com:/export/home/oracle/xtt/tsbkupmap.txt .
Password:
tsbkupmap.txt                                    100%   81     0.1KB/s   00:00

4.3. Final incremental backup merge

Perform the final incremental backup merge by running 'xttdriver.pl -r':

[oracle@exadata xtt]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -r
Start rollforward
CONVERTED BACKUP PIECE+RECO_EXA/xtts_incr_backup_1404034698_11647_93

PL/SQL procedure successfully completed.

Entering RollForward
...

End of rollforward phase

4.4. Import the transported tablespaces metadata

Generate the data pump import script by running 'xttdriver.pl -e':

[oracle@exadata xtt]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -e

This step created the xttplugin.txt file with the following contents:

[oracle@exadata xtt]$ cat xttplugin.txt
impdp directory= logfile= \
network_link= transport_full_check=no \
transport_tablespaces=TSPACE1,TSPACE2,TSPACE3 \
transport_datafiles='+DATA_EXA/EXADB/datafile/tspace1_263_851501029','+DATA_EXA/EXADB/datafile/tspace2_262_851501039','+DATA_EXA/EXADB/datafile/tspace2_260_851501057','+DATA_EXA/EXADB/datafile/tspace3_261_851501069','+DATA_EXA/EXADB/datafile/tspace3_259_851501077','+DATA_EXA/EXADB/datafile/tspace3_258_851501083';


Edit xttplugin.txt to specify the correct values for , and . In my case the final impdp command is:

impdp directory=XTT_DIR logfile=xtt_imp.log \
network_link=SPARCLINK transport_full_check=no \
transport_tablespaces=TSPACE1,TSPACE2,TSPACE3 \
transport_datafiles='+DATA_EXA/EXADB/datafile/tspace1_263_851501029','+DATA_EXA/EXADB/datafile/tspace2_262_851501039','+DATA_EXA/EXADB/datafile/tspace2_260_851501057','+DATA_EXA/EXADB/datafile/tspace3_261_851501069','+DATA_EXA/EXADB/datafile/tspace3_259_851501077','+DATA_EXA/EXADB/datafile/tspace3_258_851501083';


Where XTT_DIR is /home/oracle/xtt and the SPARCLINK is the database link created in phase 1.

Import the transported tablespaces metadata into the destination database by running the data pump import:

[oracle@exadata xtt]$ impdp directory=XTT_DIR logfile=xtt_imp.log \
> network_link=SPARCLINK transport_full_check=no \
> transport_tablespaces=TSPACE1,TSPACE2,TSPACE3 \
> transport_datafiles='+DATA_EXA/EXADB/datafile/tspace1_263_851501029','+DATA_EXA/EXADB/datafile/tspace2_262_851501039','+DATA_EXA/EXADB/datafile/tspace2_260_851501057','+DATA_EXA/EXADB/datafile/tspace3_261_851501069','+DATA_EXA/EXADB/datafile/tspace3_259_851501077','+DATA_EXA/EXADB/datafile/tspace3_258_851501083';

Import: Release 11.2.0.4.0 - Production on Sun Jun 29 19:48:59 2014
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
Username: system
Password:

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management and Real Application Testing options
Starting "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_01":  system/******** directory=XTT_DIR logfile=xtt_imp.log network_link=SPARCLINK transport_full_check=no transport_tablespaces=TSPACE1,TSPACE2,TSPACE3 transport_datafiles=+DATA_EXA/EXADB/datafile/tspace1_263_851501029,+DATA_EXA/EXADB/datafile/tspace2_262_851501039,+DATA_EXA/EXADB/datafile/tspace2_260_851501057,+DATA_EXA/EXADB/datafile/tspace3_261_851501069,+DATA_EXA/EXADB/datafile/tspace3_259_851501077,+DATA_EXA/EXADB/datafile/tspace3_258_851501083
Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK
Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK
Job "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_01" successfully completed at Sun Jun 29 19:51:21 2014 elapsed 0 00:01:55

 

NOTE: Due to a bug (Doc ID 4511371.8) in database version 10.2.0.1, the impdp cannot be performed via the network link. Instead we would need to export the metadata on the source, transfer the export dump and import the metadata on the destination. This only affects the source database version 10.2.0.1.

4.5. Validate plugged in tablespaces at destination

At this stage you may want to check if all tablespaces have been migrated, and if all data is present in the destination database. I have simply put the tablespaces into READ WRITE mode and queried their datafiles:

SQL> alter tablespace TSPACE1 read write;

Tablespace altered.

SQL> alter tablespace TSPACE2 read write;

Tablespace altered.

SQL> alter tablespace TSPACE3 read write;

Tablespace altered.

SQL> select t.name "Tablespace", f.file# "File#", f.name "Filename", f.status "Status"
from v$datafile f, v$tablespace t
where f.ts#=t.ts# and t.name like 'TSPACE%'
order by 1, 2;

Tablespace   File# Filename                                         Status
----------- ------ ------------------------------------------------ -------
TSPACE1         13 +DATA_EXA/exadb/datafile/tspace1_263_851501029  ONLINE
TSPACE2         11 +DATA_EXA/exadb/datafile/tspace2_260_851501057  ONLINE
TSPACE2         12 +DATA_EXA/exadb/datafile/tspace2_262_851501039  ONLINE
TSPACE3          8 +DATA_EXA/exadb/datafile/tspace3_258_851501083  ONLINE
TSPACE3          9 +DATA_EXA/exadb/datafile/tspace3_259_851501077  ONLINE
TSPACE3         10 +DATA_EXA/exadb/datafile/tspace3_261_851501069  ONLINE

6 rows selected.

SQL> exit

Conclusion

One way to migrate a database to Exadata is by performing a cross platform transportable tablespaces migration. This document shows an example of such migration from a single instance database version 10.2.0.4 on Solaris SPARC, to a two node RAC database version 11.2.0.4 on Exadata (Linux x86 64-bit).


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/21754115/viewspace-1733357/,如需轉載,請註明出處,否則將追究法律責任。

相關文章