|
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。如果您注册时有任何问题请联系客服QQ: 83569622 。
您需要 登录 才可以下载或查看,没有帐号?注册
x
一,环境和需求
1,PROD的环境是这样的(archivelog)
[oraprod@fin01 oraprod]$ ls /u01/oracle/proddata/
a_archive01.dbf a_ref01.dbf a_txn_data04.dbf cntrl01.dbf log01a.dbf logPROD03a.ora system02.dbf system08.dbf
a_int01.dbf a_ref02.dbf a_txn_ind01.dbf cntrl02.dbf log01b.dbf odm.dbf system03.dbf system09.dbf
a_media01.dbf a_summ01.dbf a_txn_ind02.dbf cntrl03.dbf log02a.dbf olap.dbf system04.dbf system10.dbf
a_nolog01.dbf a_txn_data01.dbf a_txn_ind03.dbf ctxd01.dbf log02b.dbf owad01.dbf system05.dbf system11.dbf
a_queue01.dbf a_txn_data02.dbf a_txn_ind04.dbf cuxd01.dbf logPROD01a.ora portal01.dbf system06.dbf temp01.dbf
a_queue02.dbf a_txn_data03.dbf a_txn_ind05.dbf cuxx01.dbf logPROD02a.ora system01.dbf system07.dbf undo01.dbf
2, TEST的环境是这样的(一个新安装的的9i数据库)
[oracle@file01 dbs]$ ls /u02/oradata/
control01.ctl control03.ctl drsys01.dbf indx01.dbf redo01.log redo03.log temp01.dbf undotbs01.dbf xdb01.dbf
control02.ctl cwmlite01.dbf example01.dbf odm01.dbf redo02.log system01.dbf tools01.dbf users01.dbf
3, 现在的需求是将PROD 16号凌晨的一次全备份恢复到TEST,并应用16一天产生的归档日志。
16号一天产生的归档日志有这些:
arch1_7296.dbf
arch1_7297.dbf
arch1_7298.dbf
arch1_7299.dbf
arch1_7300.dbf
arch1_7301.dbf
arch1_7302.dbf
arch1_7303.dbf
arch1_7304.dbf
arch1_7305.dbf
二,操作步骤
1,在PROD环境里生成控制文件的sql
alter database backup controlfile to trace;
2,修改trace生成的控制文件生成crctl.sql,使其与TEST的数据目录、SID对应:
CREATE CONTROLFILE SET DATABASE "TEST9I" RESETLOGS NOARCHIVELOG
-- SET STANDBY TO MAXIMIZE PERFORMANCE
MAXLOGFILES 32
MAXLOGMEMBERS 5
MAXDATAFILES 512
MAXINSTANCES 8
MAXLOGHISTORY 7260
LOGFILE
GROUP 3 '/u01/app/oracle/oradata/test9i/logtest01a.ora' SIZE 50M,
GROUP 4 '/u01/app/oracle/oradata/test9i/logtest02a.ora' SIZE 50M,
GROUP 5 '/u01/app/oracle/oradata/test9i/logtest03a.ora' SIZE 50M
-- STANDBY LOGFILE
DATAFILE
'/u01/app/oracle/oradata/test9i/system01.dbf',
'/u01/app/oracle/oradata/test9i/system02.dbf',
'/u01/app/oracle/oradata/test9i/system03.dbf',
'/u01/app/oracle/oradata/test9i/system04.dbf',
'/u01/app/oracle/oradata/test9i/system05.dbf',
'/u01/app/oracle/oradata/test9i/ctxd01.dbf',
'/u01/app/oracle/oradata/test9i/owad01.dbf',
'/u01/app/oracle/oradata/test9i/a_queue02.dbf',
'/u01/app/oracle/oradata/test9i/odm.dbf',
'/u01/app/oracle/oradata/test9i/olap.dbf',
'/u01/app/oracle/oradata/test9i/cuxd01.dbf',
'/u01/app/oracle/oradata/test9i/cuxx01.dbf',
'/u01/app/oracle/oradata/test9i/system10.dbf',
'/u01/app/oracle/oradata/test9i/system06.dbf',
'/u01/app/oracle/oradata/test9i/portal01.dbf',
'/u01/app/oracle/oradata/test9i/system07.dbf',
'/u01/app/oracle/oradata/test9i/system09.dbf',
'/u01/app/oracle/oradata/test9i/system08.dbf',
'/u01/app/oracle/oradata/test9i/system11.dbf',
'/u01/app/oracle/oradata/test9i/undo01.dbf',
'/u01/app/oracle/oradata/test9i/a_txn_data01.dbf',
'/u01/app/oracle/oradata/test9i/a_txn_ind01.dbf',
'/u01/app/oracle/oradata/test9i/a_ref01.dbf',
'/u01/app/oracle/oradata/test9i/a_int01.dbf',
'/u01/app/oracle/oradata/test9i/a_summ01.dbf',
'/u01/app/oracle/oradata/test9i/a_nolog01.dbf',
'/u01/app/oracle/oradata/test9i/a_archive01.dbf',
'/u01/app/oracle/oradata/test9i/a_queue01.dbf',
'/u01/app/oracle/oradata/test9i/a_media01.dbf',
'/u01/app/oracle/oradata/test9i/a_txn_data02.dbf',
'/u01/app/oracle/oradata/test9i/a_txn_data03.dbf',
'/u01/app/oracle/oradata/test9i/a_txn_ind02.dbf',
'/u01/app/oracle/oradata/test9i/a_txn_ind03.dbf',
'/u01/app/oracle/oradata/test9i/a_txn_ind04.dbf',
'/u01/app/oracle/oradata/test9i/a_txn_ind05.dbf',
'/u01/app/oracle/oradata/test9i/a_ref02.dbf'
CHARACTER SET UTF8
;
3,关闭TEST数据库
shutdown immediate
4, 删掉TEST的数据库文件
5,拷贝PROD的备份到TEST的数据文件目录里,删掉备份中的控制文件
6,在TEST中创建控制文件
sqlplus /nolog
startup nomount
@/home/oracle/crctl.sql
此时如果报错,意思是:db_files的数量不够
察看prod的init参数:
db_files=512
察看test的init参数:
db_files=200
修改test的参数(我test默认安装用的spfile):
alter system set db_files=512 scope=spfile;
重新创建控制文件
@/home/oracle/crctl.sql
7,mount TEST库,恢复归档日志
(1)如果此时打开test库
alter database open resetlogs;
此时如果报错:
ORA-01092: ORACLE instance terminated. Disconnection forced。
则需要修改undo_management,将auto改成manual
alter system set undo_management=manual scope=spfile;
(等数据库启动后应该删掉旧的undo表空间,新建一个undo表空间,再将undo_management改成auto,再将数据库关闭、全备、重新启动)
shutdown immediate
startup mount
(2)但是此时我们不要打开test库,而是直接修改
alter system set undo_management=manual scope=spfile;
然后关闭数据库
shutdown immediate
再mount数据库,为了下面的归档日志恢复
Startup mount
8,利用控制文件,执行不完全恢复
recover database using backup controlfile until time '2006-10-16 20:00:00';
alter database open resetlogs;
.....
Log applied.
Media recovery complete.
SQL> alter database open resetlogs;
正常已经可以打开数据库,查询历史数据,恢复Ok。
9,如果还报错,
ERROR at line 1:
ORA-01092: ORACLE instance terminated. Disconnection forced
则需要重新创建密码文件
orapwd file=/u01/proddb/9.2.0/dbs/orapw password=sys entries=500。
如果还不行可能要查看alter.log的报错信息。 |
|