oracle 数据库恢复

前端之家收集整理的这篇文章主要介绍了oracle 数据库恢复前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

因工作需要,把备份的文件恢复为数据库

注意:目标库的sid可以不一样,但是db_name必须要求一致

1.源库DBID 3583462369
select dbid from v$database;

2.将rman备份、归档和controlfile拷贝到目标库

3.将目标库启动到nomount状态()

4.rman target /

set dbid 3583462369
restore controlfile from 'D:\FTProot\bim\20170307\DMS_20170221_2468';

alter database mount;

5.确定原先的datafile的路径和名称
rman下进行

catalog start with 'D:\FTProot\bim\20170307\'; --备份文件的目录
run{
set newname for datafile 'H:\APP\ADMINISTRATOR\ORADATA\DMSDATA\DATA_BIGEXTENT.DBF' to 'D:\app\Administrator\oradata\dms\DATA_BIGEXTENT.DBF';
set newname for datafile 'H:\APP\ADMINISTRATOR\ORADATA\DMSDATA\DATA_BIGEXTENT_1.DBF' to 'D:\app\Administrator\oradata\dms\DATA_BIGEXTENT_1.DBF';
set newname for datafile 'H:\APP\ADMINISTRATOR\ORADATA\DMSDATA\DATA_BIGEXTENT_2.DBF' to 'D:\app\Administrator\oradata\dms\DATA_BIGEXTENT_2.DBF';
set newname for datafile 'H:\APP\ADMINISTRATOR\ORADATA\DMSDATA\DATA_BIGEXTENT_3.DBF' to 'D:\app\Administrator\oradata\dms\DATA_BIGEXTENT_3.DBF';
set newname for datafile 'H:\APP\ADMINISTRATOR\ORADATA\DMSDATA\DATA_BIGEXTENT_4.DBF' to 'D:\app\Administrator\oradata\dms\DATA_BIGEXTENT_4.DBF';
set newname for datafile 'H:\APP\ADMINISTRATOR\ORADATA\DMSDATA\DMS_DATA.DBF' to 'D:\app\Administrator\oradata\dms\DMS_DATA.DBF';
set newname for datafile 'H:\APP\ADMINISTRATOR\ORADATA\DMSDATA\DMS_DATA_1.DBF' to 'D:\app\Administrator\oradata\dms\DMS_DATA_1.DBF';
set newname for datafile 'H:\APP\ADMINISTRATOR\ORADATA\DMSDATA\DMS_DATA_10.DBF' to 'D:\app\Administrator\oradata\dms\DMS_DATA_10.DBF';
set newname for datafile 'H:\APP\ADMINISTRATOR\ORADATA\DMSDATA\DMS_DATA_11.DBF' to 'D:\app\Administrator\oradata\dms\DMS_DATA_11.DBF';
set newname for datafile 'H:\APP\ADMINISTRATOR\ORADATA\DMSDATA\DMS_DATA_12.DBF' to 'D:\app\Administrator\oradata\dms\DMS_DATA_12.DBF';
set newname for datafile 'H:\APP\ADMINISTRATOR\ORADATA\DMSDATA\DMS_DATA_13.DBF' to 'D:\app\Administrator\oradata\dms\DMS_DATA_13.DBF';
set newname for datafile 'H:\APP\ADMINISTRATOR\ORADATA\DMSDATA\DMS_DATA_14.DBF' to 'D:\app\Administrator\oradata\dms\DMS_DATA_14.DBF';
set newname for datafile 'H:\APP\ADMINISTRATOR\ORADATA\DMSDATA\DMS_DATA_15.DBF' to 'D:\app\Administrator\oradata\dms\DMS_DATA_15.DBF';
set newname for datafile 'H:\APP\ADMINISTRATOR\ORADATA\DMSDATA\DMS_DATA_2.DBF' to 'D:\app\Administrator\oradata\dms\DMS_DATA_2.DBF';
set newname for datafile 'H:\APP\ADMINISTRATOR\ORADATA\DMSDATA\DMS_DATA_3.DBF' to 'D:\app\Administrator\oradata\dms\DMS_DATA_3.DBF';
set newname for datafile 'H:\APP\ADMINISTRATOR\ORADATA\DMSDATA\DMS_DATA_4.DBF' to 'D:\app\Administrator\oradata\dms\DMS_DATA_4.DBF';
set newname for datafile 'H:\APP\ADMINISTRATOR\ORADATA\DMSDATA\DMS_DATA_5.DBF' to 'D:\app\Administrator\oradata\dms\DMS_DATA_5.DBF';
set newname for datafile 'H:\APP\ADMINISTRATOR\ORADATA\DMSDATA\DMS_DATA_6.DBF' to 'D:\app\Administrator\oradata\dms\DMS_DATA_6.DBF';
set newname for datafile 'H:\APP\ADMINISTRATOR\ORADATA\DMSDATA\DMS_DATA_7.DBF' to 'D:\app\Administrator\oradata\dms\DMS_DATA_7.DBF';
set newname for datafile 'H:\APP\ADMINISTRATOR\ORADATA\DMSDATA\DMS_DATA_8.DBF' to 'D:\app\Administrator\oradata\dms\DMS_DATA_8.DBF';
set newname for datafile 'H:\APP\ADMINISTRATOR\ORADATA\DMSDATA\DMS_DATA_9.DBF' to 'D:\app\Administrator\oradata\dms\DMS_DATA_9.DBF';
set newname for datafile 'H:\APP\ADMINISTRATOR\ORADATA\DMSDATA\DMS_DATA_MATERIAL.DBF' to 'D:\app\Administrator\oradata\dms\DMS_DATA_MATERIAL.DBF';
set newname for datafile 'H:\APP\ADMINISTRATOR\ORADATA\DMSDATA\DMS_DATA_MATERIAL_1.DBF' to 'D:\app\Administrator\oradata\dms\DMS_DATA_MATERIAL_1.DBF';
set newname for datafile 'H:\APP\ADMINISTRATOR\ORADATA\DMSDATA\DMS_DATA_MATERIAL_2.DBF' to 'D:\app\Administrator\oradata\dms\DMS_DATA_MATERIAL_2.DBF';
set newname for datafile 'H:\APP\ADMINISTRATOR\ORADATA\DMSDATA\DMS_DATA_MATERIAL_3.DBF' to 'D:\app\Administrator\oradata\dms\DMS_DATA_MATERIAL_3.DBF';
set newname for datafile 'H:\APP\ADMINISTRATOR\ORADATA\DMSDATA\DMS_DATA_MATERIAL_4.DBF' to 'D:\app\Administrator\oradata\dms\DMS_DATA_MATERIAL_4.DBF';
set newname for datafile 'H:\APP\ADMINISTRATOR\ORADATA\DMSDATA\DMS_DATA_MATERIAL_5.DBF' to 'D:\app\Administrator\oradata\dms\DMS_DATA_MATERIAL_5.DBF';
set newname for datafile 'H:\APP\ADMINISTRATOR\ORADATA\DMSDATA\DMS_DATA_MATERIAL_6.DBF' to 'D:\app\Administrator\oradata\dms\DMS_DATA_MATERIAL_6.DBF';
set newname for datafile 'H:\APP\ADMINISTRATOR\ORADATA\DMSDATA\DMS_DATA_MATERIAL_7.DBF' to 'D:\app\Administrator\oradata\dms\DMS_DATA_MATERIAL_7.DBF';
set newname for datafile 'H:\APP\ADMINISTRATOR\ORADATA\DMSDATA\DMS_INDX.DBF' to 'D:\app\Administrator\oradata\dms\DMS_INDX.DBF';
set newname for datafile 'H:\APP\ADMINISTRATOR\ORADATA\DMSDATA\DMS_INDX_1.DBF' to 'D:\app\Administrator\oradata\dms\DMS_INDX_1.DBF';
set newname for datafile 'H:\APP\ADMINISTRATOR\ORADATA\DMSDATA\DMS_INDX_10.DBF' to 'D:\app\Administrator\oradata\dms\DMS_INDX_10.DBF';
set newname for datafile 'H:\APP\ADMINISTRATOR\ORADATA\DMSDATA\DMS_INDX_11.DBF' to 'D:\app\Administrator\oradata\dms\DMS_INDX_11.DBF';
set newname for datafile 'H:\APP\ADMINISTRATOR\ORADATA\DMSDATA\DMS_INDX_2.DBF' to 'D:\app\Administrator\oradata\dms\DMS_INDX_2.DBF';
set newname for datafile 'H:\APP\ADMINISTRATOR\ORADATA\DMSDATA\DMS_INDX_3.DBF' to 'D:\app\Administrator\oradata\dms\DMS_INDX_3.DBF';
set newname for datafile 'H:\APP\ADMINISTRATOR\ORADATA\DMSDATA\DMS_INDX_4' to 'D:\app\Administrator\oradata\dms\DMS_INDX_4';
set newname for datafile 'H:\APP\ADMINISTRATOR\ORADATA\DMSDATA\DMS_INDX_5.DBF' to 'D:\app\Administrator\oradata\dms\DMS_INDX_5.DBF';
set newname for datafile 'H:\APP\ADMINISTRATOR\ORADATA\DMSDATA\DMS_INDX_6.DBF' to 'D:\app\Administrator\oradata\dms\DMS_INDX_6.DBF';
set newname for datafile 'H:\APP\ADMINISTRATOR\ORADATA\DMSDATA\DMS_INDX_7.DBF' to 'D:\app\Administrator\oradata\dms\DMS_INDX_7.DBF';
set newname for datafile 'H:\APP\ADMINISTRATOR\ORADATA\DMSDATA\DMS_INDX_8.DBF' to 'D:\app\Administrator\oradata\dms\DMS_INDX_8.DBF';
set newname for datafile 'H:\APP\ADMINISTRATOR\ORADATA\DMSDATA\DMS_INDX_9.DBF' to 'D:\app\Administrator\oradata\dms\DMS_INDX_9.DBF';
set newname for datafile 'H:\APP\ADMINISTRATOR\ORADATA\DMSDATA\DMS_TEST.DBF' to 'D:\app\Administrator\oradata\dms\DMS_TEST.DBF';
set newname for datafile 'H:\APP\ADMINISTRATOR\ORADATA\DMSDATA\DMS_TESTINDX.DBF' to 'D:\app\Administrator\oradata\dms\DMS_TESTINDX.DBF';
set newname for datafile 'H:\APP\ADMINISTRATOR\ORADATA\DMSDATA\LAB_DATA.DBF' to 'D:\app\Administrator\oradata\dms\LAB_DATA.DBF';
set newname for datafile 'H:\APP\ADMINISTRATOR\ORADATA\DMSDATA\LAB_INDEX.DBF' to 'D:\app\Administrator\oradata\dms\LAB_INDEX.DBF';
set newname for datafile 'H:\APP\ADMINISTRATOR\ORADATA\DMS\SYSAUX01.DBF' to 'D:\app\Administrator\oradata\dms\SYSAUX01.DBF';
set newname for datafile 'H:\APP\ADMINISTRATOR\ORADATA\DMS\SYSTEM01.DBF' to 'D:\app\Administrator\oradata\dms\SYSTEM01.DBF';
set newname for datafile 'H:\APP\ADMINISTRATOR\ORADATA\DMS\UNDOTBS01.DBF' to 'D:\app\Administrator\oradata\dms\UNDOTBS01.DBF';
set newname for datafile 'H:\APP\ADMINISTRATOR\ORADATA\DMS\USERS01.DBF' to 'D:\app\Administrator\oradata\dms\USERS01.DBF';
restore database;
switch datafile all;
}

