直接複製資料檔案實現linux平臺資料庫複製到windows平臺資料庫

dbhelper發表於2015-01-23

一.1  平臺環境概述

 

之前在測試傳輸表空間時感受了一下跨平臺的移值,當時只測試了通過傳輸表空間的特性複製某個指定表空間,或者是通過RMAN中的CONVERTTTS複製資料庫,測試結束之後,感覺ORACLE10G之後對不同平臺(相同位元組順序)的資料檔案相互相容性方面得到大大提升,下意識認為不通過傳輸表空間直接複製資料檔案應該也可以,今天在本地測試了一下,確實相當好使,通過這種方式使得跨平臺的移植更加高效,也易於管理和操作,下面記錄的為操作過程。
注意:源平臺與目標平臺的位元組順序(endian format)需要相同。


源平臺:RHEL6.5  系統(64) + oracle 11.2.0.1.0
目標平臺:Windows xp 系統(32bit) + oracle11.2.0.1.0

 

注意: 本章節採用直接複製相關資料檔案的形式來實現linuxwindows平臺的資料庫複製

 

一.2  檢視位元組序

SELECT d.NAME, i.VERSION, d.PLATFORM_NAME, ENDIAN_FORMAT

FROM V$TRANSPORTABLE_PLATFORM tp, V$DATABASE d, V$INSTANCE i

WHERE tp.PLATFORM_NAME = d.PLATFORM_NAME

and d.DB_UNIQUE_NAME = i.INSTANCE_NAME;

 

 

(一)------  windows平臺下檢視,windows下之前安裝過一個orcl的庫

C:\Users\華榮>sqlplus lhr/lhr@orclxp

 

SQL*Plus: Release 11.2.0.1.0 Production on 星期六 1129 12:49:15 2014

 

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

 

 

連線到:

Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

 

SQL> set line 9999 pages 9999

SQL> SELECT d.NAME, i.VERSION, d.PLATFORM_NAME, ENDIAN_FORMAT

  2  FROM V$TRANSPORTABLE_PLATFORM tp, V$DATABASE d, V$INSTANCE i

  3  WHERE tp.PLATFORM_NAME = d.PLATFORM_NAME

  4  and d.DB_UNIQUE_NAME = i.INSTANCE_NAME;

 

NAME      VERSION           PLATFORM_NAME                                                                                 ENDIAN_FORMAT

--------- ----------------- ----------------------------------------------------------------------------------------------------- --------------

ORCL      11.2.0.1.0        Microsoft Windows IA (32-bit)                                                                 Little

 

SQL>

 

 

(二)----------  linux 平臺下檢視

 

C:\Users\華榮>sqlplus lhr/lhr@rman

 

SQL*Plus: Release 11.2.0.1.0 Production on 星期六 1129 12:52:49 2014

 

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

 

 

連線到:

Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

 

SQL> set line 9999 pages 9999

SQL> SELECT d.NAME, i.VERSION, d.PLATFORM_NAME, ENDIAN_FORMAT

  2  FROM V$TRANSPORTABLE_PLATFORM tp, V$DATABASE d, V$INSTANCE i

  3  WHERE tp.PLATFORM_NAME = d.PLATFORM_NAME

  4  and d.DB_UNIQUE_NAME = i.INSTANCE_NAME;

 

NAME      VERSION           PLATFORM_NAME                                                                                 ENDIAN_FORMAT

--------- ----------------- ----------------------------------------------------------------------------------------------------- --------------

RMAN      11.2.0.1.0        Linux x86 64-bit                                                                              Little

 

SQL>

 

 

結論: 可知windows 32位系統,linux64位系統,都是Little位元組序。

 

一.3  linux 下操作

1、生成客戶端初始化引數檔案---linux操作
2、生成重建控制檔案指令碼---linux操作

一.3.1  linux下生成pfilecontrol file

 

------------------------------------------ linux 下操作

[oracle@rhel6 ~]$ sqlplus / as sysdba

 

SQL*Plus: Release 11.2.0.1.0 Production on Sat Nov 29 12:55:58 2014

 

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

 

 

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

 

SQL> create pfile='/home/oracle/initrman.ora' from spfile;

 

File created.

 

SQL> alter database backup controlfile to trace as '/home/oracle/contr_back.txt' ;

 

Database altered.

 

 

 

(三)檢視資料檔案的路徑:

