当前位置:网站首页>Oracle manually performs cross platform transfer of tablespaces (xtts)
Oracle manually performs cross platform transfer of tablespaces (xtts)
2022-04-22 11:33:00 【Ink Sky Wheel】
It's used at work oracle Officially encapsulated tools (rman_xttconvert) Do the migration , In fact, cross platform migration can also be done manually . For complex scenes , The migration can be customized manually .
One 、 Full transfer table space
If the database is in 1T within , Downtime operation , It can be directly used once RMAN Backup , Transfer the data file to the target platform host . You need to make the migrated tablespace read-only .
-- Confirm whether the components are consistent
SET lines 90 NUMWIDTH 12 PAGES 10000 LONG 2000000000ALTER SESSION SET nls_date_format='YYYY-MM-DD HH24:MI:SS';COL version FORMAT a12COL comp_id FORMAT a8COL schema LIKE versionCOL comp_name FORMAT a35COL status FORMAT a12SELECT comp_id,schema,status,version,comp_nameFROM dba_registryORDER BY 1;
-- Determine platform ID
col PLATFORM_NAME for a30col ENDIAN_FORMAT for a30SELECT D.PLATFORM_NAME, ENDIAN_FORMAT,d.platform_idFROM V$TRANSPORTABLE_PLATFORM TP, V$DATABASE DWHERE TP.PLATFORM_NAME = D.PLATFORM_NAME;
-- The production library confirms whether there is a user table in the system table space
User-Owned Tables Residing in the SYSTEM or SYSAUX Tablespacesselect owner, segment_name, segment_typefrom dba_segmentswhere tablespace_name in ('SYSTEM', 'SYSAUX')and owner not in(select namefrom system.logstdby$skip_supportwhere action=0);
-- Original library tablespace self-contained check
declarechecklist varchar2(4000);i number := 0;beginfor ts in(select tablespace_namefrom dba_tablespaceswhere tablespace_name not in ('SYSTEM','SYSAUX','AUDITTBS') and contents = 'PERMANENT')loopif (i=0) thenchecklist := ts.tablespace_name;elsechecklist := checklist||','||ts.tablespace_name;end if;i := 1;end loop;dbms_tts.transport_set_check(checklist,TRUE,TRUE);end;/select * from transport_set_violations;
-- The source library sets the tablespace as read-only
alter tablespace TESTXTT read only;alter tablespace TESTXTTIDX read only;
-- The source library converts the table space to the byte order of the target platform
CONVERT TABLESPACE TESTXTT,TESTXTTIDXTO PLATFORM 'Linux x86 64-bit'FORMAT='/xttsoft/backupdir/%N_%f.dbf' parallelism 3;
-- The target library puts the backed up data files into the corresponding empty directory of the target
mv /xttsoft/backupdir/TESTXTT* $ORACLE_BASE/oradata/tdb/
Import metadata from the target library
impdp userid=\"sys/Passw0rd as sysdba\" directory=exp_dir logfile=tts_imp.log \network_link=from_old transport_full_check=no \transport_tablespaces=TESTXTT,TESTXTTIDX \transport_datafiles='/oracle/app/oracle/oradata/testdb/TESTXTT_5.dbf','/oracle/app/oracle/oradata/testdb/TESTXTTIDX_6.dbf'
Two 、 Incremental cross platform transfer of tablespaces
The applicable database is relatively large , Short downtime , Just shut down at the last increment .
-- Source library turns on block tracking , And make sure to increase the number of incremental backup records . You have to set , Otherwise, the increment time is as long as the full amount time .
select * From v$block_change_tracking;alter system set "_bct_bitmaps_per_file"=100;alter database enable block change tracking using file '/arch/change_tracking.f'select * from v$block_change_tracking;alter system set large_pool_size=2G;
-- Generate full backup and full recovery statements , Source side execution
select RMAN_SCRIPTFrom (select '1' step,tablespace_name,file_id,'backup as copy tag ''prepare'' datafile ' || FILE_ID ||' format ''/xttsoft/backupdir/' || TABLESPACE_NAME || '_' ||file_id || '.enmo''; #scn:' ||dbms_flashback.get_system_change_number rman_scriptfrom dba_data_fileswhere tablespace_name in ('TESTXTT', 'TESTXTTIDX')union allselect '2' step,tablespace_name,file_id,'convert from platform ''Linux x86 64-bit'' datafile ''/xttsoft/backupdir/' ||tablespace_name || '_' || file_id ||'.enmo'' format ''/oracle/app/oracle/oradata/testdb/' ||TABLESPACE_NAME || '_' || file_id || '''; #scn:' ||dbms_flashback.get_system_change_number rman_scriptfrom dba_data_fileswhere tablespace_name in ('TESTXTT', 'TESTXTTIDX'))order by step;
-- Script generated backup , Source side execution
backup as copy tag 'prepare' datafile 5 format '/xttsoft/backupdir/TESTXTT_5.enmo'; #scn:1173499backup as copy tag 'prepare' datafile 6 format '/xttsoft/backupdir/TESTXTTIDX_6.enmo'; #scn:1173499
-- Script generated transformation , Target side execution
convert from platform 'Linux x86 64-bit' datafile '/xttsoft/backupdir/TESTXTT_5.enmo' format '/oracle/app/oracle/oradata/testdb/TESTXTT_5'; #scn:1173499convert from platform 'Linux x86 64-bit' datafile '/xttsoft/backupdir/TESTXTTIDX_6.enmo' format '/oracle/app/oracle/oradata/testdb/TESTXTTIDX_6'; #scn:1173499
-- For the first time
backup as copy tag 'prepare' datafile 5 format '/xttsoft/backupdir/TESTXTT_5.enmo'; #scn:1173499backup as copy tag 'prepare' datafile 6 format '/xttsoft/backupdir/TESTXTTIDX_6.enmo'; #scn:1173499
-- First full recovery
convert from platform 'Linux x86 64-bit' datafile '/xttsoft/backupdir/TESTXTT_5.enmo' format '/oracle/app/oracle/oradata/testdb/TESTXTT_5'; #scn:1173499convert from platform 'Linux x86 64-bit' datafile '/xttsoft/backupdir/TESTXTTIDX_6.enmo' format '/oracle/app/oracle/oradata/testdb/TESTXTTIDX_6'; #scn:1173499
-- Incremental composite stored procedure , Create... On the target side , Subsequent incremental synthesis will use
create or replace procedure rollforward(p_datafile_name varchar2,p_incr_file_name varchar2,p_fnumber number) asouthandle varchar2(512);outtag varchar2(30);done boolean;failover boolean;devtype VARCHAR2(512);BEGINDBMS_OUTPUT.put_line('Entering RollForward');-- Now the rolling forward.devtype := sys.dbms_backup_restore.deviceAllocate;sys.dbms_backup_restore.applySetDatafile(check_logical => FALSE,cleanup => FALSE);DBMS_OUTPUT.put_line('After applySetDataFile');sys.dbms_backup_restore.applyDatafileTo(dfnumber => p_fnumber,toname => p_datafile_name,fuzziness_hint => 0,max_corrupt => 0,islevel0 => 0,recid => 0,stamp => 0);DBMS_OUTPUT.put_line('Done: applyDataFileTo');DBMS_OUTPUT.put_line('Done: applyDataFileTo');-- Restore Set Piecesys.dbms_backup_restore.restoreSetPiece(handle => p_incr_file_name,tag => null,fromdisk => true,recid => 0,stamp => 0);DBMS_OUTPUT.put_line('Done: RestoreSetPiece');-- Restore Backup Piecesys.dbms_backup_restore.restoreBackupPiece(done => done,params => null,outhandle => outhandle,outtag => outtag,failover => failover);DBMS_OUTPUT.put_line('Done: RestoreBackupPiece');sys.dbms_backup_restore.restoreCancel(TRUE);sys.dbms_backup_restore.deviceDeallocate;END;/
-- Incremental backup
select 'backup incremental from scn 1173499 tag tts_incr_update tablespace '''||TABLESPACE_NAME||''' format ''/xttsoft/backupdir/incr_%d_%T_%U''; #scn:'||dbms_flashback.get_system_change_number rman_inc_script from dba_data_files where tablespace_name in ('TESTXTT','TESTXTTIDX') order by tablespace_name,file_name;backup incremental from scn 1173499 tag tts_incr_update tablespace 'TESTXTT' format '/xttsoft/backupdir/incr_%d_%T_%U'; #scn:1173657backup incremental from scn 1173499 tag tts_incr_update tablespace 'TESTXTTIDX' format '/xttsoft/backupdir/incr_%d_%T_%U'; #scn:1173657
-- Incremental synthesis
select 'exec rollforward(''/oracle/app/oracle/oradata/testdb/' ||t3.TABLESPACE_NAME || '_' || file_id || ''',''' || t1.HANDLE ||''',' || t2.FILE# || ')'From v$backup_piece_details t1left join v$backup_datafile t2on (t1.RECID = t2.RECID)left join dba_data_files t3on (t2.FILE# = t3.file_id)where t2.INCREMENTAL_CHANGE# = 1173499and t1.HANDLE not like '/xttsoft/backupdir/incr_TDB_0_%'order by t1.COMPLETION_TIME desc;
-- The target side performs incremental synthesis , Every time you log in sqlplus To perform a , somewhat BUG
exec rollforward('/oracle/app/oracle/oradata/testdb/TESTXTT_5','/xttsoft/backupdir/incr_TDB_20220421_420rgc01_1_1',5)exec rollforward('/oracle/app/oracle/oradata/testdb/TESTXTTIDX_6','/xttsoft/backupdir/incr_TDB_20220421_440rgc06_1_1',6)
-- The source library sets the tablespace as read-only
alter tablespace TESTXTT read only;alter tablespace TESTXTTIDX read only;
--readonly Post incremental backup
select 'backup incremental from scn 1173657 tag tts_incr_update tablespace '''||TABLESPACE_NAME||''' format ''/xttsoft/backupdir/incr_%d_%f_%T_%U''; #scn:'||dbms_flashback.get_system_change_number rman_inc_script from dba_data_files where tablespace_name in ('TESTXTT','TESTXTTIDX') order by tablespace_name,file_name;backup incremental from scn 1173657 tag tts_incr_update tablespace 'TESTXTT' format '/xttsoft/backupdir/incr_%d_%T_%U'; #scn:1174501backup incremental from scn 1173657 tag tts_incr_update tablespace 'TESTXTTIDX' format '/xttsoft/backupdir/incr_%d_%T_%U'; #scn:1174501
--readonly Post incremental synthesis
exec rollforward('/oracle/app/oracle/oradata/testdb/TESTXTT_5','/xttsoft/backupdir/incr_TDB_20220421_423rgc01_1_1',5)exec rollforward('/oracle/app/oracle/oradata/testdb/TESTXTTIDX_6','/xttsoft/backupdir/incr_TDB_20220421_442rgc06_1_1',6)
-- Import metadata
impdp userid=\"sys/Passw0rd as sysdba\" directory=exp_dir logfile=tts_imp.log \network_link=from_old transport_full_check=no \transport_tablespaces=TESTXTT,TESTXTTIDX \transport_datafiles='/oracle/app/oracle/oradata/testdb/TESTXTT_5','/oracle/app/oracle/oradata/testdb/TESTXTTIDX_6'
版权声明
本文为[Ink Sky Wheel]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204221127074162.html
边栏推荐
猜你喜欢

Create object memory analysis and inheritance

Mysql基本操作

Summary of important knowledge points of discrete structure and its application

Convolutional neural network

找国企、央企、上市公司投资人,我选择塔米狗!

看的懂的C语言--字符串、转义字符、注释

Ampere Computing释放观测云“芯”算力,强强联合推动可观测性发展

Why can't people see the truth?

MySQL view database and table creation statements

微信小程序使用VantUI框架(Vant Weapp) yarn安裝
随机推荐
进程池创建多进程下载网页
How to make the tab top by clicking on the tab bar
分支和循环语句例题
正确安装了yarn之后,在vscode中使用yarn安装,报错
MySQL查看建库建表语句
PTC: 工程机械ESG产品研发重大变革
msfvenom --- msf 组件 shell生成工具
Basic knowledge of machine learning
深度迁移学习
Sample questions of 2022 Guangdong Vocational College Students' professional skills competition network security (secondary vocational group)
MySQL 学习笔记
.env.dev不生效问题
MySQL view database and table creation statements
The new Vemma M7 won two international awards, namely "if design award" and "red dot product design award"
【无标题】
人为什么看不到真相?
824. Goat Latin / Sword finger offer II 012 The sum of the left and right subarrays is equal
OpenMLDB Pulsar Connector:高效打通实时数据到特征工程
九、ES6(2)
Basic operation of MySQL