最近在做一個銀行的資料庫遷移及升級的case,由於該系統為統計跑批,原系統配置已經無法滿足跑批效能要求,故要購買新的主機採用ssd及hd兩種混合型的儲存,中間過程型的表對應的資料表空間放入ssd對應目錄,曆史結果表放入hd對應目錄。所以需要在遷移過程中對資料檔案進行移動和重新命名。以下是從網上搜尋到的一篇文章,比較細緻的做了測試。記錄以下
同時此次,從oracle 11.2.0.4 遷移到12.2.0.01上,重點採用了oracle 12c的In_memory特性。對跑批效能提升有很大的協助。特此記錄一下
下面介紹移動Oracle資料檔案的兩種方法。 1.alter database方法
該方法,可以移動任何錶空間的資料檔案。
***關閉資料庫***SQL> shutdown immediateDatabase closed.Database dismounted.ORACLE instance shut down.***移動資料檔案,用oracle使用者操作***[oracle@test ~]$ mv /u01/app/oracle/oradata/test/system01.dbf /oracledb/test/system01.dbf[oracle@test ~]$ mv /u01/app/oracle/oradata/test/sysaux01.dbf /oracledb/test/sysaux01.dbf[oracle@test ~]$ mv /u01/app/oracle/oradata/test/undotbs01.dbf /oracledb/test/undotbs01.dbf[oracle@test ~]$ mv /u01/app/oracle/oradata/test/users01.dbf /oracledb/test/users01.dbf[oracle@test ~]$ mv /u01/app/oracle/oradata/test/temp01.dbf /oracledb/test/temp01.dbf[oracle@test ~]$ mv /u01/app/oracle/oradata/test/redo03.log /oracledb/test/redo03.log[oracle@test ~]$ mv /u01/app/oracle/oradata/test/redo02.log /oracledb/test/redo02.log[oracle@test ~]$ mv /u01/app/oracle/oradata/test/redo01.log /oracledb/test/redo01.log***啟動到mount狀態***SQL> startup mountORACLE instance started.Total System Global Area 1.0122E+10 bytesFixed Size 2237088 bytesVariable Size 1610616160 bytesDatabase Buffers 8489271296 bytesRedo Buffers 19468288 bytesDatabase mounted.SQL> alter database rename file '/u01/app/oracle/oradata/test/system01.dbf' to '/oracledb/test/system01.dbf';Database altered.SQL> alter database rename file '/u01/app/oracle/oradata/test/sysaux01.dbf' to '/oracledb/test/sysaux01.dbf';Database altered.SQL> alter database rename file '/u01/app/oracle/oradata/test/undotbs01.dbf' to '/oracledb/test/undotbs01.dbf';Database altered.SQL> alter database rename file '/u01/app/oracle/oradata/test/users01.dbf' to '/oracledb/test/users01.dbf';Database altered.SQL> alter database rename file '/u01/app/oracle/oradata/test/temp01.dbf' to '/oracledb/test/temp01.dbf';Database altered.SQL> alter database rename file '/u01/app/oracle/oradata/test/redo01.log' to '/oracledb/test/redo01.log';Database altered.SQL> alter database rename file '/u01/app/oracle/oradata/test/redo02.log' to '/oracledb/test/redo02.log';Database altered.SQL> alter database rename file '/u01/app/oracle/oradata/test/redo03.log' to '/oracledb/test/redo03.log';Database altered.SQL> alter database open;Database altered.***重啟驗證***SQL> shutdown immediate;Database closed.Database dismounted.ORACLE instance shut down.SQL> startupORACLE instance started.Total System Global Area 1.0122E+10 bytesFixed Size 2237088 bytesVariable Size 1610616160 bytesDatabase Buffers 8489271296 bytesRedo Buffers 19468288 bytesDatabase mounted.Database opened.
2.alter tablespace方法
該方法,不能移動system資料表空間,復原段資料表空間和臨時段資料表空間的資料檔案。
***offline system資料表空間時報錯***SQL> alter tablespace system offline;alter tablespace system offline*ERROR at line 1:ORA-01541: system tablespace cannot be brought offline; shut down if necessary報錯:說明system資料表空間不能offline***由此說明一下system資料表空間的特性--不能離線offline --不能置為唯讀read only --不能重新命名 --不能刪除SQL> alter tablespace sysaux offline;Tablespace altered.[oracle@test ~]$ cp /oracledb/test/sysaux01.dbf /u01/app/oracle/oradata/test/sysaux01.dbfSQL> alter tablespace sysaux rename datafile '/oracledb/test/sysaux01.dbf' to '/u01/app/oracle/oradata/test/sysaux01.dbf';Tablespace altered.SQL> alter tablespace sysaux online;Tablespace altered.***offline UNDO資料表空間時報錯***SQL> alter tablespace UNDOTBS1 offline;alter tablespace UNDOTBS1 offline*ERROR at line 1:ORA-30042: Cannot offline the undo tablespace***offline TEMP資料表空間時報錯***SQL> alter tablespace TEMP offline;alter tablespace TEMP offline*ERROR at line 1:ORA-03217: invalid option for alter of TEMPORARY TABLESPACE#把需要移動的資料檔案對應的資料表空間offlineSQL> alter tablespace USERS offline;Tablespace altered.#移動資料檔案至目標位置[oracle@test ~]$ cp /oracledb/test/users01.dbf /u01/app/oracle/oradata/test/users01.dbf#修改資料表空間中資料檔案的位置SQL> alter tablespace USERS rename datafile '/oracledb/test/users01.dbf' to '/u01/app/oracle/oradata/test/users01.dbf';Tablespace altered.#把資料表空間onlineSQL> alter tablespace users online;Tablespace altered.
3.總結 alter database方法可以移動任何錶空間的資料檔案,但其要求資料庫必須處於mount狀態,故此種方法更適合做整體資料庫的遷移。 alter tablespace方法需要資料庫處於open狀態,資料表空間在offline的狀態下才可更改。但其不能移動system資料表空間,undo資料表空間和temp資料表空間的資料檔案,故此種方法更適合於做使用者資料檔案的遷移。 原作地址:http://blog.csdn.net/snowying97/article/details/52576028
原作作者:風夏了白雪yi