SQL> select name from v$datafile;

 

NAME

--------------------------------------------------------------------------------

/u01/app/oracle/oradata/rman/system01.dbf

/u01/app/oracle/oradata/rman/sysaux01.dbf

/u01/app/oracle/oradata/rman/undotbs01.dbf

/u01/app/oracle/oradata/rman/users01.dbf

/u01/app/oracle/oradata/rman/rman.dbf

 

(四)關閉庫--為建立一致性複製,首先關閉源資料庫

SQL> shutdown immediate;

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> exit

Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

[oracle@rhel6 ~]$

 

 

一.3.2  linux/u01/app/oracle/oradata/rman下的資料檔案、重做日誌檔案、歸檔檔案,還有剛才建立的pfile和控制檔案及listener.oratnsnames.ora檔案複製到windows平臺上

wps3C8C.tmp 

 

一.4  windows 下操作

一.4.1  建立一個rman的例項,注意SID要與linux伺服器中的相同

使用命令為Windows 新增相同的服務,並啟動它

 

------------------------------------------ windows 下操作

 

 

C:\Documents and Settings\Administrator>oradim -new -sid rman

例項已建立。

 

 

 

wps3C8D.tmp 

 

一.4.2  修改初始化引數檔案,並建立相關目錄

修改之前:

rman.__db_cache_size=79691776

rman.__java_pool_size=4194304

rman.__large_pool_size=4194304

rman.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment

rman.__pga_aggregate_target=58720256

rman.__sga_target=222298112

rman.__shared_io_pool_size=0

rman.__shared_pool_size=125829120

rman.__streams_pool_size=0

*.audit_file_dest='/u01/app/oracle/admin/rman/adump'

*.audit_trail='db'

*.compatible='11.2.0.0.0'

*.control_files='/u01/app/oracle/oradata/rman/control01.ctl','/u01/app/oracle/oradata/rman/control02.ctl'

*.db_block_size=8192

*.db_domain='lhr.com'

*.db_name='rman'

*.diagnostic_dest='/u01/app/oracle'

*.dispatchers='(PROTOCOL=TCP) (SERVICE=rmanXDB)'

*.open_cursors=300

*.pga_aggregate_target=58720256

*.processes=30

*.remote_login_passwordfile='EXCLUSIVE'

*.sessions=38

*.sga_target=220200960

*.undo_tablespace='UNDOTBS1'

 

-----------修改之後

 

rman.__db_cache_size=79691776

rman.__java_pool_size=4194304

rman.__large_pool_size=4194304

rman.__oracle_base=F:\app\oracle  #ORACLE_BASE set from environment

rman.__pga_aggregate_target=58720256

rman.__sga_target=222298112

rman.__shared_io_pool_size=0

rman.__shared_pool_size=125829120

rman.__streams_pool_size=0

*.audit_file_dest=F:\app\oracle\admin\rman\adump

*.audit_trail='db'

*.compatible='11.2.0.0.0'

*.control_files='F:\app\oracle\oradata\rman\control01.ctl','F:\app\oracle\oradata\rman\control02.ctl'

*.db_block_size=8192

*.db_domain='lhr.com'

*.db_name='rman'

*.diagnostic_dest=F:\app\oracle

*.dispatchers='(PROTOCOL=TCP) (SERVICE=rmanXDB)'

*.open_cursors=300

*.pga_aggregate_target=58720256

*.processes=30

*.remote_login_passwordfile='EXCLUSIVE'

*.sessions=38

*.sga_target=220200960

*.undo_tablespace='UNDOTBS1'

 

C:\Documents and Settings\Administrator>mkdir F:\app\oracle\admin\rman\adump

 

C:\Documents and Settings\Administrator>mkdir F:\app\oracle\oradata\rman

 

一.4.3  建立spfile並啟動到nomount狀態

 

C:\Documents and Settings\Administrator>set ORACLE_SID=rman

 

C:\Documents and Settings\Administrator>echo %ORACLE_SID%

rman

 

C:\Documents and Settings\Administrator>sqlplus / as sysdba

 

SQL*Plus: Release 11.2.0.1.0 Production on 星期六 1129 13:36:42 2014

 

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

 

已連線到空閒例程。

 

SQL> create spfile from pfile='e:initrman.ora';

 

檔案已建立。

 

SQL> startup nomount;

