XTTS遷移oracle11g-19c(非容器數據庫)


 

 

 XTTS遷移oracle11g-19c(非容器數據庫)

​一.背景

嘗試把用xtts把oracle 11g單實例數據庫遷移到19c非CDB單實例數據庫中。

二.環境介紹

源端:11g:

操作系統:

[root@11g ~]# cat /etc/redhat-release 

Red Hat Enterprise Linux Server release 6.4 (Santiago)

數據庫版本:11.2.0.4

IP地址:192.168.59.180

目標端:19c:

操作系統:

[root@19c ~]# cat /etc/redhat-release 

CentOS Linux release 7.9.2009 (Core)

數據庫版本:19.3.0.0

IP地址:192.168.59.181

所需軟件:

rman_xttconvert_v3.zip

下載:

鏈接:https://pan.baidu.com/s/1ZRqkPzLVKtnnI_xQtRnADg

提取碼:fhx7

三.遷移

3.1.准備階段

3.1.1.生產庫打開塊跟蹤特性

alter database enable block change tracking using file '/u01/xtts/block_change_tracking.log';

3.1.2.對表空間做自包含檢查

檢查出INDEX存在自包含問題,需要重建或者最后重建。

本次我們遷移的用戶為TEST1和TEST2,涉及的表空間為TEST1和TEST2。

3.1.2.對表空間做自包含檢查

檢查出INDEX存在自包含問題,需要重建或者最后重建。

本次我們遷移的用戶為TEST1和TEST2,涉及的表空間為TEST1和TEST2。

3.1.3.找出臨時表的創建語句

因為XTTS在最后導入元數據的時候不支持臨時表,所以需要提前查出臨時表信息,在導入元數據之后手動執行。

SQL> Select dbms_metadata.get_ddl('TABLE',TABLE_NAME,OWNER) FROM dba_tables where TEMPORARY='Y' and owner='TEST1';
no rows selected
SQL> Select dbms_metadata.get_ddl('TABLE',TABLE_NAME,OWNER) FROM dba_tables where TEMPORARY='Y' and owner='TEST2';
no rows selected

3.2.XTTS遷移初始化階段

3.2.1.上傳rman_xttconvert_v3.zip 到oracle 11g上

解壓之后會有如下文件:

[oracle@11g rman-xttconvert]$ ll
total 172
-rw-r--r-- 1 oracle oinstall   1390 May 24  2017 xttcnvrtbkupdest.sql
-rw-r--r-- 1 oracle oinstall     71 May 24  2017 xttdbopen.sql
-rw-r--r-- 1 oracle oinstall 142020 Sep 20  2018 xttdriver.pl
-rw-r--r-- 1 oracle oinstall  11710 May 24  2017 xttprep.tmpl
-rw-r--r-- 1 oracle oinstall   8028 Dec 17 10:53 xtt.properties
-rw-r--r-- 1 oracle oinstall     52 May 24  2017 xttstartupnomount.sql
[oracle@11g rman-xttconvert]$

3.2.2.源端更改配置文件xtt.properties

更改以下參數:

tablespaces=TEST1,TEST2
platformid=13
dfcopydir=/u01/xtts/bak
backupformat=/u01/xtts/bakincr
stageondest=/u01/xtts/oradata2
storageondest=/u01/xtts/oradata3
parallel=16
rollparallel=8
getfileparallel=8
desttmpdir=/u01/xtts/temp
dumpdir=/u01/xtts/dump
​
附錄解釋:
tablespaces= ----需要遷移的表空間
platformid= ----源 OS 平台 ID     V$DATABASE.PLATFORM_ID
dfcopydir= ----源數據庫備份文件存放目錄
backupformat= ---源數據庫增備文件存放目錄
stageondest= ----目標據庫備份文件存放目錄
storageondest= ----目標據庫正式文件存放目錄
parallel= ----備份,轉化的並行度
rollparallel= ----增備的並行度