6.等上一步执行完后在sqlplus下执行下边脚本
redolog:
alter database rename file 'H:\APP\ADMINISTRATOR\ORADATA\DMS\REDO06.LOG' to 'D:\app\Administrator\oradata\dms\REDO06.LOG';
alter database rename file 'H:\APP\ADMINISTRATOR\ORADATA\DMS\REDO04.LOG' to 'D:\app\Administrator\oradata\dms\REDO04.LOG';
alter database rename file 'H:\APP\ADMINISTRATOR\ORADATA\DMS\REDO05.LOG' to 'D:\app\Administrator\oradata\dms\REDO05.LOG';


7.继续回到rman下执行:

recover database;
alter database open resetlogs;

recover database时候出现错误,如下:

RMAN-03002: recover 命令 (在 03/22/2017 19:04:28 上) 失败
RMAN-06054: 介质恢复正在请求未知的线程 1 序列 137423 的归档日志以及起始 SCN 25475181431



RMAN> recover database until sequence 137423;

启动 recover 于 22-3月 -17
使用通道 ORA_DISK_1

正在开始介质的恢复
介质恢复完成,用时: 00:00:02

完成 recover 于 22-3月 -17

RMAN> alter database open resetlogs;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: alter db 命令 (在 03/22/2017 19:19:40 上) 失败
ORA-01092: ORACLE instance terminated. Disconnection forced
ORA-00704: bootstrap process failure
ORA-39700: database must be opened with UPGRADE option
进程 ID: 7756
会话 ID: 185 序列号: 9
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
ORA-03114: 未连接到 ORACLE
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: alter db 命令 (在 03/22/2017 19:19:40 上) 失败
ORA-01092: ORACLE instance terminated. Disconnection forced
ORA-00704: bootstrap process failure
ORA-39700: database must be opened with UPGRADE option