ORACLE 例程已經啟動。

 

Total System Global Area  221790208 bytes

Fixed Size                  1373684 bytes

Variable Size             134220300 bytes

Database Buffers           83886080 bytes

Redo Buffers                2310144 bytes

SQL>

 

一.4.4  將相應的資料檔案拷貝到相關的目錄然後重建控制檔案(也別忘了更改檔案路徑)

由於是完全備份,因此我們選擇noresetlogs方式重建(如果你的複製並非建立資料檔案一致性的基礎上,那你只能選擇resetlogs方式重建)

 

----原指令碼

CREATE CONTROLFILE REUSE DATABASE "RMAN" NORESETLOGS  NOARCHIVELOG

    MAXLOGFILES 16

    MAXLOGMEMBERS 3

    MAXDATAFILES 100

    MAXINSTANCES 8

    MAXLOGHISTORY 292

LOGFILE

  GROUP 1 '/u01/app/oracle/oradata/rman/redo01.log'  SIZE 50M BLOCKSIZE 512,

  GROUP 2 '/u01/app/oracle/oradata/rman/redo02.log'  SIZE 50M BLOCKSIZE 512,

  GROUP 3 '/u01/app/oracle/oradata/rman/redo03.log'  SIZE 50M BLOCKSIZE 512

-- STANDBY LOGFILE

 

DATAFILE

  '/u01/app/oracle/oradata/rman/system01.dbf',

  '/u01/app/oracle/oradata/rman/sysaux01.dbf',

  '/u01/app/oracle/oradata/rman/undotbs01.dbf',

  '/u01/app/oracle/oradata/rman/users01.dbf',

  '/u01/app/oracle/oradata/rman/rman.dbf'

CHARACTER SET ZHS16GBK

;

 

 

--修改之後

CREATE CONTROLFILE REUSE DATABASE "RMAN" NORESETLOGS  NOARCHIVELOG

    MAXLOGFILES 16

    MAXLOGMEMBERS 3

    MAXDATAFILES 100

    MAXINSTANCES 8

    MAXLOGHISTORY 292

LOGFILE

  GROUP 1 'F:\app\oracle\oradata\rman\redo01.log'  SIZE 50M BLOCKSIZE 512,

  GROUP 2 'F:\app\oracle\oradata\rman\redo02.log'  SIZE 50M BLOCKSIZE 512,

  GROUP 3 'F:\app\oracle\oradata\rman\redo03.log'  SIZE 50M BLOCKSIZE 512

DATAFILE

  'F:\app\oracle\oradata\rman\system01.dbf',

  'F:\app\oracle\oradata\rman\sysaux01.dbf',

  'F:\app\oracle\oradata\rman\undotbs01.dbf',

  'F:\app\oracle\oradata\rman\users01.dbf',

  'F:\app\oracle\oradata\rman\rman.dbf'

CHARACTER SET ZHS16GBK

;

 

 

-------------------  將相應的資料檔案拷貝到相關的目錄,然後建立控制檔案:

 

 

SQL> CREATE CONTROLFILE REUSE DATABASE "RMAN" NORESETLOGS  NOARCHIVELOG

  2      MAXLOGFILES 16

  3      MAXLOGMEMBERS 3

  4      MAXDATAFILES 100

  5      MAXINSTANCES 8

  6      MAXLOGHISTORY 292

  7  LOGFILE

  8    GROUP 1 'F:\app\oracle\oradata\rman\redo01.log'  SIZE 50M BLOCKSIZE 512,

  9    GROUP 2 'F:\app\oracle\oradata\rman\redo02.log'  SIZE 50M BLOCKSIZE 512,

10    GROUP 3 'F:\app\oracle\oradata\rman\redo03.log'  SIZE 50M BLOCKSIZE 512

11  DATAFILE

12    'F:\app\oracle\oradata\rman\system01.dbf',

13    'F:\app\oracle\oradata\rman\sysaux01.dbf',

14    'F:\app\oracle\oradata\rman\undotbs01.dbf',

15    'F:\app\oracle\oradata\rman\users01.dbf',

16    'F:\app\oracle\oradata\rman\rman.dbf'

17  CHARACTER SET ZHS16GBK

18  ;

 

控制檔案已建立。

 

一.4.5  開啟資料庫並新增臨時表空間資料檔案

