Oracle從文件系統遷移到ASM存儲

環境:RHEL 6.4 + Oracle 11.2.0.4
需求:數據庫存儲由文件系統遷移到ASMhtml

數據庫存儲遷移到ASM磁盤組數據庫

Reference服務器

數據庫存儲遷移到ASM磁盤組

實驗環境前期準備:oracle

遷移前原數據庫各文件存儲信息查詢以下:app

--控制文件
select name from v$controlfile;
--數據文件
select name from v$datafile;
--臨時文件
select name from v$tempfile;
--日誌文件
select member from v$logfile;
--參數文件
show parameter pfile

--查詢結果以下
SQL> select name from v$controlfile;

NAME
--------------------------------------------------------------------------------
/u02/oradata/jingyu/control01.ctl
/u02/app/oracle/fast_recovery_area/jingyu/control02.ctl

SQL> select name from v$datafile;

NAME
--------------------------------------------------------------------------------
/u02/oradata/jingyu/system01.dbf
/u02/oradata/jingyu/sysaux01.dbf
/u02/oradata/jingyu/undotbs01.dbf
/u02/oradata/jingyu/users01.dbf

SQL> select name from v$tempfile;

NAME
--------------------------------------------------------------------------------
/u02/oradata/jingyu/temp01.dbf

SQL> select member from v$logfile;

MEMBER
--------------------------------------------------------------------------------
/u02/oradata/jingyu/redo03.log
/u02/oradata/jingyu/redo02.log
/u02/oradata/jingyu/redo01.log

SQL> show parameter pfile

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string      /u02/app/oracle/product/11.2.0
                                                 /dbhome_1/dbs/spfilejingyu.ora

1.1 編輯參數文件指定新的控制文件路徑

SQL> create pfile='/tmp/pfile.ora' from spfile;
SQL> shutdown immediate
-- 修改controlfile參數值
$ vi /tmp/pfile.ora
controlfile='+DATA1/control01.ctl'

1.2 啓動數據庫到nomount模式

SQL> startup nomount pfile='/tmp/pfile.ora'

1.3 RMAN恢復控制文件

注意Oracle用戶須要有讀寫ASM磁盤的權限rest

RMAN> restore controlfile from '/u02/oradata/jingyu/control01.ctl';

1.4 啓動數據庫到mount模式

RMAN> alter database mount;

1.5 RMAN Copy 數據文件

RMAN> backup as copy database format '+DATA1';

1.6 RMAN Switch 數據文件

RMAN> switch database to copy;

1.7 RMAN Switch 臨時文件,並打開數據庫

RMAN> run {
set newname for tempfile 1 to '+DATA1';
switch tempfile all;
}

RMAN> ALTER DATABASE OPEN;

1.8 遷移重作日誌文件

set linesize 200
col member for a60
SQL> SELECT a.group#, b.member, a.status FROM v$log a, v$logfile b WHERE a.group#=b.group#;
SQL> ALTER DATABASE ADD LOGFILE MEMBER '+DATA1' TO GROUP 1;
SQL> ALTER DATABASE ADD LOGFILE MEMBER '+DATA1' TO GROUP 2;
SQL> ALTER DATABASE ADD LOGFILE MEMBER '+DATA1' TO GROUP 3;
SQL> ALTER SYSTEM SWITCH LOGFILE;
SQL> ALTER DATABASE DROP LOGFILE MEMBER '/u02/oradata/jingyu/redo01.log';
SQL> ALTER SYSTEM SWITCH LOGFILE;
SQL> ALTER DATABASE DROP LOGFILE MEMBER '/u02/oradata/jingyu/redo02.log';
SQL> ALTER SYSTEM SWITCH LOGFILE;
SQL> ALTER DATABASE DROP LOGFILE MEMBER '/u02/oradata/jingyu/redo03.log';
SQL> ALTER SYSTEM CHECKPOINT;
SQL> SELECT a.group#, b.member, a.status FROM v$log a, v$logfile b WHERE a.group#=b.group#;

1.9 服務器參數文件,並重啓數據庫

-- 在ASM磁盤組中建立服務器參數文件
SQL> create spfile='+DATA1' from pfile='/tmp/pfile.ora';
-- 正常關閉數據庫
SQL> shutdown immediate 
-- 刪除$ORACLE_HOME/dbs/spfilejingyu.ora
$ rm $ORACLE_HOME/dbs/spfilejingyu.ora
-- 創建$ORACLE_HOME/dbs/initjingyu.ora,編輯內容指定ASM磁盤組中的服務器參數文件。
$ vi initjingyu.ora
spfile='+DATA1/JINGYU/PARAMETERFILE/spfile.266.897474951'
--啓動數據庫(會自動找到參數文件進而轉到ASM磁盤組中的服務器參數文件)
SQL> startup

1.10 驗證各文件存儲位置

select name from v$datafile union all
select name from v$tempfile union all
select member from v$logfile union all
select name from v$controlfile;
show parameter pfile

結果以下:日誌

SQL> select name from v$datafile union all
  2  select name from v$tempfile union all
  3  select member from v$logfile union all
  4  select name from v$controlfile;

NAME
--------------------------------------------------------------------------------
+DATA1/jingyu/datafile/system.257.897474123
+DATA1/jingyu/datafile/sysaux.258.897474149
+DATA1/jingyu/datafile/undotbs1.259.897474165
+DATA1/jingyu/datafile/users.261.897474169
+DATA1/jingyu/tempfile/temp.262.897474267
+DATA1/jingyu/onlinelog/group_1.263.897474349
+DATA1/jingyu/onlinelog/group_2.264.897474359
+DATA1/jingyu/onlinelog/group_3.265.897474363
+DATA1/control01.ctl

9 rows selected.

Elapsed: 00:00:00.02
SQL> show parameter pfile

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string      +DATA1/jingyu/parameterfile/sp
                                                 file.266.897474951

至此,數據庫存儲已經成功由文件系統所有遷移到ASM。
code

Reference

  • Steps To Migrate/Move a Database From Non-ASM to ASM And Vice-Versa (文檔 ID 252219.1)
相關文章
相關標籤/搜索