进程 ID: 7756
会话 ID: 185 序列号: 9

C:\Users\bim>

sql> !oerr ora 39700
39700,00000,"database must be opened with UPGRADE option"
// *Cause: A normal database open was attempted,but the database has not
// been upgraded to the current server version.
// *Action: Use the UPGRADE option when opening the database to run
// catupgrd.sql (for database upgrade),or to run catalog.sql
// and catproc.sql (after initial database creation).
说明需要运行这些数据字典脚本,主要原因是升级以后数据字典的一些基表的内容修改

C:\>sqlplus / as sysdba

sql*Plus: Release 11.2.0.3.0 Production on 星期四 11月 28 16:06:03 2013

Copyright (c) 1982,2011,Oracle. All rights reserved.

已连接到空闲例程。

sql> startup upgrade
ORACLE 例程已经启动。

Total System Global Area 860160000 bytes
Fixed Size 2260040 bytes
Variable Size 234881976 bytes
Database Buffers 616562688 bytes
Redo Buffers 6455296 bytes
数据库装载完毕。
数据库已经打开。
sql>
方法1:
-- CATalog UPGraDe to the new release:
This script is to be used for upgrading an 8.1.7,9.0.1,9.2 or 10.1 database to the new release. This script provides a direct upgrade path from these releases to the new Oracle release.
sql>@?/rdbms/admin/catupgrd.sql

---Creates data dictionary views.重新编译一下一些无效的对象
sql>@?/rdbms/admin/utlrp.sql

方法2:
--Creates data dictionary views.
sql>@?/rdbms/admin/catalog.sql
----Creates data dictionary views for types,stored procedures,
sql>@?/rdbms/admin/catproc.sql

sql>shutdown immediate sql>startup

原文链接:https://www.f2er.com/oracle/209972.html

猜你在找的Oracle相关文章