使用 M5 跨端點 XTTS 搭配 RMAN 增量備份將 Oracle Database 移轉至 OCI
簡介
本教學課程描述如何使用具有完全可傳輸資料汲取和 RMAN 增量備份的 M5 Cross Endian Platform Migration,將 Oracle Database 移轉至 Oracle Cloud Infrastructure (OCI)。
此方法可在具有不同位元組順序格式的系統之間進行移轉,同時將應用程式停止工作時間降到最低。
處理作業從來源的完整備份複本開始到目的地。接著會套用增量備份,讓目的地與來源保持幾乎同步。只有在最終增量備份和描述資料匯出 / 匯入期間才需要停止工作時間。
環境詳細資訊
- 來源資料庫 (NON-CDB):
- 資料庫版本:
19.29.0.0 - 作業系統:
AIX
- 資料庫版本:
- 目標資料庫 (NON-CDB):
- 資料庫版本:
19.29.0.0 (OCI) - 作業系統:
Oracle Linux
- 資料庫版本:
目標
- 使用跨平台可傳輸表格空間 (XTTS) 搭配 RMAN 增量備份,在最短停機時間內跨位元組順序平台移轉資料。
必備條件
-
來源和目標資料庫必須為
ARCHIVELOG模式。 -
此程序支援來源資料庫的最低版本 v19.18。支援升級至 Oracle Database 26ai。
-
不包括表格空間
SYSTEM、SYSAUX、UNDO和TEMP。所有其他表格空間都必須包括在dbmig_ts_list.txt中。 -
跨平台只能與 Enterprise Edition 搭配使用。此程序無法與 Standard Edition 搭配使用。
-
來源資料庫和目標資料庫的字元集必須相同。
-
必須在目的地資料庫上設定
db_create_file_dest參數。 -
複查 19.10 和更新版本的 MOS 注意事項「資料汲取建議的主動修正程式」 KB107134 ,然後在來源和目的地套用 19.18 或更新版本的資料庫所需的所有修正。
-
複查 23ai / 26ai KB160561 的 MOS 注意事項「資料汲取建議的主動修正程式」,然後針對目的地的 26ai 或更新的資料庫套用所有必要的修正。
-
啟用區塊變更追蹤以提升增量備份的效能 (選擇性)。
-
表格空間必須為
READ WRITE模式。 -
READ ONLY模式的表格空間可以使用標準 XTTS 進行移轉。 -
來源和目的地的
COMPATIBLE參數必須相同 (至少為19.0.0.0)。 -
RMAN 必須使用
BACKUPSET。不得使用COPY。
作業 1:準備來源資料庫
-
執行下列查詢以檢查來源資料庫的位元組順序格式。
col PLATFORM_NAME for a50 select platform_name, platform_id, endian_format from v$transportable_platform; -
識別來源資料庫中將要傳輸的表格空間。如果您正在移轉所有表格空間,請執行下列查詢。
select tablespace_name from dba_tablespaces where contents='PERMANENT' and tablespace_name not in ('SYSTEM','SYSAUX'); -
檢查傳輸集違規:
exec dbms_tts.transport_set_check('<comma-separated tablespace list>'); SELECT * FROM SYS.TRANSPORT_SET_VIOLATIONS; -
( 選擇性 ) 在來源資料庫上啟用區塊變更追蹤,以提升增量備份的效能。
-
確認來源資料庫的所有表格空間都已在線上。
作業 2:準備目標資料庫
-
建立新使用者表格空間。
select TABLESPACE_NAME from dba_tablespaces where TABLESPACE_NAME='USERS_OCI'; select TABLESPACE_NAME from dba_tablespaces order by 1; set long 99999 SELECT DBMS_METADATA.GET_DDL ('TABLESPACE','USERS') from dual;使用以上的「資料定義語言 (DDL)」輸出並取代下方的磁碟群組名稱,然後建立新的使用者表格空間。
CREATE BIGFILE TABLESPACE USERS_OCI DATAFILE '+DATAC2' SIZE 1073741824 AUTOEXTEND ON NEXT 17179869184 MAXSIZE 33554431M LOGGING ONLINE PERMANENT BLOCKSIZE 8192 EXTENT MANAGEMENT LOCAL AUTOALLOCATE ENCRYPTION USING 'AES256' ENCRYPT DEFAULT NOCOMPRESS SEGMENT SPACE MANAGEMENT AUTO;使用下列查詢,將新的使用者表格空間 USERS_OCI 指派給擁有預設表格空間 USERS 的所有資料庫使用者。
select 'alter user '||username||' default tablespace USERS_OCI;' from dba_users where default_tablespace='USERS';重新指派新的使用者表格空間之後,上述選取查詢的輸出必須傳回 0 。
select count(*) from dba_users where default_tablespace='USERS'; ALTER DATABASE DEFAULT TABLESPACE USERS_OCI; drop tablespace users including contents and datafiles; select TABLESPACE_NAME from dba_tablespaces where TABLESPACE_NAME='USERS'; -
在目標資料庫上建立暫時表格空間。在來源執行下列查詢,並收集表格空間詳細資訊。
在來源執行以下查詢:
select TABLESPACE_NAME from dba_tablespaces where CONTENTS='TEMPORARY';然後在目標資料庫上建立暫時表格空間。舉例而言:
create bigfile temporary tablespace USER_TEMP tempfile size 672m autoextend on next 672m extent management local;
作業 3:遞增 M5 XTTS 步驟
作業 3.1:初始階段
-
請從此處下載最新的 M5 命令檔並解壓縮:使用完全可傳輸資料汲取匯出 / 匯入和 RMAN 增量備份 (文件 ID 2999157.1) 的 M5 Cross Endian 平台移轉。在 NFS 共用上建立在來源與目的地之間共用的工作目錄。來源和目的地的 NFS 共用路徑必須相同。
如果無法共用 NFS,請使用任何本機儲存體。在來源主機上建立目錄,並將它複製到目的地主機。此項目必須在整個處理程序中重複多次。來源主機和目的地主機上的路徑必須相同。如果不是,則需要對超出此程序範圍的程序檔進行各種變更。
mkdir -p <Shared_location>/XTTS_Migration mkdir -p <Shared_location>/XTTS_Migration/Backup mkdir -p <Shared_location>/XTTS_Migration/DPPUMP cd <Shared_location> unzip DBMIG.zip檔案包含:
dbmig_driver_m5.sh:移轉驅動程式指令碼。impdp.sh:匯入驅動程式指令碼。log目錄:在執行時期建立。儲存 RMAN 備份日誌、移轉日誌及其他日誌。rman_mig_bkp.log:集中式移轉日誌檔。rman_mig_bkp.lck:在每次備份開始時建立的鎖定檔案,以防止並行驅動程式執行。如果驅動程式中止執行,則不會移除鎖定。移除鎖定之前,應先調查並解決問題。
cmd目錄:在執行時期建立。儲存 RMAN 備份與回復命令檔。dbmig_driver.properties:環境變數。dbmig_ts_list.txt:以逗號分隔的表格空間清單。
-
修改 dbmig_driver.properties 中的變數 (在 cmd 目錄中) 以反映您所使用的環境,請參閱組態檔
dbmig_driver.properties中的參數描述:使用完全可傳輸資料汲取匯出 / 匯入和 RMAN 增量備份的 M5 Cross Endian 平台移轉。dbmig_driver.properties 範例檔案
############################################################ #Source database properties #my_M5_prop_version=2 # - # - ORACLE_HOME Path to Oracle Home # - ORACLE_SID SID of the source database # - SRC_SCAN Connect string to source database via SCAN. # If no SCAN, specify source database network name. # Enclose in single quotes # Example: '@myhost-scan/db1' # Example: '@localhost/pdb1' # - MIG_PDB Accepted values: 0, 1 # Choose 0 if source is non-CDB # Choose 1 if source is a PDB # - PDB_NAME If source is a PDB, specify PDB name. # Else leave blank # Example: PDB1 # - BKP_FROM_STDBY Accepted values: 0, 1 # Choose 0 to back up from primary database, # or if Data Guard is not in use. # Choose 1 to back up from standby database. ############################################################ export ORACLE_HOME=/u01/app/oracle/product/19.0.0.0/dbhome_1 export PATH=$PATH:$ORACLE_HOME/bin export ORACLE_SID=soldb1918 export SRC_SCAN='@scan1/soldb1918' export MIG_PDB=0 export PDB_NAME= export BKP_FROM_STDBY=0 ############################################################ #Source Data Pump settings # - SOURCE_DPDMP Directory path of the directory DATA_PUMP_DIR # Example: /u01/app/oracle/m5/data_pump_dir # - SOURCE_DPIR Data Pump Directory, typically DATA_PUMP_DIR # - SYSTEM_USR Username for Data Pump export. # Do not use SYS AS SYSDBA # Example: SYSTEM # - DP_TRACE Data Pump trace level. # Use 0 to disable trace. # Use 3FF0300 to full transportable tracing # See MOS Doc ID 286496.1 for details. # - DP_PARALLEL Data Pump parallel setting. # Accepted values: 1 to 999 # Example: 16 ############################################################ export SOURCE_DPDMP=<Shared_location>/XTTS_Migration/DPPUMP export SOURCE_DPDIR=DATA_PUMP_DIR export SYSTEM_USR=SYSTEM export DP_TRACE=0 export DP_PARALLEL=1 export DP_ENC_PROMPT=N ############################################################ #Source RMAN settings # - BKP_DEST_TYPE Accepted values: DISK, SBT_TAPE # Choose DISK to backup up to local storage # Choose SBT_TAPE to use ZDLRA # - BKP_DEST_PARM If BKP_DEST_TYPE=DISK, enter location for backup: # Example: /u01/app/oracle/m5/rman # If BKP_DEST_TYPE=SBT_TAPE, enter channel configuration: # Example: "'%d_%U' PARMS \"SBT_LIBRARY=<oracle_home>/lib/libra.so,SBT_PARMS=(RA_WALLET='location=file:<oracle_home>/dbs/zdlra credential_alias=<zdlra-connect-string>')\"" # - CAT_CRED If you use RMAN catalog or ZDLRA, specify connect string to catalog database # Example: <scan-name>:<port>/<service> # - SECTION_SIZE Section size used in RMAN backups # - CHN Number of RMAN channels allocated ############################################################ export BKP_DEST_TYPE=DISK export BKP_DEST_PARM=<Shared_location>/XTTS_Migration/Backup export CAT_CRED= export SECTION_SIZE=64G export CHN=8 ############################################################ #Destination host settings #If specified, the script transfers the RMAN backups and #Data Pump dump file to the destination via over SSH. #SSH equivalence is required. # - DEST_SERVER Network name of the destination server. # Leave blank if you manually transfer # backups and dump files # - DEST_USER User for SSH connection # Example: oracle # - DEST_WORKDIR The script working directory on destination # Example: /u01/app/oracle/m5 # - DEST_DPDMP The directory path used by DATA_PUMP_DIR # in destination database # Example: /u01/app/oracle/m5/data_pump_dir ############################################################ export DEST_SERVER=srvadm01 export DEST_USER=oracle export DEST_WORKDIR=<Shared_location>/XTTS_Migration export DEST_DPDMP=<Shared_location>/XTTS_Migration/DPDUMP ############################################################ #Advanced settings #Normally, you don't need to edit this section ############################################################ export WORKDIR=$PWD export LOG_DIR=${WORKDIR}/log export CMD_DIR=${WORKDIR}/cmd export PATH=$PATH:$ORACLE_HOME/bin export DT='date +%y%m%d%H%M%S' export CMD_MKDIR='which mkdir' export CMD_TOUCH='which touch' export CMD_CAT='which cat' export CMD_RM='which rm' export CMD_AWK='which awk' export CMD_SCP='which scp' export CMD_CUT='which cut' export CMD_PLATFORM='uname' if [[ "$CMD_PLATFORM" = "Linux" ]]; then export CMD_GREP="/usr/bin/grep" else if [[ "$CMD_PLATFORM" = "AIX" ]]; then export CMD_GREP="/usr/bin/grep" else if [[ "$CMD_PLATFORM" = "HPUX" ]]; then export CMD_GREP="/usr/bin/grep" else export CMD_GREP='which ggrep' fi fi fi export my_M5_prop_version=2在來源和目標資料庫上建立資料汲取傾印檔的目錄。
create directory M5_XTTS_MIG as '<Shared_Location>/XTTS_Migration/DPDUMP'; grant read,write on directory M5_XTTS_MIG to sys,system;
任務 3.2:層級 0 備份與還原
-
在來源系統上,以環境變數 (
ORACLE_HOME和ORACLE_SID) 設定為來源資料庫的 Oracle 使用者身分登入,然後執行備份:cd <Shared_location> nohup sh dbmig_driver_m5.sh L0 & -
如果不是使用共用 NFS,請將工作目錄複製到目的地主機。
-
回復目的地系統上的資料檔。
在目的地上,將環境設為目的地資料庫。驅動程式程序檔會建立還原程序檔。它儲存在指令目錄中:
cd <Shared_location>/XTTS_Migration cp nohup.out nohup.out_L0 ls -ltra cmd/restore_L0_* rman target / cmdfile=<restore_cmdfile_name>檢查 RMAN 日誌檔:
egrep "WARN-|ORA-" log/restore_*.log
作業 3.3:向前捲動階段
在此階段期間,會在來源資料庫上建立增量備份並傳輸到目的地系統。
備份會轉換成目的地位元組順序格式,並套用至目的地資料檔。此處理程序可重複多次,以保持目的地資料庫同步。
每個增量備份都小於先前的備份,並減少最終的停止工作時間範圍。
注意:您可以在不將多個備份套用至目的地的情況下,對來源執行多個備份。
- 在來源上執行來源資料庫的層次 1 (L1) 增量備份:
cd <Shared_location>/XTTS_Migration
cp nohup.out nohup.out_1
nohup sh dbmig_driver_m5.sh L1 &
-
如果不是使用共用 NFS,請將工作目錄複製到目的地主機。
-
將增量備份套用到目的地系統上的資料檔複本。在目的地系統上,以已設定適當環境變數的 Oracle 使用者身分登入,依照下列方式執行向前捲動資料檔步驟。
在目的地系統上,以已設定適當環境變數的 Oracle 使用者身分登入。驅動程式程序檔會建立還原程序檔。它儲存在指令檔目錄中:使用最新的還原指令檔還原目標資料庫上的層級 1 (L1) 備份。
cd <Shared_location>/XTTS_Migration
ls -ltra cmd/restore_L1_*
cp nohup.out nohup.out_3
rman target / cmdfile=<restore_cmdfile_name>
檢查 RMAN 日誌檔:
egrep "WARN-|ORA-" log/restore_*.log
向前捲動步驟會連線至目的地資料庫,並針對傳輸的每個表格空間,在表格空間的資料檔套用增量備份。
重複向前捲動階段,直到資料庫切換視窗為止。
作業 3.4:最終增量備份階段
- 在匯入完成之前,停用來源和目標的下列稽核相關參數。匯入完成後重新啟用它們:
show parameter audit_sys_operations
show parameter audit_trail
alter system set audit_trail=none scope=spfile sid='*';
alter system set audit_sys_operations=FALSE scope=spfile sid='*';
srvctl stop database -d ${ORACLE_UNQNAME}
srvctl start database -d ${ORACLE_UNQNAME}
show parameter audit_sys_operations
show parameter audit_trail
- 在來源上執行來源資料庫的最終層次 1 (L1) 增量備份:
此命令檔會執行下列動作:- 提示輸入系統密碼 - 將表格空間設為唯讀模式 - 執行最後的增量備份 - 執行資料汲取匯出
cd <Shared_location>/XTTS_Migration
cp nohup.out nohup.out_1
nohup sh dbmig_driver_m5.sh L1F &
-
如果不是使用共用 NFS,請將工作目錄複製到目的地主機。
-
將上次增量備份套用到目的地資料檔。
在目的地上,將環境設為目的地資料庫。驅動程式程序檔會建立還原程序檔。它儲存在指令目錄中:
cd <Shared_location>/XTTS_Migration
ls -ltra cmd/restore_L1F_*
使用最終的回復命令檔,回復目的地資料庫的最終層次 1 (L1) 備份。
cd <Shared_location>/XTTS_Migration
cp nohup.out nohup.out_5
nohup rman target / cmdfile=<restore_cmdfile_name> &
檢查 RMAN 日誌檔:
egrep "WARN-|ORA-" log/restore_*.log
作業 3.5:資料汲取匯入
-
在目標上編輯匯入驅動程式指令碼 (impdp.sh)。使用目的地資料庫的相關資訊來填入變數。
ORACLE_HOME:Oracle 本位目錄的路徑ORACLE_SID:目標資料庫 SIDORACLE_CONNECT_STRING:連線字串DATA_PUMP_PARALLEL:平行層次DATA_PUMP_TRACE:追蹤層次
匯入動因指令檔需要四個參數:
expdp_dumpfile: Name of the Data Pump dump file, e.g., exp_UP19_240206134155.dmp
rman_last_restore_log: Relative path to the last RMAN restore log
run-mode: One of the below:
test: Generates the Data Pump parameter file. Does not start Data Pump.
test-readonly. Generates the Data Pump parameter file and adds TRANSPORTABLE=KEEP_READ_ONLY to the Data Pump parameter file. Review the documentation for the usage of this parameter. Does not start Data Pump.
run: Generates the Data Pump parameter file. Starts Data Pump to perform the import.
run-readonly: Generates the Data Pump parameter file and adds TRANSPORTABLE=KEEP_READ_ONLY to the Data Pump parameter file. Review the documentation for the usage of this parameter. Starts Data Pump to perform the import.
DP_ENC_PROMPT:
One of the below
Y: Will prompt the user for an encryption password in case one was used for the export
N: Will not prompt the user for an encryption password.
以測試模式啟動匯入驅動程式命令檔,以驗證產生之「資料汲取」參數檔的正確性:
cd <Shared_location>/XTTS_Migration
sh impdp.sh <expdp_dumpfile> <rman_last_restore_log> test N
驅動程式指令碼會在目前目錄中產生參數檔案。請檢查。
$ vi imp_<oracle_sid>_<timestamp>_xtts.par
請勿變更產生的「資料汲取」參數檔。如果您需要變更參數檔,請變更驅動程式命令檔中的程式碼,以產生想要的參數檔。
以執行模式啟動匯入驅動程式命令檔,以執行「資料汲取」匯入:
cd <Shared_location>/XTTS_Migration
sh impdp.sh <expdp_dumpfile> <rman_last_restore_log> run N
請一律複查「資料汲取」日誌檔。即使「資料汲取」列為成功,您還是應一律複查「資料汲取」日誌檔,瞭解任何嚴重錯誤。
- 匯入完成後,在來源和目標資料庫上重新啟用稽核參數。
show parameter audit_sys_operations
show parameter audit_trail
alter system set audit_trail=<value before migration taken above> scope=spfile sid='*';
alter system set audit_sys_operations=<value before migration taken above> scope=spfile sid='*';
srvctl stop database -d ${ORACLE_UNQNAME}
srvctl start database -d ${ORACLE_UNQNAME}
show parameter audit_sys_operations
show parameter audit_trail
- 驗證傳輸的資料。
rman target sys/<password>@<target_db_name> trace=rman_trace.trc log=<backup_location>/tablespace_validate.log
validate tablespace <comma-separated tablespace list> check logical;
- 指定使用者表格空間以回復在目標資料庫準備中所做的變更。
select 'alter user '||username||' default tablespace users;' from dba_users where default_tablespace='USERS_OCI';
Execute the alter commands generated by above select query.
select count(*) from dba_users where default_tablespace='USERS_OCI';
ALTER DATABASE DEFAULT TABLESPACE USERS;
drop tablespace USERS_OCI including contents and datafiles;
select TABLESPACE_NAME from dba_tablespaces where TABLESPACE_NAME='USERS';
驗證來源和目標資料庫上的資料。
相關連結
確認
- 作者 - Pavan Yennampelli (首席雲端工程師)
其他學習資源
您可以在 docs.oracle.com/learn 上探索其他實驗室,或在 Oracle Learning YouTube 頻道上存取更多免費學習內容。此外,請造訪 education.oracle.com/learning-explorer 以成為 Oracle Learning Explorer。
如需產品文件,請造訪 Oracle Help Center 。
Migrate Oracle Database to OCI Using M5 Cross-Endian XTTS with RMAN Incremental Backups
G56679-01