--由於前面是在資料庫正常關閉情況下拷貝的資料檔案,處於一致性狀態,不需要執行recover,直接open

 

SQL> ALTER DATABASE OPEN;

資料庫已更改。

 

SQL>ALTER TABLESPACE TEMP ADD TEMPFILE 'F:\app\oracle\oradata\rman\temp01.dbf'SIZE 20971520  REUSE AUTOEXTEND ON NEXT 655360  MAXSIZE 32767M;

表空間已更改。

 

 

一.4.6  由於是64位到32位作業系統,所以需要編譯一下核心程式碼

錯誤原因:用64位系統上的備份片將資料庫還原到32位系統中所產生,反過來也會產生此錯誤。

解決方案:執行指令碼用32位系統重新編譯一下核心引數即可

以下是詳細描述:

 


$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.5.0 - Production on Fri Jul 30 11:21:16 2010

Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.

Connected to:

Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

ERROR:

ORA-06553: PLS-801: internal error [56319]

SQL> conn xxx/xxx

Connected.

 

ERROR at line 1:

ORA-06553: PLS-801: internal error [56319]

 

 


解決方法如下:


SQL> shutdown immediate;
SQL> startup upgrade;

SQL> @?/rdbms/admin/utlirp.sql

SQL> @?/rdbms/admin/utlrp.sql

SQL> shutdown immediate;

SQL> startup;

 

其中:

utlirp.sql的作用是把相關內容全部在32bit平臺下編譯一遍.

utlrp.sql的作用是編譯所有失效物件.

然後再重新連線,就不會報錯了。

 

告警日誌報錯內容:

Error 604 in kwqmnpartition(), aborting txn

Sat Nov 29 14:00:09 2014

Errors in file f:\app\oracle\diag\rdbms\rman\rman\trace\rman_mmon_5476.trc:

ORA-06553: PLS-801: internal error [56327]

Errors in file f:\app\oracle\diag\rdbms\rman\rman\trace\rman_mmon_5476.trc:

ORA-06553: PLS-801: internal error [56327]

Errors in file f:\app\oracle\diag\rdbms\rman\rman\trace\rman_ora_5436.trc:

ORA-00604: 遞迴 SQL 級別 1 出現錯誤

ORA-06553: PLS-801: 內部錯誤 [56327]

Errors in file f:\app\oracle\diag\rdbms\rman\rman\trace\rman_ora_5436.trc:

ORA-00604: 遞迴 SQL 級別 1 出現錯誤

ORA-06553: PLS-801: 內部錯誤 [56327]

Completed: alter database open

Errors in file f:\app\oracle\diag\rdbms\rman\rman\trace\rman_mmon_5476.trc:

ORA-06553: PLS-801: internal error [56327]

Errors in file f:\app\oracle\diag\rdbms\rman\rman\trace\rman_mmon_5476.trc:

ORA-06553: PLS-801: internal error [56327]

Sat Nov 29 14:00:11 2014

Starting background process CJQ0

Sat Nov 29 14:00:11 2014

CJQ0 started with pid=21, OS id=3048

Errors in file f:\app\oracle\diag\rdbms\rman\rman\trace\rman_cjq0_3048.trc:

ORA-00604: error occurred at recursive SQL level 1

ORA-06544: PL/SQL: internal error, arguments: [56327], [], [], [], [], [], [], []

ORA-06553: PLS-801: internal error [56327]

Sat Nov 29 14:00:15 2014

Errors in file f:\app\oracle\diag\rdbms\rman\rman\trace\rman_j000_5048.trc:

ORA-12012: error on auto execute of job 57371

ORA-06553: PLS-801: internal error [56327]

Sat Nov 29 14:00:18 2014

Errors in file f:\app\oracle\diag\rdbms\rman\rman\trace\rman_q000_1940.trc:

ORA-06553: PLS-801: internal error [56327]

ORA-06553: PLS-801: internal error [56327]

Errors in file f:\app\oracle\diag\rdbms\rman\rman\trace\rman_cjq0_3048.trc:

ORA-00604: error occurred at recursive SQL level 1

ORA-06544: PL/SQL: internal error, arguments: [56327], [], [], [], [], [], [], []

ORA-06553: PLS-801: internal error [56327]

Sat Nov 29 14:00:25 2014

Errors in file f:\app\oracle\diag\rdbms\rman\rman\trace\rman_cjq0_3048.trc:

ORA-00604: error occurred at recursive SQL level 1

ORA-06544: PL/SQL: internal error, arguments: [56327], [], [], [], [], [], [], []

ORA-06553: PLS-801: internal error [56327]

Errors in file f:\app\oracle\diag\rdbms\rman\rman\trace\rman_cjq0_3048.trc:

ORA-00604: error occurred at recursive SQL level 1

ORA-06544: PL/SQL: internal error, arguments: [56327], [], [], [], [], [], [], []

ORA-06553: PLS-801: internal error [56327]

Sat Nov 29 14:00:35 2014

Errors in file f:\app\oracle\diag\rdbms\rman\rman\trace\rman_cjq0_3048.trc:

ORA-00604: error occurred at recursive SQL level 1

ORA-06544: PL/SQL: internal error, arguments: [56327], [], [], [], [], [], [], []

ORA-06553: PLS-801: internal error [56327]

Errors in file f:\app\oracle\diag\rdbms\rman\rman\trace\rman_cjq0_3048.trc:

ORA-00604: error occurred at recursive SQL level 1

ORA-06544: PL/SQL: internal error, arguments: [56327], [], [], [], [], [], [], []

ORA-06553: PLS-801: internal error [56327]

Sat Nov 29 14:00:45 2014

Errors in file f:\app\oracle\diag\rdbms\rman\rman\trace\rman_cjq0_3048.trc:

ORA-00604: error occurred at recursive SQL level 1

ORA-06544: PL/SQL: internal error, arguments: [56327], [], [], [], [], [], [], []

ORA-06553: PLS-801: internal error [56327]

Errors in file f:\app\oracle\diag\rdbms\rman\rman\trace\rman_cjq0_3048.trc:

ORA-00604: error occurred at recursive SQL level 1

ORA-06544: PL/SQL: internal error, arguments: [56327], [], [], [], [], [], [], []

ORA-06553: PLS-801: internal error [56327]

Sat Nov 29 14:00:55 2014

Errors in file f:\app\oracle\diag\rdbms\rman\rman\trace\rman_cjq0_3048.trc:

ORA-00604: error occurred at recursive SQL level 1

ORA-06544: PL/SQL: internal error, arguments: [56327], [], [], [], [], [], [], []

ORA-06553: PLS-801: internal error [56327]

 

 

一.4.7  其它配置工作

重配一下listener及tnsnames,重建密碼檔案等等其它工作你懂的。。。

一.4.8  測試OK

linuxrman庫:

SQL> select dbid,name,current_scn,database_role,force_logging,open_mode from v$database;

 

      DBID NAME      CURRENT_SCN DATABASE_ROLE   FOR OPEN_MODE

---------- --------- ----------- ---------------- --- --------------------

1738582916 RMAN 1257134 PRIMARY   NO  READ WRITE

 

windows上的rman庫:

SQL> select dbid,name,current_scn,database_role,force_logging,open_mode from v$database;

 

      DBID NAME      CURRENT_SCN DATABASE_ROLE    FOR OPEN_MODE

---------- --------- ----------- ---------------- --- --------------------

1738582916 RMAN          1306218 PRIMARY          NO  READ WRITE

 

注意:我原來是在沒有編譯核心程式碼的時候測試建表語句的時候內部錯誤,從告警日誌也可以看出是內部錯誤,最後重新編譯了核心後建表就沒有問題了

 

SQL> create table t as select * from dual;

 

表已建立。

 

SQL> insert into t select * from dual;

 

已建立 1 行。

 

SQL> commit;

 

提交完成。

 

SQL> delete from t;

 

已刪除2行。

 

SQL> commit;

 

提交完成。

 

SQL> drop table t;

 

表已刪除。

 

SQL>

一.4.9  刪除資料庫做其它測試

SQL> shutdown abort

ORACLE 例程已經關閉。

SQL> startup mount restrict;

ORACLE 例程已經啟動。

 

Total System Global Area  221790208 bytes

Fixed Size                  1373684 bytes

Variable Size             138414604 bytes

Database Buffers           79691776 bytes

Redo Buffers                2310144 bytes

資料庫裝載完畢。

SQL> drop database;

 

資料庫已刪除。

 

Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options 斷開

SQL>

 

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29819001/viewspace-1465666/,如需轉載,請註明出處,否則將追究法律責任。

相關文章