recreate controlfile to restore recover datatabas like flashback

这篇具有很好参考价值的文章主要介绍了recreate controlfile to restore recover datatabas like flashback。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

PROD machine - Host computer on which the production database runs. Also denotes the ORACLE_SID of the production instance.
TEST machine - Host computer, physically distinct from the machine on which the production database runs.
TEMP - The ORACLE_SID of the instance used to access the restored database.


The backup - The set of backed up database structures (see REQUIREMENTS) used as the basis for recovering the dropped table. Once restored,  this set of structures is referred to as the partially restored database.

REQUIREMENTS
------------

The following data structures must be available from the backup:
- All system tablespace datafiles
- Depending on the release, all rollback segment/undo/sysaux tablespace datafiles
- All datafiles in which the table to recovered is stored
- Archive logs - see Note (a)


Notes:
(a) If the restored datafiles are part of a hot backup, or you wish to roll them forward, the required archivelogs must be available.

In an ideal world the partially restored database will be made available for recovery on a TEST machine. However this may not always be possible, and it may be necessary to restore to the same machine on which the 'source' (PROD) database resides. The latter is NOT RECOMMENDED as a user error in the recovery process can corrupt the production database.

If the datafiles comprising the partially restored database were in hot backup mode at the time the table was dropped, it is necessary to restore a previous backup. The reason for this is that the hot backup must be rolled forward past the 'end backup' markers (the time that the tablespaces were taken out of hot backup mode) before the database can be opened. Failure to recover
the restored datafiles past their end backup markers will result in the following error when an attempt is made to open the database:

ORA-1195 "online backup of file %s needs more recovery to be consistent"

I. RECOVERY ON A TEST MACHINE:
------------------------------

The following steps are to be used when performing recovery on a TEST machine, the assumption being that there is no instance with the ORACLE_SID "PROD" or "TEMP" already running on the TEST machine.

1. On the PROD database, connect as a privileged user and create an ASCII dump of the controlfile. For example:

SQL> connect / as sysdba
SQL> alter database backup controlfile to trace resetlogs;

A trace file will be generated in the user_dump_dest destination. Rename this trace file to ccf.sql and save it.

2. Create a directory on the TEST machine. The restored database will be located in this directory. In this example the directory is called /RESTORE. The only stipulation is that there is enough space to easily accommodate the restored database and any archivelogs required for recovery.  If filesystem space is at a premium, the archivelogs may be optionally
restored to /RESTORE as required by recovery, and removed after they have been applied.

3. Restore the backup to the /RESTORE directory.

4. Optionally, restore all archivelogs required for recovery to the /RESTORE directory.

5. Copy the init.ora file (initPROD.ora) from the PROD database to the /RESTORE directory on the TEST machine. This assumes that all database parameters are specified in only the init.ora file. If an include files (ifile) is referenced, also copy this file to /RESTORE.

6. Rename the initPROD.ora to initTEMP.ora on the TEST machine.

7. Edit the initTEMP.ora and make the following modifications:
a. control_files = /RESTORE/cntrlTEMP.dbf

b. if applicable, change any ifile references to point to the copied include file

c. log_archive% parameters should be changed to reflect the restored archivelogs:
log_archive_destination
log_archive_format
For example:
log_archive_destination=/RESTORE
log_archive_format=arch_%s.dbf

d. %dump_dest parameters should be changed to point to suitable directories

e. If audit is on, turn it off.

8. Ensure that the shell environment is set correctly. At the very least, the following environment variables must be defined:


a. ORACLE_HOME
b. ORACLE_SID (should be set to TEMP)

9. Connect as a privileged user. For example:

SQL> connect / as sysdba

10. Start the instance, specifying TEMP's init.ora:

SQL> startup nomount pfile=/RESTORE/initTEMP.ora

11. The ccf.sql file (created in Step 1) contains the syntax necessary to create a new controlfile. Copy this script to the TEST machine and edit it to save only the text between (and including) 'CREATE CONTROLFILE' and it's terminating semi-colon. Modify the following sections:

a. LOGFILE. Edit this section to reflect the names of the online logs to be created for the TEMP instance. If the PROD instance has a large number of large online log members, it is advisable to specify a reduced number of smaller log members. You MUST however specify at least two online log groups.
b. DATAFILE. Edit this section to reflect the names of the restored datafiles only.
c. Miscellaneous:
- Remove the REUSE keyword
- Optionally change the ARCHIVELOG keyword to NOARCHIVELOG (so the TEMP database will not operate in archivelog mode)

An example of the completed ccf.sql script might be:

CREATE CONTROLFILE DATABASE "PROD" RESETLOGS NOARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 2
MAXDATAFILES 20
MAXINSTANCES 1
MAXLOGHISTORY 337
LOGFILE
GROUP 1 '/RESTORE/log1PROD.dbf' SIZE 1M,
GROUP 2 '/RESTORE/log2PROD.dbf' SIZE 1M
DATAFILE
'/RESTORE/sys1PROD.dbf',
'/RESTORE/rbs1RBS.dbf',
'/RESTORE/users1PROD.dbf'
;

Then execute ccf.sql script to create control file(s).

12. Recover the database. The database is to be recovered to a time before the table was dropped. There are two options here:


a. Time-based incomplete recovery. Database recovery is stopped at the specified date and time.
b. Cancel-based incomplete recovery. Database recovery is stopped on an archivelog boundary i.e. the granularity of cance-based recovery is the archivelog.

Example of time-based recovery:

SQL> recover database until time '2010-01-10:12:00:00' using backup controlfile

In the above example, apply archivelogs as requested. Recovery will stop automatically at 12:00 on Januaru 10th, 2010.

Example of cancel-based recovery:

SQL> recover database until cancel using backup controlfile

As soon as you have applied the last desired archivelog, type CANCEL to stop recovery.-- 否则打不开

13. Open the database with the RESETLOGS option:

SQL> alter database open resetlogs;

14. Export the table(s).

15. Import the table(s) into the PROD database.

16. Once the necessary tables have been imported, the TEMP instance can be shutdown and all associated files removed. It is worthwhile verifying that the import has completed successfully before removing the TEMP instance.

II. RECOVERY ON A PRODUCTION MACHINE:
-------------------------------------

If a TEST machine is not available for performing recovery, the PROD machine can be used. It is important to exercise extreme caution when doing this. The restored database will be operate under the TEST instance as before. During this procedure the restored database's name is changed in order to avoid problems in acquisition of the mount lock.

1. Take a FULL backup of the database running against the PROD instance before performing any recovery.

2. While connected to the PROD instance, create an ASCII dump of the controlfile:

SQL> connect / as sysdba
SQL> alter database backup controlfile to trace resetlogs;

3. Create a /RESTORE directory as before (Step 2 above).

4. Restore the backup (and optionally the archivelogs) to the /RESTORE directory (Steps 3 and 4 above).

5. Create the initTEMP.ora file (Steps 5, 6, 7 above). In addition to the changes already made, modify the db_name parameter, for example: 
db_name=TEMP

6. Ensure that the shell environment is set correctly (Step 8 above):
a. ORACLE_HOME
b. ORACLE_SID (should be set to TEMP)

7. Start the TEMP instance (Steps 9, 10 above). It is critical to ensure that the correct pfile is used to start the instance.

8. Modify the ccf.sql file (Step 11 above). It is critical to ensure that the DATAFILE and LOGFILE names reference the backup location and NOT the PROD instance database's files. In addition to the changes already made, modify the first line to set the new database name, for example: 
from: CREATE CONTROLFILE DATABASE "PROD" RESETLOGS NOARCHIVELOG
to: CREATE CONTROLFILE SET DATABASE "TEMP" RESETLOGS NOARCHIVELOG

9. Recover the database (Step 12 above).

10. Open the database (Step 13 above).

11. Export the table(s).

12. Import the tables(s).

13. Cleanup the TEMP instance (Step 16 above).文章来源地址https://www.toymoban.com/news/detail-686217.html

