oracle create restore point,How to quickly restore to a clean database using Oracle’s restore point...

Applies to:Oracle database – 11gR2

Problem:

----------------------------------------------------------------------------------------------------------Often while conducting benchmarking tests, it is required to load a clean database before the start of a new run. One way to ensure a clean database is to recreate the entire database before each test run, but depending on the size of it, this approach may be very time consuming or inefficient.

Solution:

----------------------------------------------------------------------------------------------------------This article describes how to use Oracle’s flashback feature to quickly restore a database to a state that existed just before running the workload. More specifically, this article describes steps on how to use the ‘guaranteed restore points’.

Restore point:Restore point is nothing but a name associated with a timestamp or an SCN of the database. One can create either a normal restore point or a guaranteed restore point. The difference between the two is that guaranteed restore point allows you to flashback to the restore point regardless of the DB_FLASHBACK_RETENTION_TARGET initialization parameter i.e. it is always available (assuming you have enough space in the flash recovery area).

NOTE: In this article Flashback logging was not turned ON.

Guaranteed Restore point:

Prerequisites:Creating a guaranteed restore point requires the following prerequisites:

The user must have the SYSDBA system privileges

Must have created a flash recovery area

The database must be in ARCHIVELOG mode

Create a guaranteed restore point:After you have created or migrated a fresh database, first thing to do is to create a guaranteed restore point so you can flashback to it each time before you start a new workload. The steps are as under:

$> su – oracle

$> sqlplus / as sysdba;

Find out if ARCHIVELOG is enabled

SQL> select log_mode from v$database;

If step 3 shows that ARCHIVELOG is not enabled then continue else skip to step 8 below.

SQL> shutdown immediate;

SQL> startup mount;

SQL> alter database archivelog;

SQL> alter database open;

SQL> create restore point CLEAN_DB guarantee flashback database;

where CLEAN_DB is the name given to the guaranteed restore point.

Viewing the guaranteed restore point

SQL> select * from v$restore_point;

Verify the information about the newly created restore point. Also, note down the SCN# for reference and we will refer to it as “reference SCN#”

Flashback to the guaranteed restore pointNow, in order to restore your database to the guaranteed restore point, follow the steps below:

$> su – oracle

$> sqlplus / as sysdba;

SQL> select current_scn from v$database;

SQL> shutdown immediate;

SQL> startup mount;

SQL> select * from v$restore_point;

SQL> flashback database to restore point CLEAN_DB;

SQL> alter database open resetlogs;

SQL> select current_scn from v$database;

Compare the SCN# from step 9 above to the reference SCN#.

NOTE: The SCN# from step 9 above may not necessarily be the exact SCN# as the reference SCN# but it will be close enough.

References:

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

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值