Вы находитесь на странице: 1из 25

Межплатформенная

миграция на Linux x86_64


Василий Цикра
ФОРС

www.fors.ru
О себе
Василий Цикра
Инженер Oracle Support
Oracle Certified Master 11g
Oracle Certified Master 12c
support@fors.ru
+7 495 7877040

www.fors.ru
Причины для миграции

• Стоимость OS Support

• Стоимость комплектующих

• Расходы на персонал, обслуживающий


программно-аппаратные комплексы

• Политика Oracle Database Patching

www.fors.ru
Сложности

• Ограниченное время выделенное на


выполнение миграции. Downtime

• Целостность данных и метаданных

• Производительность

www.fors.ru
Способы XPlatform-миграции

• Full Database DataPump

• Streams

• GoldenGate

• Standby (Logical, Physical)

• Crossplatform Transportable Tablespace

• Crossplatform Incremental Backup

www.fors.ru
План миграции - 1

• Patch analysis в разрезе XTTS, Incremental Backup, OS


specific patches

• Анализ существующих one-off patches, PSU, Bundle


Patches и т.д.

• При необходимости заказ соответствующих на Linux


x86_64

• Подготовка результирующего Opatch lsinventory

www.fors.ru
План миграции - 2

Создание
копии prod
базы данных

Цель:
Выполнение
Нагрузочное отладка полного
тестирование алгоритма цикла
миграции
миграции

Функциональное
тестирование

www.fors.ru
Source Database

Metadata Data Pump Export EXPDP TTS


(grants, PLSQL, ACL,SQL
Plan BaseLines, Patches
etc)

Rman datafile endian converstion

Metadata Data Pump Import IMPDP TTS Plugin

X86_64 Destination database


SYSTEM, SYSAUX, UNDO, DRSYS etc

www.fors.ru
План миграции - 3

• Установка Linux x86_64

• Подготовка OS

• Подготовка destination database на x86_64

• DataPump export – PLSQL, grants и других metadata

• Подготовка скриптов для переноса: Users, grants, audit records, CBO


statistics, scheduler tasks, jobs, ACL, SQL Plan Baselines/ profiles и тд

Продуктивная база работает в этот период

www.fors.ru
План миграции - 3

• Останов бизнес логики

• Перевод пользовательских tablespace в режим read only

• TTS DataPump Export для всех пользовательских tablespace

• Convert to/from platform всех datafiles

• TTS DataPump Import всех tablespace

• DataPump Import – grants, plsql


• : Users, grants, audit records, CBO statistics, scheduler tasks, jobs, ACL,
SQL Plan Baselines/ profiles

Продуктивная база не работает в этот период

www.fors.ru
Модификация Плана

Цель: уменьшение downtime

www.fors.ru
Миграция RO tablespaces

• Self consistent tablespaces

• Create table CDR (…) partition p1 tablespace year2012,


partition p2 tablespace year2013..

• Alter table CDR exchange partition year2012 with CDRY2012

• Логика приложения не требует «старых» данных

• Сложности с global indexes, non-partitioned indexes,


primary/unique keys

www.fors.ru
ALTER TABLE CDR EXCHANGE PARTITION
year2012 WITH TABLE cdr2012 INCLUDING
INDEXES WITHOUT VALIDATION;

CDR Standalone
partition Table
Local Index
year2012 CDRY2012 Index

Leaf2 Leaf1
Leaf2 Leaf1

RO Tablespace Year2012

www.fors.ru
Global or non-partitioned Indexes

Строки Table Partition Jan2012 соответствуют разным partition P1,P2,P3


of Global partitioned index

Stock Holds Line Items

GLOBAL INDEX PARTITIONS

www.fors.ru
Концепция Crossplatform
Incremental backup
Backup for transport Tablespace
Level 0

Source

Backup for transport Tablespace


Level 1 incremental backup
->RO

Endian conversion
X86_64 of backups
Restore foreign tablespace

www.fors.ru
Реализация в 12.1.0.2

www.fors.ru
RMAN>BACKUP
FOR TRANSPORT
ALLOW INCONSISTENT
INCREMENTAL LEVEL 0
TABLESPACE CDR_YEAR2016
FORMAT '/home/oracle/billing/cdr_year2016_t0.bck';

Starting backup at 03/17/2016 05:36:26


using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=18 device type=DISK
…..
channel ORA_DISK_4: SID=263 device type=DISK
allocated channel: ORA_DISK_5
channel ORA_DISK_5: SID=28 device type=DISK
channel ORA_DISK_1: starting incremental level 0 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00011 name=+DATA/BILLING/DATAFILE/tbs_cdr_year2016.301.82012313239
channel ORA_DISK_1: starting piece 1 at 03/17/2016 05:36:29
channel ORA_DISK_1: finished piece 1 at 03/17/2016 05:36:30
piece handle=/home/oracle/billing/cdr_year2016_t0.bck t03ag=TAG20160315T063629 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 03/17/2016 05:36:30