到了这里,关于recreate controlfile to restore recover datatabas like flashback的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 华硕主板台式电脑开机后提示:Please enter setup to recover BIOS setting.Press F1 toRun SETUP 恢复bios出厂设置方法

    台式电脑开机后突然间无法进入系统,提示:Please enter setup to recover BIOS setting.Press F1 toRun SETUP 华硕主板是很多朋友装机喜欢使用的主板,大牌做工确实不错,装机量也很大,有时我们对BIOS进行了一些设置,不过却不知道如何恢复到原来的状态,那么要怎么操作才能恢复BIOS出

    2024年02月11日
    浏览(56)
  • Tomcat 运行报错 This is very likely to create a memory leak

    服务器上某个Tomcat服务运行一段时间后自动停止,查看日志输出,提示: This is very likely to create a memory leak. Stack trace of thread. 查阅资料得知,产生该异常的原因为内存溢出。 在 tomcat目录/bin 下修改 calalina.sh ,添加 JVM 启动参数: 如果遇到无法识别短横杠 - 的问题,则可以使

    2024年02月07日
    浏览(38)
  • 解决 Connection to Python debugger failed Socket closed 及 (most likely due to a circular import) 问题处理

    在debug 过程中,出现了 Connection to Python debugger failed Socket closed 错误具体报错为: Traceback (most recent call last):   File \\\"/home/Downloads/pycharm-community-2022.3.1/plugins/python-ce/helpers/pydev/pydevd.py\\\", line 45, in module     from _pydevd_bundle.pydevd_comm import CMD_SET_BREAK, CMD_SET_NEXT_STATEMENT, CMD_STEP_INTO, CMD

    2024年02月03日
    浏览(58)
  • 【Zookeeper】Unable to read additional data from client sessionid xx likely client has closed socket

    转载并且补充:【Zookeeper】Unable to read additional data from client sessionid *, likely client has closed socket 因为项目中使用到了Zookeeper,所以我自己找了些关于zk的资料学习了一下。在异步创建节点的过程中,抛出了如下问题: 异步创建节点的时候总是闪退,然后服务端报错 Unable to rea

    2024年02月04日
    浏览(45)
  • Android打造丝滑的Activity recreate重建(主题切换)过渡动画

    当应用程序支持多种语言或主题时,切换语言或主题通常需要重新启动 Activity 以重新加载配置。虽然 recreate 是一种常用的重建 Activity 方法,但它不支持像在 Activity 之间切换时那样使用过渡动画。特别是在切换 浅色/深色 主题时,由于缺乏过渡动画而显得很生硬。为了提升改

    2024年02月22日
    浏览(48)
  • It looks like you are making an HTTP request to a Hadoop IPC port. This is not the correct port for

    虚拟机:Ubuntu18.04 hadoop:hadoop3.1.3 jdk:openjdk8 在虚拟机浏览器输入localhost:9000报错如图:  具体:It looks like you are making an HTTP request to a Hadoop IPC port. This is not the correct port for the web interface on this daemon.  一开始我的hadoop两个配置文件重要代码修改如下: 修改core-site.xml文件为:

    2024年02月03日
    浏览(43)
  • golang之recover

    Go语言中的 recover 函数 在Go语言中, recover 是一个内建函数,用于从 panic 中恢复并继续执行程序。 panic 是Go语言中的异常机制,当程序发生不可恢复的错误时,会引发一个 panic 。 recover 函数用于捕获这个 panic ,并进行一些处理,以防止程序崩溃。 2.1 什么是Panic? 在Go语言中

    2024年02月13日
    浏览(35)
  • GO——recover

    定义 panic 改变程序控制流 立即停止当前函数剩余代码,调用defer 只会执行当前协程的defer recover 可以终止panic造成的程序崩溃 只能在defer中发挥作用 输出

    2024年01月25日
    浏览(37)
  • Go 语言 panic 和 recover 详解

    panic()  和  recover()  是 Go 语言中用于处理错误的两个重要函数。 panic()  函数用于中止程序并引发panic,而  recover()  函数用于捕获panic并恢复程序的执行。 panic()  函数用于中止程序并引发panic。 panic()  函数可以接收一个参数,该参数将作为panic的原因。 当发生panic时,程序

    2024年02月02日
    浏览(47)
  • Go中Panic and Recover

    什么是Panic? 在 Go 程序中处理异常情况的惯用方法是使用errors.。errors足以应对程序中出现的大多数异常情况。 **但有些情况下,程序在出现异常情况后无法继续执行。在这种情况下,我们使用 panic 提前终止程序。当函数遇到恐慌时,其执行将停止,所有延迟的函数都会被执

    2024年02月06日
    浏览(43)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包