1.思路
a.RMAN备份数据库
b.修改参数文件
c.恢复控制文件
d.恢复数据库
e.重置temp文件
f.重设redo log
2.过程
a.RMAN备份
$ rman target /
RMAN> show all;
using target database control file instead of recovery catalog
RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/10.2.0/db_1/dbs/snapcf_dblife.f'; # default
RMAN> CONFIGURE BACKUP OPTIMIZATION ON;
new RMAN configuration parameters:
CONFIGURE BACKUP OPTIMIZATION ON;
new RMAN configuration parameters are successfully stored
RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters are successfully stored
RMAN> CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u01/rman/%F';
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u01/rman/%F';
new RMAN configuration parameters are successfully stored
RMAN> backup database format '/u01/rman/full_%u.bak';
Starting backup at 04-JUN-11
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=37 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/u01/oradata/dblife/system01.dbf
input datafile fno=00003 name=/u01/oradata/dblife/sysaux01.dbf
input datafile fno=00002 name=/u01/oradata/dblife/undotbs01.dbf
input datafile fno=00004 name=/u01/oradata/dblife/users01.dbf
channel ORA_DISK_1: starting piece 1 at 04-JUN-11
channel ORA_DISK_1: finished piece 1 at 04-JUN-11
piece handle=/u01/rman/full_01me2k2s.bak tag=TAG20110604T203436 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:35
Finished backup at 04-JUN-11
Starting Control File and SPFILE Autobackup at 04-JUN-11
piece handle=/u01/rman/c-535101028-20110604-00 comment=NONE
Finished Control File and SPFILE Autobackup at 04-JUN-11
RMAN> sql 'create pfile from spfile';
sql statement: create pfile from spfile
修改参数文件
vi initdblife.ora
*.control_files='+DATA/dblife/controlfile/control01.ctl','+DATA/dblife/controlfile/control02.ctl'
SQL> create spfile from pfile;
File created.
恢复控制文件
RMAN> shutdown immediate
database closed
database dismounted
Oracle instance shut down
RMAN> startup nomount
connected to target database (not started)
Oracle instance started
Total System Global Area 419430400 bytes
Fixed Size 1219736 bytes
Variable Size 130024296 bytes
Database Buffers 281018368 bytes
Redo Buffers 7168000 bytes
RMAN> restore controlfile from '/u01/rman/c-535101028-20110604-02';
Starting restore at 04-JUN-11
using channel ORA_DISK_1
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:16
output filename=+DATA/dblife/controlfile/control01.ctl
output filename=+DATA/dblife/controlfile/control02.ctl
Finished restore at 04-JUN-11
恢复数据库
RMAN> alter database mount;
database mounted
released channel: ORA_DISK_1
RMAN> run {
2> set newname for datafile 1 to '+data';
3> set newname for datafile 2 to '+data';
4> set newname for datafile 3 to '+data';
5> set newname for datafile 4 to '+data';
6> set newname for tempfile 1 to '+data';
7> restore database;
8> recover database;
9> switch datafile all;
10> }
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting restore at 04-JUN-11
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=46 devtype=DISK
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to +DATA
restoring datafile 00002 to +DATA
restoring datafile 00003 to +DATA
restoring datafile 00004 to +DATA
channel ORA_DISK_1: reading from backup piece /u01/rman/full_05me2n8m.bak
channel ORA_DISK_1: restored backup piece 1
piece handle=/u01/rman/full_05me2n8m.bak tag=TAG20110604T212854
channel ORA_DISK_1: restore complete, elapsed time: 00:00:35
Finished restore at 04-JUN-11
Starting recover at 04-JUN-11
using channel ORA_DISK_1
starting media recovery
archive log thread 1 sequence 1 is already on disk as file /u01/oradata/dblife/redo1_1.rdo
archive log filename=/u01/oradata/dblife/redo1_1.rdo thread=1 sequence=1
media recovery complete, elapsed time: 00:00:01
Finished recover at 04-JUN-11
datafile 1 switched to datafile copy
input datafile copy recid=9 stamp=752967289 filename=+DATA/dblife/datafile/system.262.752967253
datafile 2 switched to datafile copy
input datafile copy recid=10 stamp=752967289 filename=+DATA/dblife/datafile/undotbs.264.752967253
datafile 3 switched to datafile copy
input datafile copy recid=11 stamp=752967289 filename=+DATA/dblife/datafile/sysaux.263.752967253
datafile 4 switched to datafile copy
input datafile copy recid=12 stamp=752967289 filename=+DATA/dblife/datafile/users.265.752967253
RMAN> alter database open resetlogs;
database opened
查看恢复到ASM上的文件
$ asmcmd
ASMCMD> ls
DATA/
ASMCMD> cd data
ASMCMD> ls
DBLIFE/
ASMCMD> cd dblife
ASMCMD> ls
CONTROLFILE/
DATAFILE/
ASMCMD> ls controlfile
Current.261.752965739
control01.ctl
control02.ctl
current.260.752965745
ASMCMD> ls datafile
SYSAUX.263.752967253
SYSTEM.262.752967253
UNDOTBS.264.752967253
USERS.265.752967253
SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
+DATA/dblife/datafile/system.262.752967253
+DATA/dblife/datafile/undotbs.264.752967253
+DATA/dblife/datafile/sysaux.263.752967253
+DATA/dblife/datafile/users.265.752967253
SQL> select name from v$controlfile;
NAME
--------------------------------------------------------------------------------
+DATA/dblife/controlfile/control01.ctl
+DATA/dblife/controlfile/control02.ctl
SQL> select name from v$tempfile;
NAME
--------------------------------------------------------------------------------
/u01/oradata/dblife/temp01.dbf
重置临时表空间
SQL> alter tablespace temp add tempfile '+data' size 100m;
Tablespace altered.
SQL> alter tablespace temp drop tempfile '/u01/oradata/dblife/temp01.dbf';
Tablespace altered.
SQL> select name from v$tempfile;
NAME
--------------------------------------------------------------------------------
+DATA/dblife/tempfile/temp.256.752967701
重建redo log
SQL> select member from v$logfile;
MEMBER
--------------------------------------------------------------------------------
/u01/oradata/dblife/redo1_1.rdo
/u01/oradata/dblife/redo1_2.rdo
/u01/oradata/dblife/redo2_1.rdo
/u01/oradata/dblife/redo2_2.rdo
/u01/oradata/dblife/redo3_1.rdo
/u01/oradata/dblife/redo3_2.rdo
6 rows selected.
SQL> set linesize 100
SQL> select * from v$log;
GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIM
---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------
1 1 1 20971520 2 NO CURRENT 228140 04-JUN-11
2 1 0 20971520 2 YES UNUSED 0
3 1 0 20971520 2 YES UNUSED 0
SQL> alter database drop logfile group 2;
Database altered.
SQL> alter database add logfile group 2 '+data' size 50m;
Database altered.
SQL> alter database drop logfile group 3;
Database altered.
SQL> alter database add logfile group 3 '+data' size 50m;
Database altered.
SQL> alter system switch logfile;
System altered.
SQL> /
System altered.
SQL> alter system checkpoint;
System altered.
SQL> select * from v$log;
GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIM
---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------
1 1 7 20971520 2 YES INACTIVE 229878 04-JUN-11
2 1 8 52428800 1 YES INACTIVE 229891 04-JUN-11
3 1 9 52428800 1 NO CURRENT 229910 04-JUN-11
SQL> alter database drop logfile group 1;
Database altered.
SQL> alter database add logfile group 1 '+data' size 50m;
Database altered.
SQL> select member from v$logfile;
MEMBER
----------------------------------------------------------------------------------------------------
+DATA/dblife/onlinelog/group_1.258.752968127
+DATA/dblife/onlinelog/group_2.257.752967913
+DATA/dblife/onlinelog/group_3.259.752967955
迁移完成!
阅读(1301) | 评论(0) | 转发(0) |