3.2.3.創建上述目錄並將rman-xttconvert目錄傳輸至目標端

創建相應目錄:
源端:
mkdir -p /u01/xtts/bak
mkdir -p /u01/xtts/bakincr
mkdir -p /u01/xtts/temp
mkdir -p /u01/xtts/dump
[oracle@11g software]$ scp -r rman-xttconvert/ 192.168.59.181:/home/oracle/
目標端:
mkdir -p /u01/xtts/oradata2
mkdir -p /u01/xtts/oradata3
mkdir -p /u01/xtts/temp
mkdir -p /u01/xtts/dump
mkdir -p /u01/xtts/incr

3.3.初始備份

3.3.1.源端進行初始備份

export TMPDIR=/u01/xtts/temp
$ORACLE_HOME/perl/bin/perl xttdriver.pl -p
[oracle@11g rman-xttconvert]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -p
============================================================
trace file is /u01/xtts/temp/prepare_Feb7_Mon_14_31_25_313//Feb7_Mon_14_31_25_313_.log
=============================================================--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------
​
​
--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------
​
​
--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------
​
​
--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------
​
​
--------------------------------------------------------------------
Starting prepare phase
--------------------------------------------------------------------
Prepare source for Tablespaces:
                  'TEST1'  /u01/xtts/oradata2
xttpreparesrc.sql for 'TEST1' started at Mon Feb  7 14:31:25 2022
xttpreparesrc.sql for  ended at Mon Feb  7 14:31:25 2022
Prepare source for Tablespaces:
                  'TEST2'  /u01/xtts/oradata2
xttpreparesrc.sql for 'TEST2' started at Mon Feb  7 14:31:30 2022
xttpreparesrc.sql for  ended at Mon Feb  7 14:31:30 2022--------------------------------------------------------------------
Done with prepare phase
--------------------------------------------------------------------
​
​
--------------------------------------------------------------------
Find list of datafiles in system
--------------------------------------------------------------------
​
​
--------------------------------------------------------------------
Done finding list of datafiles in system
--------------------------------------------------------------------
[oracle@11g rman-xttconvert]$

3.3.2.傳輸初始備份

