2,restore spfile to asm diskgroupRMAN> backup as compressed backupset database plus archivelog;
Starting backup at 02-FEB-13
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=5 RECID=19 STAMP=806364292
input archived log thread=1 sequence=6 RECID=20 STAMP=806364367
channel ORA_DISK_1: starting piece 1 at 02-FEB-13
channel ORA_DISK_1: finished piece 1 at 02-FEB-13
piece handle=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/0lo1096f_1_1 tag=TAG20130202T220607 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 02-FEB-13
Starting backup at 02-FEB-13
using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/oradata/asm/system01.dbf
input datafile file number=00002 name=/oradata/asm/sysaux01.dbf
input datafile file number=00003 name=/oradata/asm/undotbs01.dbf
input datafile file number=00004 name=/oradata/asm/users.dbf
channel ORA_DISK_1: starting piece 1 at 02-FEB-13
channel ORA_DISK_1: finished piece 1 at 02-FEB-13
piece handle=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/0mo1096j_1_1 tag=TAG20130202T220610 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:02:15
Finished backup at 02-FEB-13
Starting backup at 02-FEB-13
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=7 RECID=21 STAMP=806364507
channel ORA_DISK_1: starting piece 1 at 02-FEB-13
channel ORA_DISK_1: finished piece 1 at 02-FEB-13
piece handle=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/0no109ar_1_1 tag=TAG20130202T220827 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 02-FEB-13
Starting Control File and SPFILE Autobackup at 02-FEB-13
piece handle=/oradata/rmanbackup/c-3825267224-20130202-03 comment=NONE
Finished Control File and SPFILE Autobackup at 02-FEB-13
RMAN> restore spfile to '+data/asm/spfileasm.ora';
Starting restore at 02-FEB-13
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: restoring SPFILE
output file name=+data/asm/spfileasm.ora
channel ORA_DISK_1: reading from backup piece /oradata/rmanbackup/c-3825267224-20130202-03
channel ORA_DISK_1: piece handle=/oradata/rmanbackup/c-3825267224-20130202-03 tag=TAG20130202T220828
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 02-FEB-13
SQL> alter system set control_files='+data' scope=spfile;
System altered.
SQL> shutdown immediate
ORA-01507: database not mounted
ORACLE instance shut down.
SQL> startup nomount;
ORACLE instance started.
Total System Global Area 839282688 bytes
Fixed Size 2217992 bytes
Variable Size 574621688 bytes
Database Buffers 260046848 bytes
Redo Buffers 2396160 bytes
6,restore datafile to asm diskgroupRMAN> restore controlfile from '/oradata/rmanbackup/c-3825267224-20130202-03';
Starting restore at 02-FEB-13
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=24 device type=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=+DATA/asm/controlfile/current.271.806365451
Finished restore at 02-FEB-13RMAN> alter database mount;
database mounted
released channel: ORA_DISK_1
RMAN> run
2> {
3> allocate channel c1 type disk;
4> set newname for datafile 1 to '+data/asm/system01.dbf';
5> set newname for datafile 2 to '+data/asm/sysaux01.dbf';
6> set newname for datafile 3 to '+data/asm/undotbs01.dbf';
7> set newname for datafile 4 to '+data/asm/users01.dbf';
8> restore database;
9> switch datafile all;
10> recover database;
11> release channel c1;
12> }
allocated channel: c1
channel c1: SID=24 device type=DISK
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting restore at 02-FEB-13
channel c1: starting datafile backup set restore
channel c1: specifying datafile(s) to restore from backup set
channel c1: restoring datafile 00001 to +data/asm/system01.dbf
channel c1: restoring datafile 00002 to +data/asm/sysaux01.dbf
channel c1: restoring datafile 00003 to +data/asm/undotbs01.dbf
channel c1: restoring datafile 00004 to +data/asm/users01.dbf
channel c1: reading from backup piece /u01/app/oracle/product/11.2.0/dbhome_1/dbs/0mo1096j_1_1
channel c1: piece handle=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/0mo1096j_1_1 tag=TAG20130202T220610
channel c1: restored backup piece 1
channel c1: restore complete, elapsed time: 00:02:16
Finished restore at 02-FEB-13
datafile 1 switched to datafile copy
input datafile copy RECID=21 STAMP=806365826 file name=+DATA/asm/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=22 STAMP=806365826 file name=+DATA/asm/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=23 STAMP=806365826 file name=+DATA/asm/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=24 STAMP=806365826 file name=+DATA/asm/users01.dbf
Starting recover at 02-FEB-13
starting media recovery
archived log for thread 1 with sequence 7 is already on disk as file /oradata/asm/redo05.log
archived log for thread 1 with sequence 8 is already on disk as file /oradata/asm/redo04.log
archived log file name=/oradata/asm/redo05.log thread=1 sequence=7
archived log file name=/oradata/asm/redo04.log thread=1 sequence=8
media recovery complete, elapsed time: 00:00:01
Finished recover at 02-FEB-13
released channel: c1
RMAN> alter database open resetlogs;
database opened
8,设置db_recovery_file_dest的路径SQL> alter database add logfile group 1 '+data/asm/redo01.log' size 50m;
Database altered.
SQL> alter database add logfile group 2 '+data/asm/redo02.log' size 50m;
Database altered.SQL> alter database drop logfile group 4;
Database altered.
SQL> alter database drop logfile group 5;
Database altered.SQL> select * from v$logfile;
GROUP# STATUS TYPE MEMBER IS_
---------- ------- ------- -------------------------------------------------- ---
1 ONLINE +DATA/asm/redo01.log NO
2 ONLINE +DATA/asm/redo02.log NO
9,设置tempfileSQL> alter system set db_recovery_file_dest_size=5G;
System altered.
SQL> ALTER SYSTEM SET DB_RECOVERY_FILE_DEST='+FLASH';
System altered.
======================================================SQL> alter tablespace temp add tempfile '+data/asm/temp02.dbf' size 10m;
Tablespace altered.
SQL> alter tablespace temp drop tempfile '/oradata/asm/temp01.dbf';
Tablespace altered.
SET SERVEROUTPUT ON;DECLARECURSOR rlc ISSELECT GROUP# GRP, THREAD# THR, BYTES, 'NO' SRLFROM V$LOGUNIONSELECT GROUP# GRP, THREAD# THR, BYTES, 'YES' SRLFROM V$STANDBY_LOGORDER BY 1;stmt VARCHAR2(2048);BEGINFOR rlcRec IN rlc LOOPIF (rlcRec.srl = 'YES') THENstmt := 'ALTER DATABASE ADD STANDBY LOGFILE THREAD ' ||rlcRec.thr || ' SIZE ' || rlcRec.bytes;EXECUTE IMMEDIATE stmt;stmt := 'ALTER DATABASE DROP STANDBY LOGFILE GROUP ' || rlcRec.grp;EXECUTE IMMEDIATE stmt;ELSEstmt := 'ALTER DATABASE ADD LOGFILE THREAD ' ||rlcRec.thr || ' SIZE ' || rlcRec.bytes;EXECUTE IMMEDIATE stmt;BEGINstmt := 'ALTER DATABASE DROP LOGFILE GROUP ' || rlcRec.grp;DBMS_OUTPUT.PUT_LINE(stmt);EXECUTE IMMEDIATE stmt;EXCEPTIONWHEN OTHERS THENEXECUTE IMMEDIATE 'ALTER SYSTEM SWITCH LOGFILE';EXECUTE IMMEDIATE 'ALTER SYSTEM CHECKPOINT GLOBAL';EXECUTE IMMEDIATE stmt;END;END IF;END LOOP;END;
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/24237320/viewspace-1060192/ ,如需转载,请注明出处,否则将追究法律责任。