RMAN同位元組序跨平台跨版本遷移資料庫

來源:互聯網
上載者:User

RMAN同位元組序跨平台跨版本遷移資料庫

跨平台傳輸資料庫
RMAN的convert database命令被用來將整個資料庫從一個平台移動到另一個平台。當源平台與目標平台位元組序相同時,RMAN會在目標平台自動完成建立新資料庫的大部分操作。當跨平台傳輸資料庫時convertdatabase命令的處理過程將會很長。與傳輸資料表空間一樣,RMAN的convert database命令可以在源平台或目標平台執行。

當跨平台傳輸資料庫時檔案會自動被傳輸到目標平台,這些檔案包括:
1.屬於永久資料表空間的資料檔案,注意,不管源平台與目標平吧的位元組序是否相同,傳輸資料庫的資料檔案必須要進行轉換不能簡單的從一個平台複製到另一個平台。與跨平台傳輸資料表空間不一樣,傳輸整個資料庫要求特定類型的資料區塊,比如undo段,要被重新格式化確保與目標平台相容

2.如果使用PFILE,PFILE檔案會被傳輸。如果使用SPFILE,會基於SPFILE產生PFILE並將其傳輸,並在目標平基於PFILE來產生新的SPFILE。注意,在大多數情況下,PFILE檔案中的有些參數對於新資料庫需要手動修改。例如db_name,control_files

跨平台傳輸資料庫的限制
 跨平台傳輸資料庫的主要限制是源平台與目標平台必須有相同的位元組序。例如,當將資料庫從Windows平台傳輸到Linux平台(都是小位元組序)或者從HP-UX到AIX(都是大位元組序),不能將整個資料庫從HP-UX傳輸到Linux平台上。然而,可以在目標平台上建立一個新資料庫,並使用資料表空間傳輸功能將需要的資料表空間從來源資料庫中使用跨平台與跨位元組序傳輸到目標資料庫中。

--------------------------------------推薦閱讀 --------------------------------------

RMAN 配置歸檔日誌刪除策略

Oracle基礎教程之通過RMAN複製資料庫

RMAN備份策略制定參考內容

RMAN備份學習筆記

OracleDatabase Backup加密 RMAN加密

--------------------------------------分割線 --------------------------------------

在源平台執行轉換
 將32位windows平台上的資料庫jingyong(10.2.0.1)遷移到32位的Linux平台上(10.2.0.5)。在源平台上執行RMAN的convert database操作的步驟如下:
1.將來源資料庫以唯讀模式開啟
C:\Users\Administrator>sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on 星期二 3月 31 15:08:36 2015

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


串連到:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

SQL> shutdown immediate
資料庫已經關閉。
已經卸載資料庫。
ORACLE 常式已經關閉。
SQL> startup mount
ORACLE 常式已經啟動。

Total System Global Area  419430400 bytes
Fixed Size                  1249320 bytes
Variable Size            125833176 bytes
Database Buffers          285212672 bytes
Redo Buffers                7135232 bytes
資料庫裝載完畢。
SQL> alter database open read only;

資料庫已更改。

 

2.對來源資料庫執行dbms_tdb.check_db檢查
SQL> set serveroutput on
SQL> declare
  2  db_ready boolean;
  3  begin
  4  db_ready :=dbms_tdb.check_db('Linux IA (32-bit)',dbms_tdb.skip_readonly);
  5  end;
  6  /

PL/SQL procedure successfully completed


3.對來源資料庫執行dbms_tdb.check_external來識別外部對象
SQL> set serveroutput on;
SQL> declare
  2    external boolean;
  3  begin
  4    external:=dbms_tdb.check_external;
  5  end;
  6  /

The following external tables exist in the database:
SH.SALES_TRANSACTIONS_EXT
The following directories exist in the database:
SYS.TEST_DUMP, SYS.SUBDIR, SYS.XMLDIR, SYS.MEDIA_DIR, SYS.LOG_FILE_DIR, SYS.DATA_FILE_DIR, SYS.WORK_DIR, SYS.ADMIN_DIR, SYS.DATA_PUMP_DIR
The following BFILEs exist in the database:
PM.PRINT_MEDIA

PL/SQL procedure successfully completed


