Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2638684
  • 博文数量: 631
  • 博客积分: 10716
  • 博客等级: 上将
  • 技术积分: 8397
  • 用 户 组: 普通用户
  • 注册时间: 2008-04-01 22:35
文章分类

全部博文(631)

文章存档

2020年(2)

2019年(22)

2018年(4)

2017年(37)

2016年(22)

2015年(1)

2013年(12)

2012年(20)

2011年(19)

2010年(20)

2009年(282)

2008年(190)

分类: Oracle

2011-07-12 10:36:51

1.思路
a.备份控制文件
b.修改控制文件位置参数
c.恢复控制文件
d.RMAN copy数据库到ASM
e.恢复数据库
f.重置temp表空间
g.重设redo log
h.检查
 
2.过程
a.备份控制文件
SQL> alter database backup controlfile to '/u01/rman/c_ldjfaoidjfal.ctl';
Database altered.
b.修改控制文件位置参数
SQL> show parameter control_files
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
control_files                        string      /u01/oradata/dblife/control01.
                                                 ctl, /u01/oradata/dblife/contr
                                                 ol02.ctl
SQL> alter system set control_files='+DATA/dblife/controlfile/control01.ctl' scope=spfile;
System altered.
c.恢复控制文件
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup nomount
ORACLE instance started.
Total System Global Area  419430400 bytes
Fixed Size                  1219736 bytes
Variable Size             138412904 bytes
Database Buffers          272629760 bytes
Redo Buffers                7168000 bytes
 
RMAN> restore controlfile to '+DATA/dblife/controlfile/control01.ctl' from '/u01/rman/c_ldjfaoidjfal.ctl';
Starting restore at 04-JUN-11
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=45 devtype=DISK
channel ORA_DISK_1: copied control file copy
Finished restore at 04-JUN-11
d.RMAN copy数据库到ASM
RMAN> alter database mount;
database mounted
released channel: ORA_DISK_1
RMAN> backup as copy database format '+DATA';
Starting backup at 04-JUN-11
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=45 devtype=DISK
channel ORA_DISK_1: starting datafile copy
input datafile fno=00001 name=/u01/oradata/dblife/system01.dbf
output filename=+DATA/dblife/datafile/system.259.752971523 tag=TAG20110604T224522 recid=5 stamp=752971543
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:25
channel ORA_DISK_1: starting datafile copy
input datafile fno=00003 name=/u01/oradata/dblife/sysaux01.dbf
output filename=+DATA/dblife/datafile/sysaux.257.752971547 tag=TAG20110604T224522 recid=6 stamp=752971565
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:25
channel ORA_DISK_1: starting datafile copy
input datafile fno=00002 name=/u01/oradata/dblife/undotbs01.dbf
output filename=+DATA/dblife/datafile/undotbs.256.752971573 tag=TAG20110604T224522 recid=7 stamp=752971578
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting datafile copy
input datafile fno=00004 name=/u01/oradata/dblife/users01.dbf
output filename=+DATA/dblife/datafile/users.265.752971581 tag=TAG20110604T224522 recid=8 stamp=752971587
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15
Finished backup at 04-JUN-11
RMAN-06497: WARNING: control file is not current, control file autobackup skipped
RMAN> switch database to copy;
datafile 1 switched to datafile copy "+DATA/dblife/datafile/system.259.752971523"
datafile 2 switched to datafile copy "+DATA/dblife/datafile/undotbs.256.752971573"
datafile 3 switched to datafile copy "+DATA/dblife/datafile/sysaux.257.752971547"
datafile 4 switched to datafile copy "+DATA/dblife/datafile/users.265.752971581"
 
e.恢复数据库
RMAN> recover database;
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
RMAN> alter database open resetlogs;
database opened
 
f.重置temp表空间
SQL> select name from v$tempfile;
NAME
--------------------------------------------------------------------------------
/u01/oradata/dblife/temp01.dbf
SQL> alter tablespace temp add tempfile '+DATA';
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.264.752972535
 
g.重设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.260.752973041
+DATA/dblife/onlinelog/group_2.263.752972943
+DATA/dblife/onlinelog/group_3.262.752972959
h.检查数据库
SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
+DATA/dblife/datafile/system.259.752971523
+DATA/dblife/datafile/undotbs.256.752971573
+DATA/dblife/datafile/sysaux.257.752971547
+DATA/dblife/datafile/users.265.752971581
SQL> select name from v$controlfile;
NAME
--------------------------------------------------------------------------------
+DATA/dblife/controlfile/control01.ctl
SQL> select name from v$tempfile;
NAME
--------------------------------------------------------------------------------
+DATA/dblife/tempfile/temp.264.752972535
阅读(1500) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~