ALLSTARS_ORACLE 发表于 2017-4-15 10:00:53

求救啊!正式环境 RMAN怎么打开数据库


RMAN> resotre database;

RMAN> recover database;

Starting recover at 08-APR-13
using channel ORA_DISK_1
using channel ORA_DISK_2

starting media recovery

Oracle Error:
ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below
ORA-01152: file 1 was not restored from a sufficiently old backup
ORA-01110: data file 1: '/u01/oradata/orcl/system01.dbf'

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 04/08/2013 08:17:17
ORA-01013: user requested cancel of current operation

RMAN> alter database open resetlogs;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of alter db command at 04/08/2013 08:19:13
ORA-01152: file 1 was not restored from a sufficiently old backup
ORA-01110: data file 1: '/u01/oradata/orcl/system01.dbf'




$ mv system01.dbf system01.dbf.bak


RMAN> restore datafile 1;

Starting restore at 08-APR-13
using channel ORA_DISK_1
using channel ORA_DISK_2

skipping datafile 1; already restored to file /u01/oradata/orcl/system01.dbf
restore not done; all files readonly, offline, or already restored
Finished restore at 08-APR-13


没有冷备份。
做一次restore database要9个小时,现在只想尽快打开数据库,丢失点数据也没有关系 。

RMAN> list incarnation;


List of Database Incarnations
DB Key  Inc Key DB Name  DB ID            STATUS  Reset SCN  Reset Time
------- ------- -------- ---------------- --- ---------- ----------
1       1       ORCL     1186970342       PARENT  1          17-FEB-08
2       2       ORCL     1186970342       CURRENT 464631     04-JUL-08


是不是不应该用alter database open resetlogs?


SQL> select file#,TS#, RFILE#, STATUS ,NAME, CHECKPOINT_CHANGE# from v$datafile ;

FILE#        TS#     RFILE# STATUS  NAME                                               CHECKPOINT_CHANGE#
----- ---------- ---------- ------- -------------------------------------------------- ------------------
    1          0          1 SYSTEM  /u01/oradata/orcl/system01.dbf                             3689127636
    2          1          2 ONLINE  /u01/oradata/orcl/undotbs01.dbf                            3689119946
    3          2          3 ONLINE  /u01/oradata/orcl/sysaux01.dbf                             3689127636
    4          4          4 ONLINE  /u01/oradata/orcl/users01.dbf                              3689022893
    5         49          5 ONLINE  /u01/oradata/orcl/MP2009_01.dbf                            3689048377
    6          7          6 ONLINE  /u01/oradata/orcl/B4SPACE_01.dbf                           3689120572
    7          8          7 ONLINE  /u01/oradata/orcl/clt_stats01.dbf                          3689040988
    8         56          8 ONLINE  /u01/oradata/orcl/mtrxspace01.dbf                          3689124025
    9         10          9 ONLINE  /u01/oradata/orcl/L5MSPACE01.dbf                           3689127636
   10         20         10 ONLINE  /u01/oradata/orcl/C203SPACE_01.dbf                         3689022893
   11         22         11 ONLINE  /u01/oradata/orcl/D1SPACE_002.dbf                          3689127636

FILE#        TS#     RFILE# STATUS  NAME                                               CHECKPOINT_CHANGE#
----- ---------- ---------- ------- -------------------------------------------------- ------------------
   12         13         12 ONLINE  /u01/oradata/orcl/PBRSPACE01.dbf                           3689125518
   13         13         13 ONLINE  /u01/oradata/orcl/PBRSPACE02.dbf                           3689124025
   14         13         14 ONLINE  /u01/oradata/orcl/PBRSPACE03.dbf                           3689124025
   15         56         15 ONLINE  /u01/oradata/orcl/mtrxspace02.dbf                          3689124025
   16         45         16 ONLINE  /u01/oradata/orcl/MP2008_03.dbf                            3689121641
   17         45         17 ONLINE  /u01/oradata/orcl/MP2008_04.dbf                            3689122622
   18         45         18 ONLINE  /u01/oradata/orcl/MP2008_05.dbf                            3689124683
   19         45         19 ONLINE  /u01/oradata/orcl/MP2008_06.dbf                            3689124683
   20         56         20 ONLINE  /u01/oradata/orcl/mtrxspace03.dbf                          3689124025
   21         56         21 ONLINE  /u01/oradata/orcl/mtrxspace04.dbf                          3689124025
   22         56         22 ONLINE  /u01/oradata/orcl/mtrxspace05.dbf                          3689124025
...

FILE#        TS#     RFILE# STATUS  NAME                                               CHECKPOINT_CHANGE#
----- ---------- ---------- ------- -------------------------------------------------- ------------------
  229         75        229 ONLINE  /u02/oradata/orcl/fus2008_007.dbf_bk                       3689140179

199 rows selected.


SQL> select file#,status, CHECKPOINT_CHANGE#,name from v$datafile_header;