www.fors.ru
RMAN>BACKUP
FOR TRANSPORT
ALLOW INCONSISTENT
INCREMENTAL LEVEL 1
TABLESPACE CDR_YEAR2016
FORMAT '/home/oracle/billing/cdr_year2016_lvl1.bck’;

Starting backup at 03/15/2016 06:36:26


using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=18 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=271 device type=DISK
allocated channel: ORA_DISK_3
channel ORA_DISK_3: SID=29 device type=DISK
allocated channel: ORA_DISK_4
channel ORA_DISK_4: SID=263 device type=DISK
allocated channel: ORA_DISK_5
channel ORA_DISK_5: SID=28 device type=DISK
channel ORA_DISK_1: starting incremental level 1 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00011 name=+DATA/BILLING/DATAFILE/tbs_cdr_year2016.301.82012313239
channel ORA_DISK_1: starting piece 1 at 03/15/2016 06:36:29
channel ORA_DISK_1: finished piece 1 at 03/15/2016 06:36:30
piece handle=/home/oracle/billing/cdr_year2016_lvl1.bck tag=TAG20160315T063629 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 03/17/2016 06:36:30

www.fors.ru
RMAN> RESTORE
2> FROM PLATFORM 'HP-UX (64-bit)'
3> FOREIGN DATAFILE 11
4> FORMAT '+DATA'
5> FROM BACKUPSET '/home/oracle/billing/cdr_year2016_t0.bck';
Starting restore at 18‐MAR‐16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=364 device type=DISK
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring foreign file 00011
channel ORA_DISK_1: reading from backup piece /home/oracle/billing/cdr_year2016_t0.bck
channel ORA_DISK_1: restoring foreign file 11 to +DATA/BILLING/DATAFILE/tbs_cdr_year2016.301.82012313239
channel ORA_DISK_1: foreign piece handle=/home/oracle/billing/cdr_year2016_t0.bck
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:04
Finished restore at 18‐MAR‐16
RMAN>

www.fors.ru
 RMAN> RECOVER
 2> FROM PLATFORM 'HP-UX (64-bit)'
 3> FOREIGN DATAFILECOPY
'+DATA/BILLING/DATAFILE/tbs_cdr_year2016.301.82012313239'
 4> FROM BACKUPSET '/home/oracle/billing/cdr_year2016_lvl1.bck';
 Starting restore at 18‐MAR‐16
 using channel ORA_DISK_1
 channel ORA_DISK_1: starting datafile backup set restore
 channel ORA_DISK_1: specifying datafile(s) to restore from backup set
 channel ORA_DISK_1: restoring foreign file
+DATA/BILLING/DATAFILE/tbs_cdr_year2016.301.82012313239
 channel ORA_DISK_1: reading from backup piece
/home/oracle/billing/cdr_year2016_lvl1.bck
 channel ORA_DISK_1: foreign piece
handle=/home/oracle/billing/cdr_year2016_lvl1.bck
 channel ORA_DISK_1: restored backup piece 1
 channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
 Finished restore at 18‐MAR‐16
 RMAN>

www.fors.ru
 SQL>alter tablespace CDR_YEAR2016 read only;
RMAN>BACKUP
 FOR TRANSPORT
 INCREMENTAL LEVEL 1
 TABLESPACE CDR_YEAR2016
 FORMAT '/home/oracle/billing/cdr_year2016_final.bck'
 DATAPUMP FORMAT '/home/oracle/billing/cdr_year2016.dmp.bcp'
 DESTINATION 'home/oracle/billing';
 Starting backup at 03/15/2016 06:41:23
 using target database control file instead of recovery catalog
 allocated channel: ORA_DISK_1
 ….
 Running TRANSPORT_SET_CHECK on specified tablespaces
 TRANSPORT_SET_CHECK completed successfully
 Performing export of metadata for specified tablespaces...
 EXPDP>
 WARNING: Oracle Data Pump operations are not typically needed when connected to the root or
 EXPDP> Starting "SYSBACKUP"."TRANSPORT_EXP_BILLING_trw":
 EXPDP> Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK
 ….
 EXPDP> Processing object type TRANSPORTABLE_EXPORT/STATISTICS/MARKER
 EXPDP> Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK
 EXPDP> Master table "SYSBACKUP"."TRANSPORT_EXP_BILLING_trw" successfully loaded/unloaded
 EXPDP> ******************************************************************************
 EXPDP> Dump file set for SYSBACKUP.TRANSPORT_EXP_ORAWISS_urkc is:
 EXPDP> /home/oracle/billing/cdr_year2016.dmp
 channel ORA_DISK_1: starting incremental level 1 datafile backup set
 channel ORA_DISK_1: specifying datafile(s) in backup set
 input datafile file number=00011 name=+DATA/BILLING/DATAFILE/tbs_cdr_year2016.301.82012313239
 channel ORA_DISK_1: starting piece 1 at 03/15/2016 06:42:33
 channel ORA_DISK_1: finished piece 1 at 03/15/2016 06:42:34
 piece handle=/home/oracle/billing/cdr_year2016_final.bck tag=TAG20160315T064125 comment=NONE
 channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
 channel ORA_DISK_1: starting incremental level 1 datafile backup set
 …………
 channel ORA_DISK_1: finished piece 1 at 03/15/2016 06:42:35
 piece handle=/home/oracle/billing/cdr_year2016.dmp.bcp tag=TAG20160315T064125 comment=NONE
 channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
 Finished backup at 03/15/2016 06:42:35
