单机linux删除文件恢复,【RMAN】RAC数据恢复至单机环境

查看备份集信息

RMAN> list backup;

List of Backup Sets

===================

BS Key Size Device Type Elapsed Time Completion Time

------- ---------- ----------- ------------ ---------------

18 18.50K DISK 00:00:00 17-FEB-14

BP Key: 18 Status: AVAILABLE Compressed: YES Tag: TAG20140217T133110

Piece Name: /Oracle/backup/arch_0ip0ro4u

List of Archived Logs in backup set 18

Thrd Seq Low SCN Low Time Next SCN Next Time

---- ------- ---------- --------- ---------- ---------

1 112 1482625 17-FEB-14 1482667 17-FEB-14

1 113 1482667 17-FEB-14 1482671 17-FEB-14

1 114 1482671 17-FEB-14 1482704 17-FEB-14

BS Key Type LV Size Device Type Elapsed Time Completion Time

------- ---- -- ---------- ----------- ------------ ---------------

19 Full 256.63M DISK 00:01:34 17-FEB-14

BP Key: 19 Status: AVAILABLE Compressed: YES Tag: TAG20140217T133111

Piece Name: /oracle/backup/full_0jp0ro50_1_1

List of Datafiles in backup set 19

File LV Type Ckp SCN Ckp Time Name

---- -- ---- ---------- --------- ----

1 Full 1482715 17-FEB-14 +DATA/racdb/datafile/system.279.839446279

2 Full 1482715 17-FEB-14 +DATA/racdb/datafile/sysaux.280.839446345

3 Full 1482715 17-FEB-14 +DATA/racdb/datafile/undotbs1.281.839446447

4 Full 1482715 17-FEB-14 +DATA/racdb/datafile/undotbs2.283.839446487

5 Full 1482715 17-FEB-14 +DATA/racdb/datafile/users.284.839446515

根据备份信息,恢复数据文件及数据库

RMAN> run{

2> set newname for datafile 1 to '/oracle/oradata/racdb/system01.dbf';

3> set newname for datafile 3 to '/oracle/oradata/racdb/undotbs01.dbf';

4> set newname for datafile 2 to '/oracle/oradata/racdb/sysaux01.dbf';

5> set newname for datafile 5 to '/oracle/oradata/racdb/users01.dbf';

6> set newname for datafile 4 to '/oracle/oradata/racdb/undotbs02.dbf';

7> restore database;

8> switch datafile all;

9> }

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting restore at 17-FEB-14

using channel ORA_DISK_1

channel ORA_DISK_1: starting datafile backup set restore

channel ORA_DISK_1: specifying datafile(s) to restore from backup set

channel ORA_DISK_1: restoring datafile 00001 to /oracle/oradata/racdb/system01.dbf

channel ORA_DISK_1: restoring datafile 00002 to /oracle/oradata/racdb/sysaux01.dbf

channel ORA_DISK_1: restoring datafile 00003 to /oracle/oradata/racdb/undotbs01.dbf

channel ORA_DISK_1: restoring datafile 00004 to /oracle/oradata/racdb/undotbs02.dbf

channel ORA_DISK_1: restoring datafile 00005 to /oracle/oradata/racdb/users01.dbf

channel ORA_DISK_1: reading from backup piece /oracle/backup/full_0jp0ro50_1_1

channel ORA_DISK_1: piece handle=/oracle/backup/full_0jp0ro50_1_1 tag=TAG20140217T133111

channel ORA_DISK_1: restored backup piece 1

channel ORA_DISK_1: restore complete, elapsed time: 00:01:55

Finished restore at 17-FEB-14

datafile 1 switched to datafile copy

input datafile copy RECID=6 STAMP=839771072 file name=/oracle/oradata/racdb/system01.dbf

datafile 2 switched to datafile copy

input datafile copy RECID=7 STAMP=839771072 file name=/oracle/oradata/racdb/sysaux01.dbf

datafile 3 switched to datafile copy

input datafile copy RECID=8 STAMP=839771072 file name=/oracle/oradata/racdb/undotbs01.dbf

datafile 4 switched to datafile copy

input datafile copy RECID=9 STAMP=839771072 file name=/oracle/oradata/racdb/undotbs02.dbf

datafile 5 switched to datafile copy

input datafile copy RECID=10 STAMP=839771072 file name=/oracle/oradata/racdb/users01.dbf

RMAN> run{

2> set until scn 1482715; --scn 号根据备份集信息得出

recover database;

}3> 4>

executing command: SET until clause

Starting recover at 17-FEB-14

using channel ORA_DISK_1

starting media recovery

media recovery complete, elapsed time: 00:00:00

Finished recover at 17-FEB-14

打开数据库

RMAN> sql 'alter database open resetlogs';

sql statement: alter database open resetlogs

查看redo log 信息,并删除无效日志组(节点2日志)

sys@RACDB> select THREAD#, STATUS, ENABLED from v$thread;

THREAD# STATUS ENABLED

---------- ------ --------

1 OPEN PUBLIC

2 CLOSED PUBLIC

sys@RACDB> select group# from v$log where THREAD#=2;

GROUP#

----------

3

4

删除日志组3、4

sys@RACDB> alter database disable thread 2;

Database altered.

sys@RACDB> alter database clear unarchived logfile group 3;

Database altered.

sys@RACDB> alter database drop logfile group 3;

Database altered.

查看undo表空间,并删除节点2(在此不使用)的undo表空间

sys@RACDB> show parameter undo

NAME TYPE VALUE

------------------------------------ ----------- ------------------------------

undo_management string AUTO

undo_retention integer 900

undo_tablespace string UNDOTBS1

sys@RACDB> select tablespace_name from dba_tablespaces where contents='UNDO';

TABLESPACE_NAME

------------------------------

UNDOTBS1

UNDOTBS2

sys@RACDB> drop tablespace UNDOTBS2 including contents and datafiles;

修改临时表空间

sys@RACDB> select name from v$tempfile;

NAME

----------------------------------------------------------------------------------------------------

/oracle/admin/racdb/RACDB/datafile/o1_mf_temp_9j38pmmk_.tmp

sys@RACDB> select tablespace_name from dba_tablespaces where contents='TEMPORARY';

TABLESPACE_NAME

------------------------------

TEMP

sys@RACDB> create temporary tablespace TEMP1 tempfile '/oracle/oradata/racdb/temp01.dbf' size 50M autoextend off;

Tablespace created.

sys@RACDB> alter database default temporary tablespace TEMP1;

Database altered.

sys@RACDB> drop tablespace TEMP including contents and datafiles;

Tablespace dropped.

查看监听状态并配置,编辑tnsname.ora文件。通过以下命令创建密码文件,注意密码文件的位置

[oracle@oradb1 dbs]$ orapwd file=orapwracdb1 password=oracle entries=30

附:

设置备份片

RMAN> catalog backuppiece '/oracle/backup/arch2_08p0rhm1';

cataloged backup piece

backup piece handle=/oracle/backup/arch2_08p0rhm1 RECID=4 STAMP=839766295

三、总结

在恢复过程中也遇到不少问题,起初没太仔细看备份集信息及归档日志不完全,造成scn号不准确,以至于数据库无法完成恢复。作为数据库管理人员,在对数据库操作时,请仔细核对相关信息,修改文件前最好先保留一份原始文件。详细RMAN管理语句、命令请参考oracle官方文档。

0b1331709591d260c1c78e86d0c51c18.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值