Chinaunix首页 | 论坛 | 博客
  • 博客访问: 230363
  • 博文数量: 59
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 592
  • 用 户 组: 普通用户
  • 注册时间: 2014-04-01 12:51
个人简介

你们都是我的客户,所以,我对你们是透明的

文章分类

全部博文(59)

文章存档

2016年(29)

2015年(30)

分类: Oracle

2016-06-23 15:26:04

1、测试表t1
SQL> select * from sa.t1;
        ID NAME
---------- ----------
         2 aa

2、备份数据库和控制文件
RMAN> backup database;
Starting backup at 23-JUN-16
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=32 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00003 name=/oradata/his/undotbs01.dbf
input datafile file number=00004 name=/oradata/his/users01.dbf
input datafile file number=00001 name=/oradata/his/system01.dbf
input datafile file number=00002 name=/oradata/his/sysaux01.dbf
channel ORA_DISK_1: starting piece 1 at 23-JUN-16
channel ORA_DISK_1: finished piece 1 at 23-JUN-16
piece handle=/oracle/app/oracle/product/11.2.0/db_1/dbs/0mr8s8mr_1_1

tag=TAG20160623T134459 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:35
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
channel ORA_DISK_1: starting piece 1 at 23-JUN-16
channel ORA_DISK_1: finished piece 1 at 23-JUN-16
piece handle=/oracle/app/oracle/product/11.2.0/db_1/dbs/0nr8s8nu_1_1

tag=TAG20160623T134459 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 23-JUN-16
RMAN>

RMAN> backup current controlfile;
Starting backup at 23-JUN-16
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
channel ORA_DISK_1: starting piece 1 at 23-JUN-16
channel ORA_DISK_1: finished piece 1 at 23-JUN-16
piece handle=/oracle/app/oracle/product/11.2.0/db_1/dbs/0or8s8o9_1_1

tag=TAG20160623T134545 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 23-JUN-16

3、查看当前时间点
SQL> select to_char(sysdate,'hh24:mi:ss') from dual;
TO_CHAR(
--------
13:46:21


4、删除测试数据
SQL> select * from sa.t1;
        ID NAME
---------- ----------
         2 aa

SQL> delete from sa.t1;
1 row deleted.

SQL> commit;
Commit complete.


关闭数据库,假装数据库起不来了。
5、开始基于时间点的不完全恢复
[oracle@test oradata]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Thu Jun 23 13:47:30 2016
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
connected to target database (not started)

nomount
RMAN> startup nomount
Oracle instance started
Total System Global Area     363266048 bytes

Fixed Size                     2253304 bytes
Variable Size                171970056 bytes
Database Buffers             184549376 bytes
Redo Buffers                   4493312 bytes

5.1恢复控制文件
RMAN> restore controlfile from  '/oracle/app/oracle/product/11.2.0/db_1/dbs/0or8s8o9_1_1';

Starting restore at 23-JUN-16
using channel ORA_DISK_1

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/oradata/his/control01.ctl
Finished restore at 23-JUN-16

5.2开始正式恢复
RMAN> alter database mount;

database mounted
released channel: ORA_DISK_1

RMAN> run{
2> set until time "to_date('2016-06-23 13:46:21','yyyy-mm-dd hh24:mi:ss')";
3> restore database;
4> recover database;
5> }

executing command: SET until clause

Starting restore at 23-JUN-16
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=19 device type=DISK

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 /oradata/his/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /oradata/his/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /oradata/his/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /oradata/his/users01.dbf
channel ORA_DISK_1: reading from backup piece

/oracle/app/oracle/product/11.2.0/db_1/dbs/0mr8s8mr_1_1
channel ORA_DISK_1: piece

handle=/oracle/app/oracle/product/11.2.0/db_1/dbs/0mr8s8mr_1_1

tag=TAG20160623T134459
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:01:05
Finished restore at 23-JUN-16

Starting recover at 23-JUN-16
using channel ORA_DISK_1

starting media recovery

archived log for thread 1 with sequence 1 is already on disk as file

/oradata/his/redo01a.log
archived log file name=/oradata/his/redo01a.log thread=1 sequence=1
media recovery complete, elapsed time: 00:00:00
Finished recover at 23-JUN-16

RMAN>

只读打开验证数据
SQL> alter database open read only;
Database altered.

SQL> select * from sa.t1;
        ID NAME
---------- ----------
         2 aa
SQL>
(t1回来了)



注:
如果要打开的话
shutdown immediate
startup mount
alter database open resetlogs;


-------------------------
好久没总结东西了。记一下
阅读(2155) | 评论(0) | 转发(0) |
0

上一篇:dg参考手册

下一篇:MaxScale

给主人留下些什么吧!~~