FILE# STATUS  CHECKPOINT_CHANGE# NAME
----- ------- ------------------ --------------------------------------------------
    1 ONLINE          3689127636 /u01/oradata/orcl/system01.dbf
    2 ONLINE          3689119946 /u01/oradata/orcl/undotbs01.dbf
    3 ONLINE          3689127636 /u01/oradata/orcl/sysaux01.dbf
    4 ONLINE          3689022893 /u01/oradata/orcl/users01.dbf
    5 ONLINE          3689048377 /u01/oradata/orcl/MP2009_01.dbf
    6 ONLINE          3689120572 /u01/oradata/orcl/B4SPACE_01.dbf
    7 ONLINE          3689040988 /u01/oradata/orcl/clt_stats01.dbf
    8 ONLINE          3689124025 /u01/oradata/orcl/mtrxspace01.dbf
    9 ONLINE          3689127636 /u01/oradata/orcl/L5MSPACE01.dbf
   10 ONLINE          3689022893 /u01/oradata/orcl/C203SPACE_01.dbf
   11 ONLINE          3689127636 /u01/oradata/orcl/D1SPACE_002.dbf
。。。

FILE# STATUS  CHECKPOINT_CHANGE# NAME
----- ------- ------------------ --------------------------------------------------
  229 ONLINE          3689140179 /u02/oradata/orcl/fus2008_007.dbf_bk

199 rows selected.




SQL> alter database open read only;
alter database open read only
*
ERROR at line 1:
ORA-16004: backup database requires recovery
ORA-01152: file 1 was not restored from a sufficiently old backup
ORA-01110: data file 1: '/u01/oradata/orcl/system01.dbf'

这个库平时不开archive log的,我只需将这个0级rman备份集恢复过来。这段时间的数据丢失了我可以想办法 。

是0级的rman,备份的脚本在这:

CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u01/RMAN/%F';
CONFIGURE DEVICE TYPE DISK PARALLELISM 2 BACKUP TYPE TO COMPRESSED BACKUPSET;
run {
crosscheck archivelog all;
delete expired archivelog all;
crosscheck backup;
delete expired backup;
allocate channel c1 type disk;
backup incremental level 0 database format '/u01/RMAN/db0%u_%s_%p.bak' filesperset 3 include current controlfile;
sql 'alter system archive log current';
backup filesperset 1 format '/u01/RMAN/arch%u_%s_%p.bak' archivelog all delete input;
release channel c1;
}
exit;
~

备份集在这:
$ ls
arch2io0s23h_82_1.bak     db00bo0qm2n_11_1.bak  db00po0r9q7_25_1.bak  db017o0rl4k_39_1.bak  db01lo0rr3c_53_1.bak  db023o0rv22_67_1.bak
arch2jo0s259_83_1.bak     db00co0qoaf_12_1.bak  db00qo0ral9_26_1.bak  db018o0rlop_40_1.bak  db01mo0rrf3_54_1.bak  db024o0rvf1_68_1.bak
c-1186970342-20130201-00  db00do0qpr2_13_1.bak  db00ro0rbpm_27_1.bak  db019o0rmcv_41_1.bak  db01no0rrhf_55_1.bak  db025o0rvp7_69_1.bak
c-1186970342-20130201-01  db00eo0qrqc_14_1.bak  db00so0rd5k_28_1.bak  db01ao0rmne_42_1.bak  db01oo0rrlm_56_1.bak  db026o0s040_70_1.bak
db001o0q4e8_1_1.bak       db00fo0qtv9_15_1.bak  db00to0reac_29_1.bak  db01bo0rn1t_43_1.bak  db01po0rs05_57_1.bak  db027o0s0dr_71_1.bak
db002o0q6ha_2_1.bak       db00go0qvu9_16_1.bak  db00uo0rf1l_30_1.bak  db01co0rngo_44_1.bak  db01qo0rsch_58_1.bak  db028o0s0tl_72_1.bak
db003o0qevt_3_1.bak       db00ho0r19j_17_1.bak  db00vo0rg7l_31_1.bak  db01do0ro08_45_1.bak  db01ro0rspq_59_1.bak  db029o0s0vc_73_1.bak
db004o0qfvu_4_1.bak       db00io0r2i2_18_1.bak  db010o0rhfr_32_1.bak  db01eo0rofn_46_1.bak  db01so0rss5_60_1.bak  db02ao0s113_74_1.bak
db005o0qhbs_5_1.bak       db00jo0r3q8_19_1.bak  db011o0rhqa_33_1.bak  db01fo0rou8_47_1.bak  db01to0rt6k_61_1.bak  db02bo0s17g_75_1.bak
db006o0qivj_6_1.bak       db00ko0r4qt_20_1.bak  db012o0rigl_34_1.bak  db01go0rpd4_48_1.bak  db01uo0rtim_62_1.bak  db02co0s1er_76_1.bak
db007o0qkm5_7_1.bak       db00lo0r5fn_21_1.bak  db013o0riju_35_1.bak  db01ho0rppf_49_1.bak  db01vo0rtlb_63_1.bak  db02do0s1gj_77_1.bak
db008o0qlr7_8_1.bak       db00mo0r6lc_22_1.bak  db014o0rjde_36_1.bak  db01io0rps4_50_1.bak  db020o0rtv6_64_1.bak  db02eo0s1mm_78_1.bak
db009o0qocu_9_1.bak       db00no0r7sa_23_1.bak  db015o0rjqd_37_1.bak  db01jo0rq86_51_1.bak  db021o0ruau_65_1.bak  db02fo0s1sf_79_1.bak
db00ao0qk3d_10_1.bak      db00oo0r937_24_1.bak  db016o0rkdu_38_1.bak  db01ko0rqkr_52_1.bak  db022o0ruml_66_1.bak  db02go0s228_80_1.bak
复制代码