/u01/xtts/bak和/u01/xtts/temp目錄下面的文件拷貝到目標環境對應的目錄下
scp -r /u01/xtts/bak/* oracle@192.168.59.181:/u01/xtts/oradata2
scp -r /u01/xtts/temp/* oracle@192.168.59.181:/u01/xtts/temp

3.3.3.目標端依次轉換

--執行轉換之前記錄下傳輸的文件的內容
[oracle@19c xtts]$ cd oradata2
[oracle@19c oradata2]$ ll
total 157392
-rw-r----- 1 oracle oinstall 80748544 Feb  7 14:34 TEST1_7.tf
-rw-r----- 1 oracle oinstall 80420864 Feb  7 14:34 TEST2_8.tf
[oracle@19c oradata2]$ cd ../temp/
[oracle@19c temp]$ ll
total 12
drwxr-xr-x 2 oracle oinstall 268 Feb  7 14:36 prepare_Feb7_Mon_14_31_25_313
-rw-r--r-- 1 oracle oinstall 348 Feb  7 14:36 rmanconvert.cmd
-rw-r--r-- 1 oracle oinstall  82 Feb  7 14:36 xttnewdatafiles.txt
-rw-r--r-- 1 oracle oinstall  40 Feb  7 14:36 xttplan.txt
[oracle@19c temp]$ cat xttnewdatafiles.txt 
::TEST1
7,/u01/xtts/oradata3/TEST1_7.dbf
::TEST2
8,/u01/xtts/oradata3/TEST2_8.dbf
[oracle@19c temp]$ cat xttplan.txt 
TEST1::::13693177
7
TEST2::::13693177
8
[oracle@19c temp]$ 
--開始執行轉換
export TMPDIR=/u01/xtts/temp
$ORACLE_HOME/perl/bin/perl xttdriver.pl -c
​
[oracle@19c rman-xttconvert]$ cd /home/oracle/rman-xttconvert/
[oracle@19c rman-xttconvert]$ export TMPDIR=/u01/xtts/temp
[oracle@19c rman-xttconvert]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -c
============================================================
trace file is /u01/xtts/temp/convert_Feb7_Mon_14_39_32_334//Feb7_Mon_14_39_32_334_.log
=============================================================--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------
​
​
--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------
​
​
--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------
​
​
--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------
​
​
--------------------------------------------------------------------
Performing convert
--------------------------------------------------------------------
​
​
--------------------------------------------------------------------
Converted datafiles listed in: /u01/xtts/temp/xttnewdatafiles.txt
--------------------------------------------------------------------
[oracle@19c rman-xttconvert]$ 
​
--轉換之后我們看看temp文件夾下內容的變化
[oracle@19c xtts]$ cd temp/
[oracle@19c temp]$ ll
total 12
drwxr-xr-x 2 oracle oinstall 174 Feb  7 14:42 convert_Feb7_Mon_14_39_32_334
drwxr-xr-x 2 oracle oinstall 268 Feb  7 14:36 prepare_Feb7_Mon_14_31_25_313
-rw-r--r-- 1 oracle oinstall 348 Feb  7 14:36 rmanconvert.cmd
-rw-r--r-- 1 oracle oinstall  82 Feb  7 14:42 xttnewdatafiles.txt
-rw-r--r-- 1 oracle oinstall  40 Feb  7 14:36 xttplan.txt
[oracle@19c temp]$ cat xttnewdatafiles.txt 
::TEST1
7,/u01/xtts/oradata3/TEST1_7.dbf
::TEST2
8,/u01/xtts/oradata3/TEST2_8.dbf
[oracle@19c temp]$ cat xttplan.txt 
TEST1::::13693177
7
TEST2::::13693177
8
[oracle@19c temp]$

3.4.增量數第一次傳輸

3.4.1.源端增量數據導出

export TMPDIR=/u01/xtts/temp
$ORACLE_HOME/perl/bin/perl xttdriver.pl -i
[oracle@11g rman-xttconvert]$ export TMPDIR=/u01/xtts/temp
[oracle@11g rman-xttconvert]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -i
============================================================
trace file is /u01/xtts/temp/incremental_Feb7_Mon_14_49_22_958//Feb7_Mon_14_49_22_958_.log
=============================================================--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------
​
​
--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------
​
​
--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------
​
​
--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------
​
​
--------------------------------------------------------------------
Backup incremental
--------------------------------------------------------------------
============================================================
No new datafiles added
=============================================================
Prepare newscn for Tablespaces: 'TEST1'
Prepare newscn for Tablespaces: 'TEST2'--------------------------------------------------------------------
Starting incremental backup
--------------------------------------------------------------------
​
​
--------------------------------------------------------------------
Done backing up incrementals
--------------------------------------------------------------------
[oracle@11g rman-xttconvert]$ 
--我們記錄下來新生成的文件
[oracle@11g xtts]$ cd bakincr/
[oracle@11g bakincr]$ ll
total 352
-rw-r----- 1 oracle oinstall 180224 Feb  7 14:49 3k0l8cvj_1_1
-rw-r----- 1 oracle oinstall 180224 Feb  7 14:49 3l0l8cvl_1_1
[oracle@11g bakincr]$ cd ../temp/
[oracle@11g temp]$ ll
total 32
-rw-r--r-- 1 oracle oinstall   62 Feb  7 14:49 incrbackups.txt
drwxr-xr-x 2 oracle oinstall 4096 Feb  7 14:49 incremental_Feb7_Mon_14_49_22_958
drwxr-xr-x 2 oracle oinstall 4096 Feb  7 14:31 prepare_Feb7_Mon_14_31_25_313
-rw-r--r-- 1 oracle oinstall  348 Feb  7 14:31 rmanconvert.cmd
-rw-r--r-- 1 oracle oinstall   52 Feb  7 14:49 tsbkupmap.txt
-rw-r--r-- 1 oracle oinstall   82 Feb  7 14:31 xttnewdatafiles.txt
-rw-r--r-- 1 oracle oinstall   40 Feb  7 14:31 xttplan.txt
-rw-r--r-- 1 oracle oinstall   44 Feb  7 14:49 xttplan.txt.new
[oracle@11g temp]$ 
[oracle@11g temp]$ cat xttnewdatafiles.txt 
::TEST1
7,/u01/xtts/oradata3/TEST1_7.dbf
::TEST2
8,/u01/xtts/oradata3/TEST2_8.dbf
[oracle@11g temp]$ cat xttplan.txt
TEST1::::13693177
7
TEST2::::13693177
8
[oracle@11g temp]$ cat xttplan.txt.new 
 TEST1::::13713305
 7
 TEST2::::13713305
 8
[oracle@11g temp]$
--傳輸增量數據到目標端
cd /u01/xtts/bakincr
scp * oracle@192.168.59.181:/u01/xtts/oradata2
cd /u01/xtts/temp
scp xttplan.txt.new xttnewdatafiles.txt incrbackups.txt rmanconvert.cmd tsbkupmap.txt  oracle@192.168.59.181:/u01/xtts/temp
--此時目標端temp內容如下:
[oracle@19c temp]$ ll
total 24
drwxr-xr-x 2 oracle oinstall 174 Feb  7 14:42 convert_Feb7_Mon_14_39_32_334
-rw-r--r-- 1 oracle oinstall  62 Feb  7 14:53 incrbackups.txt
drwxr-xr-x 2 oracle oinstall 268 Feb  7 14:36 prepare_Feb7_Mon_14_31_25_313
-rw-r--r-- 1 oracle oinstall 348 Feb  7 14:53 rmanconvert.cmd
-rw-r--r-- 1 oracle oinstall  52 Feb  7 14:53 tsbkupmap.txt
-rw-r--r-- 1 oracle oinstall  82 Feb  7 14:53 xttnewdatafiles.txt
-rw-r--r-- 1 oracle oinstall  40 Feb  7 14:36 xttplan.txt
-rw-r--r-- 1 oracle oinstall  44 Feb  7 14:53 xttplan.txt.new
[oracle@19c temp]$

3.4.2.目標端增量數據導入

在目標端重命名xttplan.txt.new 為xttplan.txt,然后進入xtts腳本目錄執行轉換

[oracle@19c temp]$ cat xttplan.txt.new 
 TEST1::::13713305
 7
 TEST2::::13713305
 8
[oracle@19c temp]$ cat xttplan.txt.new 
 TEST1::::13713305
 7
 TEST2::::13713305
 8
[oracle@19c temp]$ mv xttplan.txt.new xttplan.txt
[oracle@19c temp]$ 
​
export TMPDIR=/u01/xtts/temp
$ORACLE_HOME/per/bin/perl xttdriver.pl -r
​
[oracle@19c rman-xttconvert]$ export TMPDIR=/u01/xtts/temp
[oracle@19c rman-xttconvert]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -r
============================================================
trace file is /u01/xtts/temp/rollforward_Feb7_Mon_15_27_53_567//Feb7_Mon_15_27_53_567_.log
=============================================================--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------
​
​
--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------
​
​
--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------
​
​
--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------
​
​
--------------------------------------------------------------------
Start rollforward
--------------------------------------------------------------------
​
​
--------------------------------------------------------------------
End of rollforward phase
--------------------------------------------------------------------
[oracle@19c rman-xttconvert]$

3.4.3.源端更新scn記錄

$ORACLE_HOME/perl/bin/perl xttdriver.pl -s
[oracle@11g rman-xttconvert]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -s
============================================================
trace file is /u01/xtts/temp/determinescn_Feb7_Mon_15_30_57_587//Feb7_Mon_15_30_57_587_.log
=============================================================--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------
​
​
--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------
​
​
--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------
​
​
--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------
Prepare newscn for Tablespaces: 'TEST1'
Prepare newscn for Tablespaces: 'TEST2'
New /u01/xtts/temp/xttplan.txt with FROM SCN's generated
[oracle@11g rman-xttconvert]$

將目標端temp目錄以及源端bakincr目錄進行清理,准備再次進行同步新數據

3.5.增量數據第二次傳輸

3.5.1.源端執行增量備份

export TMPDIR=/u01/xtts/temp
$ORACLE_HOME/perl/bin/perl xttdriver.pl -i
​
[oracle@11g rman-xttconvert]$ export TMPDIR=/u01/xtts/temp
[oracle@11g rman-xttconvert]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -i
============================================================
trace file is /u01/xtts/temp/incremental_Feb7_Mon_15_36_47_595//Feb7_Mon_15_36_47_595_.log
=============================================================--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------
​
​
--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------
​
​
--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------
​
​
--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------
​
​
--------------------------------------------------------------------
Backup incremental
--------------------------------------------------------------------
============================================================
No new datafiles added
=============================================================
Prepare newscn for Tablespaces: 'TEST1'
Prepare newscn for Tablespaces: 'TEST2'--------------------------------------------------------------------
Starting incremental backup
--------------------------------------------------------------------
​
​
--------------------------------------------------------------------
Done backing up incrementals
--------------------------------------------------------------------
[oracle@11g rman-xttconvert]$ 

3.5.2.第二次增量備份傳輸

cd /u01/xtts/bakincr
scp * oracle@192.168.59.181:/u01/xtts/oradata2
cd /u01/xtts/temp
scp xttplan.txt.new xttnewdatafiles.txt incrbackups.txt rmanconvert.cmd tsbkupmap.txt  oracle@192.168.59.181:/u01/xtts/temp

3.5.3.第二次增量備份導入

在目標端重命名xttplan.txt.new 為xttplan.txt,然后進入xtts腳本目錄執行轉換

[oracle@19c temp]$ mv xttplan.txt.new xttplan.txt
[oracle@19c rman-xttconvert]$ export TMPDIR=/u01/xtts/temp
[oracle@19c rman-xttconvert]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -r
============================================================
trace file is /u01/xtts/temp/rollforward_Feb7_Mon_15_40_33_214//Feb7_Mon_15_40_33_214_.log
=============================================================--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------
​
​
--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------
​
​
--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------
​
​
--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------
​
​
--------------------------------------------------------------------
Start rollforward
--------------------------------------------------------------------
​
​
--------------------------------------------------------------------
End of rollforward phase
--------------------------------------------------------------------
[oracle@19c rman-xttconvert]$ 

3.5.4.源端更新SCN記錄

將目標端temp目錄以及源端bakincr目錄進行清理,准備再次進行同步新數據

$ORACLE_HOME/perl/bin/perl xttdriver.pl -s
[oracle@11g rman-xttconvert]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -s
============================================================
trace file is /u01/xtts/temp/determinescn_Feb7_Mon_15_42_52_116//Feb7_Mon_15_42_52_116_.log
=============================================================--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------
​
​
--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------
​
​
--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------
​
​
--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------
Prepare newscn for Tablespaces: 'TEST1'
Prepare newscn for Tablespaces: 'TEST2'
New /u01/xtts/temp/xttplan.txt with FROM SCN's generated

3.6.最后一次增量備份數據

3.6.1.源端將表空間修改為只讀模式

alter tablespace TEST1 read only;
alter tablespace TEST2 read only;
select tablespace_name,status from dba_tablespaces;

3.6.2.源端再次執行增量備份

export TMPDIR=/u01/xtts/temp
$ORACLE_HOME/perl/bin/perl xttdriver.pl -i
​
[oracle@11g rman-xttconvert]$ export TMPDIR=/u01/xtts/temp
[oracle@11g rman-xttconvert]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -i
============================================================
trace file is /u01/xtts/temp/incremental_Feb7_Mon_15_48_09_609//Feb7_Mon_15_48_09_609_.log
=============================================================--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------
​
​
--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------
​
​
--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------
​
​
--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------
​
​
--------------------------------------------------------------------
Backup incremental
--------------------------------------------------------------------
============================================================
No new datafiles added
=============================================================
Prepare newscn for Tablespaces: 'TEST1'
Prepare newscn for Tablespaces: 'TEST2'--------------------------------------------------------------------
Starting incremental backup
--------------------------------------------------------------------
​
​
--------------------------------------------------------------------
Done backing up incrementals
--------------------------------------------------------------------
[oracle@11g rman-xttconvert]$ 

3.6.3.傳輸增量數據

--源端傳輸文件到目標端:
scp -r /u01/xtts/bakincr/* oracle@192.168.59.181:/u01/xtts/oradata2
scp xttplan.txt.new xttnewdatafiles.txt incrbackups.txt rmanconvert.cmd tsbkupmap.txt  oracle@192.168.59.181:/u01/xtts/temp
--目標端端修改
mv xttplan.txt.new xttplan.txt

3.6.4.目標端執行轉換

export TMPDIR=/u01/xtts/temp
$ORACLE_HOME/perl/bin/perl xttdriver.pl -r
​
[oracle@19c rman-xttconvert]$ export TMPDIR=/u01/xtts/temp
[oracle@19c rman-xttconvert]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -r
============================================================
trace file is /u01/xtts/temp/rollforward_Feb7_Mon_15_52_05_571//Feb7_Mon_15_52_05_571_.log
=============================================================--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------
​
​
--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------
​
​
--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------
​
​
--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------
​
​
--------------------------------------------------------------------
Start rollforward
--------------------------------------------------------------------
​
​
--------------------------------------------------------------------
End of rollforward phase
--------------------------------------------------------------------
[oracle@19c rman-xttconvert]$ 

3.7.元數據導出導入

3.7.1.元數據導出

[oracle@11g temp]$ o
​
SQL*Plus: Release 11.2.0.4.0 Production on Mon Feb 7 15:55:00 2022
​
Copyright (c) 1982, 2013, Oracle.  All rights reserved.
​
​
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
​
SQL> create or replace directory dump as '/u01/xtts/dump';
​
Directory created.
--表空間元數據導出
[oracle@11g rman-xttconvert]$ expdp system/oracle dumpfile=test.dump directory=dump transport_tablespaces=test1,test2 logfile=dump.log
​
Export: Release 11.2.0.4.0 - Production on Mon Feb 7 15:55:36 2022
​
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
​
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "SYSTEM"."SYS_EXPORT_TRANSPORTABLE_01":  system/******** dumpfile=test.dump directory=dump transport_tablespaces=test1,test2 logfile=dump.log 
Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK
Processing object type TRANSPORTABLE_EXPORT/TABLE
Processing object type TRANSPORTABLE_EXPORT/GRANT/OWNER_GRANT/OBJECT_GRANT
Processing object type TRANSPORTABLE_EXPORT/CONSTRAINT/CONSTRAINT
Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK
Master table "SYSTEM"."SYS_EXPORT_TRANSPORTABLE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SYSTEM.SYS_EXPORT_TRANSPORTABLE_01 is:
  /u01/xtts/dump/test.dump
******************************************************************************
Datafiles required for transportable tablespace TEST1:
  /u01/app/oracle/oradata/orcl/test1.dbf
Datafiles required for transportable tablespace TEST2:
  /u01/app/oracle/oradata/orcl/test2.dbf
Job "SYSTEM"."SYS_EXPORT_TRANSPORTABLE_01" successfully completed at Mon Feb 7 15:56:41 2022 elapsed 0 00:01:01
​
[oracle@11g rman-xttconvert]$ 
--相關對象元數據導出
[oracle@11g rman-xttconvert]$ expdp system/oracle directory=dump dumpfile=schema_meta.dmp logfile=expdp_schema_meta.log content=metadata_only schemas=test1,test2
​
Export: Release 11.2.0.4.0 - Production on Mon Feb 7 15:58:49 2022
​
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
​
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
FLASHBACK automatically enabled to preserve database integrity.
Starting "SYSTEM"."SYS_EXPORT_SCHEMA_01":  system/******** directory=dump dumpfile=schema_meta.dmp logfile=expdp_schema_meta.log content=metadata_only schemas=test1,test2 
Processing object type SCHEMA_EXPORT/USER
Processing object type SCHEMA_EXPORT/SYSTEM_GRANT
Processing object type SCHEMA_EXPORT/ROLE_GRANT
Processing object type SCHEMA_EXPORT/DEFAULT_ROLE
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/TABLE/TABLE
Processing object type SCHEMA_EXPORT/TABLE/GRANT/OWNER_GRANT/OBJECT_GRANT
Processing object type SCHEMA_EXPORT/TABLE/INDEX/INDEX
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Master table "SYSTEM"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SYSTEM.SYS_EXPORT_SCHEMA_01 is:
  /u01/xtts/dump/schema_meta.dmp
Job "SYSTEM"."SYS_EXPORT_SCHEMA_01" successfully completed at Mon Feb 7 15:59:08 2022 elapsed 0 00:00:15
​
[oracle@11g rman-xttconvert]$ 
--拷貝到目標環境
scp /u01/xtts/dump/test.dump oracle@192.168.59.181:/u01/xtts/dump
scp /u01/xtts/dump/schema_meta.dmp oracle@192.168.59.181:/u01/xtts/dump

3.7.2.目標端導入數據

create directory dump as '/u01/xtts/dump';
create user test1 identified by oracle default tablespace users;
create user test2 identified by oracle default tablespace users;
grant dba to test1,test2;
​
impdp system/oracle dumpfile=test.dump directory=dump logfile=dump.log transport_datafiles='/u01/xtts/oradata3/TEST1_7.dbf','/u01/xtts/oradata3/TEST2_8.dbf';
​
[oracle@19c dump]$ impdp system/oracle dumpfile=test.dump directory=dump logfile=dump.log transport_datafiles='/u01/xtts/oradata3/TEST1_7.dbf','/u01/xtts/oradata3/TEST2_8.dbf';
​
Import: Release 19.0.0.0.0 - Production on Mon Feb 7 16:11:02 2022
Version 19.3.0.0.0
​
Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.
​
Connected to: Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Master table "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_01" successfully loaded/unloaded
Starting "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_01":  system/******** dumpfile=test.dump directory=dump logfile=dump.log transport_datafiles=/u01/xtts/oradata3/TEST1_7.dbf,/u01/xtts/oradata3/TEST2_8.dbf 
Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK
Processing object type TRANSPORTABLE_EXPORT/TABLE
Processing object type TRANSPORTABLE_EXPORT/GRANT/OWNER_GRANT/OBJECT_GRANT
Processing object type TRANSPORTABLE_EXPORT/CONSTRAINT/CONSTRAINT
ORA-39014: One or more workers have prematurely exited.
ORA-39029: worker 1 with process name "DW00" prematurely terminated
ORA-31671: Worker process DW00 had an unhandled exception.
ORA-00600: internal error code, arguments: [25027], [0], [0], [4], [16777810], [0], [1], [1], [], [], [], []
​
Job "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_01" stopped due to fatal error at Mon Feb 7 16:16:57 2022 elapsed 0 00:05:09
--導入報錯,但是發現表空間已經存在。
​
--將表空間設置為讀寫模式
​
alter tablespace test1 read write;
alter tablespace test2 read write;
SQL> select tablespace_name,status from dba_tablespaces;
​
TABLESPACE_NAME                STATUS
------------------------------ ---------
SYSTEM                         ONLINE
SYSAUX                         ONLINE
UNDOTBS1                       ONLINE
TEMP                           ONLINE
USERS                          ONLINE
TEST1                          ONLINE
TEST2                          ONLINE
​
7 rows selected.
​
--導入相關元數據對象
impdp system/oracle directory=dump dumpfile=schema_meta.dmp logfile=meta.log
​
[oracle@19c dump]$ impdp system/oracle directory=dump dumpfile=schema_meta.dmp logfile=meta.log
​
Import: Release 19.0.0.0.0 - Production on Mon Feb 7 16:22:51 2022
Version 19.3.0.0.0
​
Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.
​
Connected to: Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Master table "SYSTEM"."SYS_IMPORT_FULL_01" successfully loaded/unloaded
Starting "SYSTEM"."SYS_IMPORT_FULL_01":  system/******** directory=dump dumpfile=schema_meta.dmp logfile=meta.log 
Processing object type SCHEMA_EXPORT/USER
ORA-31684: Object type USER:"TEST1" already exists
​
ORA-31684: Object type USER:"TEST2" already exists
​
Processing object type SCHEMA_EXPORT/SYSTEM_GRANT
Processing object type SCHEMA_EXPORT/ROLE_GRANT
Processing object type SCHEMA_EXPORT/DEFAULT_ROLE
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/TABLE/TABLE
ORA-39151: Table "TEST1"."TEST1" exists. All dependent metadata and data will be skipped due to table_exists_action of skip
​
ORA-39151: Table "TEST2"."TEST2" exists. All dependent metadata and data will be skipped due to table_exists_action of skip
​
Processing object type SCHEMA_EXPORT/TABLE/GRANT/OWNER_GRANT/OBJECT_GRANT
Processing object type SCHEMA_EXPORT/TABLE/INDEX/INDEX
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Job "SYSTEM"."SYS_IMPORT_FULL_01" completed with 4 error(s) at Mon Feb 7 16:23:01 2022 elapsed 0 00:00:08
​
[oracle@19c dump]$ 

3.7.3.修改用戶默認表空間信息

SQL> alter user test1 default  tablespace test1;
User altered.
SQL> alter user test2 default  tablespace test2;
User altered.

3.8.檢查無效對象並驗證數據

select 'ALTER' ||OBJECT_TYPE||''||OWNER||'.'|| OBJECT_NAME||'COMPILE;' from all_objects where status='INVALID' 
AND object_type in ('PACKAGE','FUNCTION','PROCEDURE','TABLE','VIEW','SEQUENCE','TRIGGER'); 
--驗證數據
--源端:
SQL> select object_type,count(*) from dba_objects where owner in ('TEST1','TEST2') group by object_type order by 2;
​
OBJECT_TYPE           COUNT(*)
------------------- ----------
TABLE                        2
INDEX                        2
TABLE PARTITION             18
--目標端:
OBJECT_TYPE               COUNT(*)
----------------------- ----------
TABLE                            2
TABLE PARTITION                 18

可以看到,之前源端創建在users表空間的索引沒有遷移過來。需要我們重新創建。

3.9.清理環境

/u01/xtts目錄清理

四.總結

4.1.步驟總結

  1. 首先確定需要遷移的表空間,檢查是否自包含。

  2. 找出臨時表的創建語句,元數據導入之后手動進行創建。

  3. 初始化參數修改階段。 目標端初始化備份文件和增量備份文件放同一個目錄。

  4. 增量備份前滾階段,可以多次進行。

  5. 最后一次增量備份階段。

  6. 導入元數據。

  7. 校驗數據

4.2.報錯總結

  1. 增量前滾階段目標端應用報錯 : scn號設置錯誤   增量備份文件存放目錄錯誤

  2. 導入表空間元數據報錯:沒有創建用戶


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM