將資料庫從檔案系統遷移到ASM

leon830216發表於2014-03-01
支援資料庫版本:10gR2

前提條件: 磁碟組 DG1 DG2 均以建立並掛載


1. 確認所要遷移的檔案
SQL> 
select name from v$controlfile
union all
select name from v$datafile
union all
select name from v$tempfile
union all
select member from v$logfile
union all
select value from v$parameter where name = 'spfile';


2. 修改引數檔案

2-1. control_files
SQL> alter system set control_files='+DG1' scope=spfile;

2-2. db_create_file_dest
SQL> alter system set db_create_file_dest='+DG1';

2-3. db_recovery_file_dest
SQL> alter system set db_recovery_file_dest='+DG2';


3. 遷移檔案

3-1. 引數檔案
SQL> create pfile from spfile;
SQL> create spfile='+DG1/asmdb/spfileasmdb.ora' from pfile;
SQL> shutdown immediate
$ mv initasmdb.ora initasmdb.ora.bak
$ cp initasmdb.ora.bak initasmdb.ora
$ vim initasmdb.ora
spfile='+DG1/asmdb/spfileasmdb.ora'

3-2. 控制檔案
$ rman target /
RMAN> startup nomount
RMAN> restore controlfile from '/data/control01.ctl';
RMAN> alter database mount;

3-3. 資料檔案
RMAN> backup as copy database format '+DG1';

RMAN> switch database to copy;
RMAN> recover database;
RMAN> alter database open;

3-4. 臨時檔案
SQL> select name,status,enabled from v$tempfile;
SQL> alter tablespace temp add tempfile '+DG1';
SQL> alter tablespace temp drop tempfile '/data/temp01.dbf';

3-5. 日誌檔案
SQL> alter database add logfile member '+DG1' to group 1;
SQL> alter database add logfile member '+DG1' to group 2;
SQL> alter database add logfile member '+DG1' to group 3;
SQL> alter system switch logfile;
SQL> alter database drop logfile member '/data/asmdb/redo01.log';
SQL> alter database drop logfile member '/data/asmdb/redo02.log';
SQL> alter database drop logfile member '/data/asmdb/redo03.log';


4. 檢視遷移結果
SQL> shutdown immediate
SQL> startup
SQL>
select name from v$datafile
union all
select name from v$tempfile
union all
select name from v$controlfile
union all
select member from v$logfile;
union all
select value from v$parameter where name = 'spfile';

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

相關文章