環境:RHEL 6.4 + Oracle 11.2.0.4
需求:數據庫存儲由文件系統遷移到ASMhtml
Reference服務器
實驗環境前期準備: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
SQL> create pfile='/tmp/pfile.ora' from spfile; SQL> shutdown immediate -- 修改controlfile參數值 $ vi /tmp/pfile.ora controlfile='+DATA1/control01.ctl'
SQL> startup nomount pfile='/tmp/pfile.ora'
注意Oracle用戶須要有讀寫ASM磁盤的權限rest
RMAN> restore controlfile from '/u02/oradata/jingyu/control01.ctl';
RMAN> alter database mount;
RMAN> backup as copy database format '+DATA1';
RMAN> switch database to copy;
RMAN> run { set newname for tempfile 1 to '+DATA1'; switch tempfile all; } RMAN> ALTER DATABASE OPEN;
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#;
-- 在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
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