使用RAM將檔案系統遷移到ASM

kingsql發表於2014-10-17
1,全備資料庫PROD

run{
allocate channel c1 device type disk;
allocate channel c2 device type disk;
backup tag 'SH_DB' as compressed backupset format ‘/home/oracle/full_%U.bak' database
include current controlfile;
backup tag 'SH_ARCH' archivelog al format ‘/home/oracle/arch_%U.bak’l;
release channel c1;
release channel c2;
}

2,確認控制檔案的備份片
RMAN> list backup of control file;

/home/oracle/full_03pkgtf4_1_1.bak

3,匯出pfile,將控制檔案修改為+DATA和+FRA

SYS@PROD >create pfile='/home/oracle/prodpfile' from spfile;

[oracle@single ~]$ vi /home/oracle/prodpfile

*.audit_file_dest='/u01/admin/PROD/adump'
*.audit_trail='db'
*.compatible='11.2.0.4.0'
##*.control_files='/u01/oradata/PROD/control01.ctl','/u01/fast_recovery_area/PROD/control02.ctl'
*.control_files='+DATA/PROD/controlfile/control01.ctl','+FRA/PROD/controlfile/control02.ctl'
*.db_block_size=8192
*.db_create_file_dest='+DATA'
*.db_domain=''
*.db_name='PROD'
##*.db_recovery_file_dest='/u01/fast_recovery_area'
*.db_recovery_file_dest='+FRA'
*.db_recovery_file_dest_size=4385144832
*.diagnostic_dest='/u01'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=PRODXDB)'
*.log_archive_format='%t_%s_%r.dbf'
*.memory_target=583008256
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.undo_tablespace='UNDOTBS1'

4,刪除PROD
SYS@PROD >startup force mount restrict;

SYS@PROD >drop database;

5,建立災備端所需目錄(DBCA刪除資料庫需要此步驟)
mkdir -p $ORACLE_BASE/admin/PROD/adump

6,建立資料庫密碼檔案 (DBCA刪除資料庫需要此步驟)
orapwd file=$ORACLE_HOME/dbs/orapwPROD password=oracle entries=5 force=y

7,採用修改過的pfile啟動到nomount
$ sqlplus / as sysdba

SYS@PROD >startup nomount pfile=/home/oracle/pfile;

8,將spfile檔案建立到+DATA目錄下,利用Oracle11g新特性from memory

SYS@PROD >create spfile='+DATA/PROD/spfilePROD.ora' from memory;

9,建立一個pfile來指向spfile。將紅色字型內容填寫在vi建立的pfile檔案中。 在Oracle11g中安裝過叢集軟體都需要這樣配置,無論是單例項ASM還是RAC+ASM

SYS@PROD >!vi $ORACLE_HOME/dbs/initPROD.ora

SPFILE='+DATA/PROD/spfilePROD.ora’

10,恢復控制檔案到+DATA

RMAN> startup force nomount;

RMAN> restore controlfile from '/home/oracle/full_03pkgtf4_1_1.bak';

11,啟動到mount

RMAN> mount database;

12,識別備份集
RMAN> catalog start with '/home/oracle/';

13,恢復資料庫,注意關鍵詞set newname 和 switch datafile all是遷移檔案系統到ASM的關鍵。

run{
set newname for datafile 1 to '+DATA';
set newname for datafile 2 to '+DATA';
set newname for datafile 3 to '+DATA';
set newname for datafile 4 to '+DATA';
set newname for tempfile 1 to '+DATA';
restore database;
switch datafile all;
recover database;
}

14,更改聯機日誌路徑為+DATA

SYS@PROD >alter database rename file '/u01/oradata/PROD/redo01.log' to '+DATA';
SYS@PROD >alter database rename file '/u01/oradata/PROD/redo02.log' to '+DATA';
SYS@PROD >alter database rename file '/u01/oradata/PROD/redo03.log' to '+DATA';

15,open resetlogs開庫
SYS@PROD >alter database open resetlogs;

16, 如果在set newname tempfile步驟不能成功的遷移tempfile使用下面的命令手工追加
SYS@PROD >alter tablespace temp add tempfile '+DATA' size 10m;
SYS@PROD >alter tablespace temp drop tempfile '/u01/oradata/PROD/temp01.dbf’;

實驗結束

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

相關文章