ALLSTARS_ORACLE 发表于 2017-4-15 10:02:11

恢复的过程:

1.将其它机器的/u01/app 拷贝到这台机器.
2.
rman target /
set dbid=XXX
alter database nomount
recover controlfile from '/u01/RMAN/c-1186970342-20130201-00'
alter database open;
restore database
recover database;
alter database open resetlogs;



备份都在的,现在的/u01/RMAN是其它机器NFS过来的

List of Backup Sets
===================

BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
81      145.09M    DISK        00:00:00     01-FEB-13      
        BP Key: 81   Status: AVAILABLE  Compressed: YES  Tag: TAG20130201T074032
        Piece Name: /u01/RMAN/arch2io0s23h_82_1.bak

  List of Archived Logs in backup set 81
  Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
  ---- ------- ---------- --------- ---------- ---------
  1    5222    3678093807 26-JAN-13 3689145786 01-FEB-13

BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
82      7.00K      DISK        00:00:00     01-FEB-13      
        BP Key: 82   Status: AVAILABLE  Compressed: YES  Tag: TAG20130201T074032
        Piece Name: /u01/RMAN/arch2jo0s259_83_1.bak

  List of Archived Logs in backup set 82
  Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
  ---- ------- ---------- --------- ---------- ---------
  1    5223    3689145786 01-FEB-13 3689145802 01-FEB-13





就两个archive

之前没有开过归档的,就是为了用rman来备份才暂时开一下归档

好吧,如果不行的话还能否用_allow_resetlogs_corruption=true打开数据库?

RMAN> restore controlfile from '/u01/RMAN/c-1186970342-20130201-00';

Starting restore at 08-APR-13
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=541 devtype=DISK

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:16
output filename=/u01/oradata/orcl/control01.ctl
output filename=/u01/oradata/orcl/control02.ctl
output filename=/u01/oradata/orcl/control03.ctl
Finished restore at 08-APR-13

RMAN> alter database mount;

database mounted
released channel: ORA_DISK_1

RMAN> recover database until scn 3689145671;

Starting recover at 08-APR-13
Starting implicit crosscheck backup at 08-APR-13
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=541 devtype=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: sid=540 devtype=DISK
Crosschecked 80 objects
Finished implicit crosscheck backup at 08-APR-13

Starting implicit crosscheck copy at 08-APR-13
using channel ORA_DISK_1
using channel ORA_DISK_2
Finished implicit crosscheck copy at 08-APR-13

searching for all files in the recovery area
cataloging files...
no files cataloged

using channel ORA_DISK_1
using channel ORA_DISK_2

starting media recovery

unable to find archive log
archive log thread=1 sequence=5222
Oracle Error:
ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below
ORA-01152: file 1 was not restored from a sufficiently old backup
ORA-01110: data file 1: '/u01/oradata/orcl/system01.dbf'

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 04/08/2013 10:11:54
RMAN-06054: media recovery requesting unknown log: thread 1 seq 5222 lowscn 3689022893

SQL> alter database open read only ;
alter database open read only
*
ERROR at line 1:
ORA-16004: backup database requires recovery
ORA-01152: file 1 was not restored from a sufficiently old backup
ORA-01110: data file 1: '/u01/oradata/orcl/system01.dbf'


RMAN> recover database until scn 3689145671;

Starting recover at 08-APR-13
using channel ORA_DISK_1
using channel ORA_DISK_2

starting media recovery

channel ORA_DISK_1: starting archive log restore to default destination
channel ORA_DISK_1: restoring archive log
archive log thread=1 sequence=5222
channel ORA_DISK_1: reading from backup piece /u01/RMAN/arch2io0s23h_82_1.bak
channel ORA_DISK_1: restored backup piece 1
piece handle=/u01/RMAN/arch2io0s23h_82_1.bak tag=TAG20130201T074032
channel ORA_DISK_1: restore complete, elapsed time: 00:00:46
archive log filename=/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2013_04_08/o1_mf_1_5222_8p4b5371_.arc thread=1 sequence=5222
channel default: deleting archive log(s)
archive log filename=/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2013_04_08/o1_mf_1_5222_8p4b5371_.arc recid=1 stamp=812197064
media recovery complete, elapsed time: 00:00:11
Finished recover at 08-APR-13


SQL>  alter database open read only ;

Database altered.
页: [1]
查看完整版本: 求救啊!正式环境 RMAN怎么打开数据库