www.fors.ru
RMAN> RESTORE
FOREIGN TABLESPACE CDR_YEAR2016
FROM BACKUPSET '/home/oracle/billing/cdr_year2016_final.bck’
DUMP FILE FROM BACKUPSET '/home/oracle/billing/cdr_year2016.dmp.bcp';
The command results in the following output:
Starting restore at 12MAR16
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring all files in foreign tablespace CDR_YEAR2016
channel ORA_DISK_1: reading from backup piece /home/oracle/billing/cdr_year2016_final.bck
channel ORA_DISK_1: restoring foreign file 2 to +DATA/BILLING/DATAFILE/tbs_cdr_year2016.301.82012313239
channel ORA_DISK_1: foreign piece handle=+DATA/BILLING/DATAFILE/tbs_cdr_year2016.301.82012313239
channel ORA_DISK_1: restored backup piece 1

channel ORA_DISK_1: restoring Data Pump dump file to /u01/app/oracle/product/c12101/dbs/backup_tts_dest_31167.dmp
channel ORA_DISK_1: reading from backup piece /home/oracle/billing/cdr_year2016.dmp.bcp
channel ORA_DISK_1: foreign piece handle=/home/oracle/billing/cdr_year2016.dmp.bcp
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:02
Performing import of metadata...
IMPDP> Master table "SYSBACKUP"."TSPITR_IMP_dest_jykD" successfully loaded/unloaded
IMPDP> import done in WE8MSWIN1252 character set and AL16UTF16 NCHAR character set
export done in US7ASCII character set and AL16UTF16 NCHAR character set
IMPDP> Starting "SYSBACKUP"."TSPITR_IMP_dest_jykD":
IMPDP> Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK
IMPDP> Processing object type TRANSPORTABLE_EXPORT/TABLE
IMPDP> Processing object type TRANSPORTABLE_EXPORT/TABLE_STATISTICS
IMPDP> Processing object type TRANSPORTABLE_EXPORT/STATISTICS/MARKER
IMPDP> Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK
IMPDP> Job "SYSBACKUP"."TSPITR_IMP_dest_jykD" successfully completed at Fri Mar 18 12:19:08 2016 elapsed

www.fors.ru
Что делать на 11g?

• 11G - Reduce Transportable Tablespace Downtime using Cross


Platform Incremental Backup (Doc ID 1389592.1)

• Phase 1 - Initial Setup phase

• Phase 2 - Prepare phase

• Phase 3 - Roll Forward phase

• Phase 4 - Transport phase


rman-xttconvert_2.0.zip

www.fors.ru
Internals of XTTS incr backups

• RMAN> connect target /

• RMAN> backup incremental from scn <SCN>


tablespace ‘CDR20016'
format '/backup/%U';

www.fors.ru
Internals of XTTS incr backups
 variable devicename varchar2(80);
 execute :devicename := dbms_backup_restore.deviceAllocate;

 declare
 handle varchar2(512) ;
 comment varchar2(80) ;
 media varchar2(80) ;
 concur boolean ;
 recid number ;
 stamp number ;
 BEGIN
 sys.dbms_backup_restore.backupBackupPiece(
 bpname => '/backup/0cmu8seu_1_1',
 fname => ’/backup/xtts_incr_backup',
 handle => handle, media => media, comment => comment,
 concur => concur, recid => recid, stamp => stamp, check_logical => FALSE,
 copyno => 1, deffmt => 0, copy_recid => 0, copy_stamp => 0,
 npieces => 1, dest => 0,
 pltfrmfr => 2);
 EXCEPTION
 WHEN OTHERS
 THEN
 DBMS_OUTPUT.put_line (SQLERRM);
 END ;
 /

www.fors.ru