ASM之迁移到ASM
oracle@wayne-laptop:~$ rman target /
Recovery Manager: Release 10.2.0.4.0 – Production on Tue Aug 11 16:20:41 2009
Copyright (c) 1982, 2007, Oracle. All rights reserved.
connected to target database: ORA10G (DBID=4013050375)
RMAN> BACKUP AS COPY INCREMENTAL LEVEL 0 DATABASE FORMAT ‘+dg1′TAG ‘ORA_ASM_MIGRATION’;
Starting backup at 11-AUG-09
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile fno=00001 name=/home/oracle/app/oradata/ora10g/system01.dbf
output filename=+DG1/ora10g/datafile/system.264.694628679 tag=ORA_ASM_MIGRATION recid=7 stamp=694628715
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:45
channel ORA_DISK_1: starting datafile copy
input datafile fno=00002 name=/home/oracle/app/oradata/ora10g/undotbs01.dbf
output filename=+DG1/ora10g/datafile/undotbs1.265.694628721 tag=ORA_ASM_MIGRATION recid=8 stamp=694628745
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:35
channel ORA_DISK_1: starting datafile copy
input datafile fno=00003 name=/home/oracle/app/oradata/ora10g/sysaux01.dbf
output filename=+DG1/ora10g/datafile/sysaux.266.694628757 tag=ORA_ASM_MIGRATION recid=9 stamp=694628773
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:25
channel ORA_DISK_1: starting datafile copy
input datafile fno=00005 name=/home/oracle/app/oradata/ORA10G/datafile/o1_mf_wayne_57q7y8hp_.dbf
output filename=+DG1/ora10g/datafile/wayne.268.694628781 tag=ORA_ASM_MIGRATION recid=10 stamp=694628787
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting datafile copy
input datafile fno=00004 name=/home/oracle/app/oradata/ora10g/users01.dbf
output filename=+DG1/ora10g/datafile/users.261.694628797 tag=ORA_ASM_MIGRATION recid=11 stamp=694628796
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting datafile copy
copying current control file
output filename=+DG1/ora10g/controlfile/backup.262.694628797 tag=ORA_ASM_MIGRATION recid=12 stamp=694628799
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting incremental level 0 datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 11-AUG-09
channel ORA_DISK_1: finished piece 1 at 11-AUG-09
piece handle=+DG1/ora10g/backupset/2009_08_11/nnsnn0_ora_asm_migration_0.263.694628803 tag=ORA_ASM_MIGRATION comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
Finished backup at 11-AUG-09
RMAN> run {
2> backup as backupset spfile;
3> restore spfile to ‘+dg1/spfile’;
4> }
Starting backup at 11-AUG-09
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 11-AUG-09
channel ORA_DISK_1: finished piece 1 at 11-AUG-09
piece handle=/home/oracle/app/flash_recovery_area/ORA10G/backupset/2009_08_11/o1_mf_nnsnf_TAG20090811T162849_582by1ts_.bkp tag=TAG20090811T162849 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 11-AUG-09
Starting restore at 11-AUG-09
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: restoring SPFILE
output filename=+dg1/spfile
channel ORA_DISK_1: reading from backup piece /home/oracle/app/flash_recovery_area/ORA10G/backupset/2009_08_11/o1_mf_nnsnf_TAG20090811T162849_582by1ts_.bkp
channel ORA_DISK_1: restored backup piece 1
piece handle=/home/oracle/app/flash_recovery_area/ORA10G/backupset/2009_08_11/o1_mf_nnsnf_TAG20090811T162849_582by1ts_.bkp tag=TAG20090811T162849
channel ORA_DISK_1: restore complete, elapsed time: 00:00:02
Finished restore at 11-AUG-09
RMAN> exit
Recovery Manager complete.
oracle@wayne-laptop:~$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.4.0 – Production on Tue Aug 11 16:29:42 2009
Copyright (c) 1982, 2007, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 – Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> startup force nomount PFILE=”/tmp/pfile.ora”;
ORACLE instance started.
Total System Global Area 205520896 bytes
Fixed Size 1266584 bytes
Variable Size 100666472 bytes
Database Buffers 96468992 bytes
Redo Buffers 7118848 bytes
SQL> alter system set control_files=’+dg1/ct1.f’,'+fra/ct2.f’ scope=spfile;
System altered.
SQL> alter system set DB_RECOVERY_FILE_DEST_SIZE=2g scope=spfile;
System altered.
SQL> alter system set DB_RECOVERY_FILE_DEST=’+fra’ scope=spfile;
System altered.
SQL> shutdown immediate
ORA-01507: database not mounted
ORACLE instance shut down.
SQL> startup nomount PFILE=”/tmp/pfile.ora”;
ORACLE instance started.
Total System Global Area 205520896 bytes
Fixed Size 1266584 bytes
Variable Size 100666472 bytes
Database Buffers 96468992 bytes
Redo Buffers 7118848 bytes
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 – Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
oracle@wayne-laptop:~$ rman target /
Recovery Manager: Release 10.2.0.4.0 – Production on Tue Aug 11 16:33:18 2009
Copyright (c) 1982, 2007, Oracle. All rights reserved.
connected to target database: ora10g (not mounted)
RMAN> restore controlfile from ‘/home/oracle/app/oradata/ora10g/control03.ctl’;
Starting restore at 11-AUG-09
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK
channel ORA_DISK_1: copied control file copy
output filename=+DG1/ct1.f
output filename=+FRA/ct2.f
Finished restore at 11-AUG-09
RMAN> alter database mount;
database mounted
released channel: ORA_DISK_1
RMAN> switch database to copy;
datafile 1 switched to datafile copy “+DG1/ora10g/datafile/system.264.694628679″
datafile 2 switched to datafile copy “+DG1/ora10g/datafile/undotbs1.265.694628721″
datafile 3 switched to datafile copy “+DG1/ora10g/datafile/sysaux.266.694628757″
datafile 4 switched to datafile copy “+DG1/ora10g/datafile/users.261.694628797″
datafile 5 switched to datafile copy “+DG1/ora10g/datafile/wayne.268.694628781″
RMAN> recover database;
Starting recover at 11-AUG-09
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK
starting media recovery
media recovery complete, elapsed time: 00:00:03
Finished recover at 11-AUG-09
RMAN> run {
set newname for tempfile 1 to ‘+dg1′;
switch tempfile all;
}
2> 3> 4>
executing command: SET NEWNAME
renamed temporary file 1 to +dg1 in control file
RMAN> ALTER DATABASE OPEN;
database opened
RMAN> exit
Recovery Manager complete.
oracle@wayne-laptop:~$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.4.0 – Production on Tue Aug 11 16:39:03 2009
Copyright (c) 1982, 2007, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 – Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL>
SQL>
declare
cursor rlc is
select group# grp, thread# thr, bytes/1024 bytes_k, ‘NO’ srl
from v$log
union
select group# grp, thread# thr, bytes/1024 bytes_k, ‘YES’ srl
from v$standby_log
order by 1;
stmt varchar2(2048);
swtstmt varchar2(1024) := ‘alter system switch logfile’;
ckpstmt varchar2(1024) := ‘alter system checkpoint global’;
begin
for rlcRec in rlc loop
if (rlcRec.srl = ‘YES’) then
stmt := ‘alter database add standby logfile thread ‘ ||
rlcRec.thr || ‘ ”+DG1” size ‘ ||
rlcRec.bytes_k || ‘K’;
execute immediate stmt;
stmt := ‘alter database drop standby logfile group ‘ || rlcRec.grp;
execute immediate stmt;
else
stmt := ‘alter database add logfile thread ‘ ||
rlcRec.thr || ‘ ”+DG1” size ‘ ||
rlcRec.bytes_k || ‘K’;
execute immediate stmt;
begin
stmt := ‘alter database drop logfile group ‘ || rlcRec.grp;
dbms_output.put_line(stmt);
execute immediate stmt;
exception
when others then
execute immediate swtstmt;
execute immediate ckpstmt;
execute immediate stmt;
end;
end if;
end loop;
38 end;
39 /
PL/SQL procedure successfully completed.