4.執行convert database命令,指定目標平台和輸出檔案名稱。RMAN會產生需要移動到目標平台上的檔案,包含以下檔案:
--資料庫完整的資料檔案副本
--在目標平台使用的新的PFILE參數檔案,包含來自來源資料庫PFILE或SPFILE中的設定。在目標平台使用之前需要進行相應修改
--傳輸指令碼,包含在目標平台建立新資料庫的SQL語句
RMAN> convert database new database 'jingyong'
2> transport script 'E:\oradata\transport\transport_db_script.sql'
3> to platform 'Linux IA (32-bit)'
4> db_file_name_convert('E:\oradata\JINGYONG\DATAFILE', 'E:\oradata\transport','
E:\oradata\JINGYONG', 'E:\oradata\transport');

啟動 convert 於 31-3月 -15
使用目標資料庫控制檔案替代恢複目錄
分配的通道: ORA_DISK_1
通道 ORA_DISK_1: sid=152 devtype=DISK

在資料庫中找到外部表格 SH.SALES_TRANSACTIONS_EXT

在資料庫中找到目錄 SYS.TEST_DUMP
在資料庫中找到目錄 SYS.SUBDIR
在資料庫中找到目錄 SYS.XMLDIR
在資料庫中找到目錄 SYS.MEDIA_DIR
在資料庫中找到目錄 SYS.LOG_FILE_DIR
在資料庫中找到目錄 SYS.DATA_FILE_DIR
在資料庫中找到目錄 SYS.WORK_DIR
在資料庫中找到目錄 SYS.ADMIN_DIR
在資料庫中找到目錄 SYS.DATA_PUMP_DIR

在資料庫中找到 BFILE PM.PRINT_MEDIA

在口令檔案中找到使用者 SYS (具有 SYSDBA and SYSOPER 許可權)
通道 ORA_DISK_1: 啟動資料檔案轉換
輸入資料檔案 fno=00001 name=E:\ORADATA\JINGYONG\DATAFILE\O1_MF_SYSTEM_BKLLOT8Z_.
DBF
已轉換的資料檔案 = E:\ORADATA\TRANSPORT\O1_MF_SYSTEM_BKLLOT8Z_.DBF
通道 ORA_DISK_1: 資料檔案轉換完畢, 經過時間: 00:00:25
通道 ORA_DISK_1: 啟動資料檔案轉換
輸入資料檔案 fno=00003 name=E:\ORADATA\JINGYONG\DATAFILE\O1_MF_SYSAUX_BKLLOTFL_.
DBF
已轉換的資料檔案 = E:\ORADATA\TRANSPORT\O1_MF_SYSAUX_BKLLOTFL_.DBF
通道 ORA_DISK_1: 資料檔案轉換完畢, 經過時間: 00:00:16
通道 ORA_DISK_1: 啟動資料檔案轉換
輸入資料檔案 fno=00005 name=E:\ORADATA\JINGYONG\DATAFILE\O1_MF_EXAMPLE_BKLLRKG2_
.DBF
已轉換的資料檔案 = E:\ORADATA\TRANSPORT\O1_MF_EXAMPLE_BKLLRKG2_.DBF
通道 ORA_DISK_1: 資料檔案轉換完畢, 經過時間: 00:00:07
通道 ORA_DISK_1: 啟動資料檔案轉換
輸入資料檔案 fno=00006 name=E:\ORADATA\JINGYONG\TSPITR01.DBF
已轉換的資料檔案 = E:\ORADATA\TRANSPORT\TSPITR01.DBF
通道 ORA_DISK_1: 資料檔案轉換完畢, 經過時間: 00:00:03
通道 ORA_DISK_1: 啟動資料檔案轉換
輸入資料檔案 fno=00007 name=E:\ORADATA\JINGYONG\TEST01.DBF
已轉換的資料檔案 = E:\ORADATA\TRANSPORT\TEST01.DBF
通道 ORA_DISK_1: 資料檔案轉換完畢, 經過時間: 00:00:03
通道 ORA_DISK_1: 啟動資料檔案轉換
輸入資料檔案 fno=00002 name=E:\ORADATA\JINGYONG\DATAFILE\O1_MF_UNDOTBS1_BKLLOTM0
_.DBF
已轉換的資料檔案 = E:\ORADATA\TRANSPORT\O1_MF_UNDOTBS1_BKLLOTM0_.DBF
通道 ORA_DISK_1: 資料檔案轉換完畢, 經過時間: 00:00:03
通道 ORA_DISK_1: 啟動資料檔案轉換
輸入資料檔案 fno=00004 name=E:\ORADATA\JINGYONG\DATAFILE\O1_MF_USERS_BKLLOTM6_.D
BF
已轉換的資料檔案 = E:\ORADATA\TRANSPORT\O1_MF_USERS_BKLLOTM6_.DBF
通道 ORA_DISK_1: 資料檔案轉換完畢, 經過時間: 00:00:01
在目標平台上運行 SQL 指令碼 E:\ORADATA\TRANSPORT\TRANSPORT_DB_SCRIPT.SQL 以建立數
據庫
編輯 init.ora 檔案 D:\ORACLE\PRODUCT\10.2.0\DB_1\DATABASE\INIT_00Q37GUS_1_0.ORA
。此 PFILE 將用於在目標平台上建立資料庫據
要重新編譯所有 PL/SQL 模組, 請在目標平台上運行 utlirp.sql 和 utlrp.sql
要更改內部資料庫標識符, 請使用 DBNEWID 公用程式
完成 backup 於 31-3月 -15

 

5.將轉換操作產生的所有檔案傳輸到目標主機上儲存資料庫檔案的目錄中當convert database執行完成後,來源資料庫可以以讀寫入模式開啟,產生的所有檔案都要被傳輸到目標主機上。
ftp> put INIT_00Q37GUS_1_0.ORA
200 PORT command successful. Consider using PASV.
150 Ok to send data.
226 File receive OK.
ftp: 發送 1415 位元組,用時 0.00秒 1415.00KB/秒。
ftp> put O1_MF_EXAMPLE_BKLLRKG2_.DBF
200 PORT command successful. Consider using PASV.
150 Ok to send data.
226 File receive OK.
ftp: 發送 104865792 位元組,用時 8.57秒 12233.53KB/秒。
ftp> put O1_MF_SYSTEM_BKLLOT8Z_.DBF
200 PORT command successful. Consider using PASV.
150 Ok to send data.
226 File receive OK.
ftp: 發送 503324672 位元組,用時 49.54秒 10160.38KB/秒。
ftp> put TSPITR01.DBF
200 PORT command successful. Consider using PASV.
150 Ok to send data.
226 File receive OK.
ftp: 發送 52436992 位元組,用時 4.46秒 11762.45KB/秒。
ftp> put TEST01.DBF
200 PORT command successful. Consider using PASV.
150 Ok to send data.
226 File receive OK.
ftp: 發送 52436992 位元組,用時 3.48秒 15050.80KB/秒。
ftp> put O1_MF_UNDOTBS1_BKLLOTM0_.DBF
200 PORT command successful. Consider using PASV.
150 Ok to send data.
226 File receive OK.
ftp: 發送 31465472 位元組,用時 2.05秒 15341.53KB/秒。
ftp> put O1_MF_USERS_BKLLOTM6_.DBF
200 PORT command successful. Consider using PASV.
150 Ok to send data.
226 File receive OK.
ftp: 發送 5251072 位元組,用時 0.20秒 26520.57KB/秒。
ftp> put TRANSPORT_DB_SCRIPT.SQL
200 PORT command successful. Consider using PASV.
150 Ok to send data.
226 File receive OK.
ftp: 發送 2582 位元組,用時 0.00秒 2582000.00KB/秒。
ftp> put O1_MF_SYSAUX_BKLLOTFL_.DBF
200 PORT command successful. Consider using PASV.
150 Ok to send data.
226 File receive OK.
ftp: 發送 251666432 位元組,用時 19.63秒 12817.89KB/秒。


[oracle@oracle11g jingyong]$ ls -lrt
total 978976
-rwxrwxrwx 1 oracle oinstall      1415 Mar 31 16:18 INIT_00Q37GUS_1_0.ORA
-rwxrwxrwx 1 oracle oinstall 104865792 Mar 31 16:18 O1_MF_EXAMPLE_BKLLRKG2_.DBF
-rwxrwxrwx 1 oracle oinstall 503324672 Mar 31 16:20 O1_MF_SYSTEM_BKLLOT8Z_.DBF
-rwxrwxrwx 1 oracle oinstall  52436992 Mar 31 16:21 TSPITR01.DBF
-rwxrwxrwx 1 oracle oinstall  52436992 Mar 31 16:21 TEST01.DBF
-rwxrwxrwx 1 oracle oinstall  31465472 Mar 31 16:22 O1_MF_UNDOTBS1_BKLLOTM0_.DBF
-rwxrwxrwx 1 oracle oinstall  5251072 Mar 31 16:22 O1_MF_USERS_BKLLOTM6_.DBF
-rwxrwxrwx 1 oracle oinstall      2582 Mar 31 16:23 TRANSPORT_DB_SCRIPT.SQL
-rwxrwxrwx 1 oracle oinstall 251666432 Mar 31 16:24 O1_MF_SYSAUX_BKLLOTFL_.DBF

 

6.在目標主機上建立資料庫需要的目錄,並修改PFILE參數檔案中的相關參數,並修改傳輸指令碼中指示資料檔案的位置。

建立相關目錄
[oracle@oracle11g dbs]$ mkdir -p /u01/app/oracle/admin/jingyong/adump
[oracle@oracle11g dbs]$ mkdir -p /u01/app/oracle/admin/jingyong/bdump
[oracle@oracle11g dbs]$ mkdir -p /u01/app/oracle/admin/jingyong/cdump
[oracle@oracle11g dbs]$ mkdir -p /u01/app/oracle/admin/jingyong/udump
[oracle@oracle11g dbs]$ chmod -R 777 /u01/app/oracle/admin/jingyong*


修改PFILE參數檔案
[oracle@oracle11g jingyong]$ vi initjingyong.ora
# Please change the values of the following parameters:


  audit_file_dest          = '/u01/app/oracle/admin/jingyong/adump'

  background_dump_dest    = '/u01/app/oracle/admin/jingyong/bdump'

  user_dump_dest          = '/u01/app/oracle/admin/jingyong/udump'

  core_dump_dest          = '/u01/app/oracle/admin/jingyong/udump'

  db_name                  = "JINGYONG"
  control_files='/u01/app/oracle/oradata/test/control01.ctl'


# Please review the values of the following parameters:


  dispatchers              = "(PROTOCOL=TCP) (SERVICE=jingyongXDB)"

 

# The values of the following parameters are from source database:

  processes                = 150

  nls_language            = "SIMPLIFIED CHINESE"

  nls_territory            = "CHINA"

  sga_target              = 130M

  db_block_size            = 8192

  compatible              = "10.2.0.1.0"

  db_file_multiblock_read_count= 16

  undo_management          = "AUTO"

  undo_tablespace          = "UNDOTBS1"

  job_queue_processes      = 10

  open_cursors            = 300

  pga_aggregate_target    = 32M

 

修改convert database命令產生的傳輸指令碼
[oracle@oracle11g jingyong]$ vi TRANSPORT_DB_SCRIPT.SQL
-- The contents of online logs will be lost and all backups will
-- be invalidated. Use this only if online logs are damaged.

-- After mounting the created controlfile, the following SQL
-- statement will place the database in the appropriate
-- protection mode:
--  ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE PERFORMANCE

STARTUP NOMOUNT PFILE='/u01/app/oracle/10.2.0/db/dbs/initjingyong.ora'

-- Create SPFILE
CREATE SPFILE FROM PFILE = '/u01/app/oracle/10.2.0/db/dbs/initjingyong.ora';


STARTUP FORCE NOMOUNT
CREATE CONTROLFILE REUSE SET DATABASE "JINGYONG" RESETLOGS  NOARCHIVELOG
    MAXLOGFILES 16
    MAXLOGMEMBERS 3
    MAXDATAFILES 100
    MAXINSTANCES 8
    MAXLOGHISTORY 292
LOGFILE
  GROUP 1 '/u02/jingyong/redo01.log' SIZE 50M,
  GROUP 2 '/u02/jingyong/redo02.log' SIZE 50M,
  GROUP 3 '/u02/jingyong/redo03.log' SIZE 50M
DATAFILE
  '/u02/jingyong/O1_MF_SYSTEM_BKLLOT8Z_.DBF',
  '/u02/jingyong/O1_MF_UNDOTBS1_BKLLOTM0_.DBF',
  '/u02/jingyong/O1_MF_SYSAUX_BKLLOTFL_.DBF',
  '/u02/jingyong/O1_MF_USERS_BKLLOTM6_.DBF',
  '/u02/jingyong/O1_MF_EXAMPLE_BKLLRKG2_.DBF',
  '/u02/jingyong/TSPITR01.DBF',
  '/u02/jingyong/TEST01.DBF'
CHARACTER SET ZHS16GBK
;

-- Database can now be opened zeroing the online logs.
ALTER DATABASE OPEN RESETLOGS;

-- Commands to add tempfiles to temporary tablespaces.
-- Online tempfiles have complete space information.
-- Other tempfiles may require adjustment.
ALTER TABLESPACE TEMP ADD TEMPFILE '/u02/jingyong/temp01.dbf'
    SIZE 50M  AUTOEXTEND OFF;
-- End of tempfile additions.
--

set echo off
prompt ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
prompt * Your database has been created successfully!
prompt * There are many things to think about for the new database. Here
prompt * is a checklist to help you stay on track:
prompt * 1. You may want to redefine the location of the directory objects.
prompt * 2. You may want to change the internal database identifier (DBID)
prompt *    or the global database name for this database. Use the
prompt *    NEWDBID Utility (nid).
prompt ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

SHUTDOWN IMMEDIATE
STARTUP UPGRADE
@@ ?/rdbms/admin/utlirp.sql
SHUTDOWN IMMEDIATE
STARTUP
-- The following step will recompile all PL/SQL modules.
-- It may take serveral hours to complete.
@@ ?/rdbms/admin/utlrp.sql

更多詳情見請繼續閱讀下一頁的精彩內容:

  • 1
  • 2
  • 3
  • 4
  • 下一頁

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.