ITPub博客

首页 > 数据库 > MySQL > NBU恢复所有数据库的文件

NBU恢复所有数据库的文件

原创 MySQL 作者:startno 时间:2012-05-03 20:52:03 0 删除 编辑

一,看数据状态

SQL> startup

ORACLE instance started.

Total System Global Area 285212672 bytes

Fixed Size 1273276 bytes

Variable Size 92275268 bytes

Database Buffers 188743680 bytes

Redo Buffers 2920448 bytes

Database mounted.

Database opened.

SQL> !

二删除数据库所有文件

oracle.oracle10-> pwd

/home/oracle

oracle.oracle10-> cd /u01/app/oracle/oradata/wislon

oracle.oracle10-> ll

total 1071472

-rw-r----- 1 oracle oinstall 7061504 May 3 19:23 control01.ctl

-rw-r----- 1 oracle oinstall 7061504 May 3 19:23 control02.ctl

-rw-r----- 1 oracle oinstall 7061504 May 3 19:23 control03.ctl

-rw-r----- 1 oracle oinstall 104865792 May 3 19:18 example01.dbf

-rw-r----- 1 oracle oinstall 52429312 May 3 19:18 redo01.log

-rw-r----- 1 oracle oinstall 52429312 May 3 19:18 redo02.log

-rw-r----- 1 oracle oinstall 52429312 May 3 19:18 redo03.log

-rw-r----- 1 oracle oinstall 272637952 May 3 19:18 sysaux01.dbf

-rw-r----- 1 oracle oinstall 471867392 May 3 19:18 system01.dbf

-rw-r----- 1 oracle oinstall 20979712 Apr 28 10:23 temp01.dbf

-rw-r----- 1 oracle oinstall 10493952 May 3 19:18 u01.dbf

-rw-r----- 1 oracle oinstall 31465472 May 3 19:18 undotbs01.dbf

-rw-r----- 1 oracle oinstall 5251072 May 3 19:18 users01.dbf

oracle.oracle10-> rm -rf *

oracle.oracle10-> ll 所有文件都没有了

total 0

oracle.oracle10-> exit

exit

三重启数据库,找不到控制文件

SQL> shutdown immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> startup

ORACLE instance started.

Total System Global Area 285212672 bytes

Fixed Size 1273276 bytes

Variable Size 92275268 bytes

Database Buffers 188743680 bytes

Redo Buffers 2920448 bytes

ORA-00205: error in identifying control file, check alert log for more info

SQL> !

四,在NBU Master Server上用下面的命令来查看磁带上的备份信息

[root@master ~]# bplist -S master -C oracle10 -t 4 -R -l /

-rw-rw---- oracle oinstall 7340032 May 03 19:01 /cntrl_51_1_782334102 控制文件

-rw-rw---- oracle oinstall 262144 May 03 19:01 /al_50_1_782334061

-rw-rw---- oracle oinstall 6291456 May 03 19:00 /al_48_1_782334025

-rw-rw---- oracle oinstall 11010048 May 03 19:00 /al_49_1_782334025

-rw-rw---- oracle oinstall 262144 May 03 18:59 /bk_1170389824_47_1_782333972

-rw-rw---- oracle oinstall 7340032 May 03 18:58 /bk_1170389824_46_1_782333927

-rw-rw---- oracle oinstall 385875968 May 03 18:57 /bk_1170389824_44_1_782333872

-rw-rw---- oracle oinstall 294912000 May 03 18:57 /bk_1170389824_45_1_782333872

-rw-rw---- oracle oinstall 7077888 Apr 27 16:17 /al_6_1_781719465

-rw-rw---- oracle oinstall 262144 Apr 27 16:17 /al_5_1_781719465

-rw-rw---- oracle oinstall 262144 Apr 27 16:17 /bk_1171790800_4_1_781719423

-rw-rw---- oracle oinstall 7340032 Apr 27 16:16 /bk_1171790800_3_1_781719368

-rw-rw---- oracle oinstall 383778816 Apr 27 16:15 /bk_1171790800_1_1_781719303

-rw-rw---- oracle oinstall 267386880 Apr 27 16:15 /bk_1171790800_2_1_781719303

[root@master ~]#

五,在数据库所在的服务器上运行RMAN来恢复控制文件

SQL> shutdown immediate

ORACLE instance shut down.

oracle.oracle10-> rman target /

Recovery Manager: Release 10.2.0.5.0 - Production on Thu May 3 19:46:21 2012

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

connected to target database (not started)

RMAN> set dbid=1170389824 DBID是在NBU备份脚本中的FORMAT ‘bk_%I 这个是在RMAN备份集中加入数据库的DBID

executing command: SET DBID

RMAN> RUN{

2> ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE';

3> SEND 'NB_ORA_SERV=master,NB_ORA_CLIENT=oracle10';

4> restore controlfile from 'cntrl_51_1_782334102';

5> RELEASE CHANNEL ch00;

6> }

using target database control file instead of recovery catalog

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-03002: failure of allocate command at 05/03/2012 19:47:48

RMAN-06403: could not obtain a fully authorized session

ORA-01034: ORACLE not available

ORA-27101: shared memory realm does not exist

Linux Error: 2: No such file or directory

RMAN> sql'startup nomount';

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-03002: failure of sql command at 05/03/2012 19:48:34

RMAN-06403: could not obtain a fully authorized session

ORA-01034: ORACLE not available

ORA-27101: shared memory realm does not exist

Linux Error: 2: No such file or directory

RMAN> startup

Oracle instance started

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-03002: failure of startup command at 05/03/2012 19:48:40

ORA-00205: error in identifying control file, check alert log for more info

RMAN>

RMAN>

RMAN> RUN{

2> ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE';

3> SEND 'NB_ORA_SERV=master,NB_ORA_CLIENT=oracle10';

4> restore controlfile from 'cntrl_51_1_782334102';

5> RELEASE CHANNEL ch00;

6> }

allocated channel: ch00

channel ch00: sid=156 devtype=SBT_TAPE

channel ch00: Veritas NetBackup for Oracle - Release 6.5 (2007072323)

sent command to channel: ch00

Starting restore at 03-MAY-12

channel ch00: restoring control file

channel ch00: restore complete, elapsed time: 00:00:45

output filename=/u01/app/oracle/oradata/wislon/control01.ctl

output filename=/u01/app/oracle/oradata/wislon/control02.ctl

output filename=/u01/app/oracle/oradata/wislon/control03.ctl

Finished restore at 03-MAY-12

released channel: ch00

六,启动数据库到MOUNT状态,查看RMAN的备份集情况

RMAN> sql 'alter database mount';

sql statement: alter database mount

RMAN> list backup;

List of Backup Sets

===================

BS Key Type LV Size Device Type Elapsed Time Completion Time

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

21 Incr 0 279.00M SBT_TAPE 00:00:54 26-APR-12

BP Key: 21 Status: AVAILABLE Compressed: NO Tag: HOT_DB_BK_LEVEL0

Handle: bk_34_1_781622630 Media:

List of Datafiles in backup set 21

File LV Type Ckp SCN Ckp Time Name

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

2 0 Incr 482800 26-APR-12 /u01/app/oracle/oradata/wislon/undotbs01.dbf

3 0 Incr 482800 26-APR-12 /u01/app/oracle/oradata/wislon/sysaux01.dbf

5 0 Incr 482800 26-APR-12 /u01/app/oracle/oradata/wislon/example01.dbf

BS Key Type LV Size Device Type Elapsed Time Completion Time

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

22 Incr 0 367.50M SBT_TAPE 00:01:36 26-APR-12

BP Key: 22 Status: AVAILABLE Compressed: NO Tag: HOT_DB_BK_LEVEL0

Handle: bk_33_1_781622630 Media:

List of Datafiles in backup set 22

File LV Type Ckp SCN Ckp Time Name

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

[@more@]

七,恢复数据库数据文件

RMAN> RUN{

2> ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE';

3> SEND 'NB_ORA_SERV=master,NB_ORA_CLIENT=oracle10';

4> restore database;

5> RELEASE CHANNEL ch00;

6> }

allocated channel: ch00

channel ch00: sid=156 devtype=SBT_TAPE

channel ch00: Veritas NetBackup for Oracle - Release 6.5 (2007072323)

sent command to channel: ch00

Starting restore at 03-MAY-12

creating datafile fno=9 name=/u01/app/oracle/oradata/wislon/u011.dbf

channel ch00: starting datafile backupset restore

channel ch00: specifying datafile(s) to restore from backup set

restoring datafile 00002 to /u01/app/oracle/oradata/wislon/undotbs01.dbf

restoring datafile 00003 to /u01/app/oracle/oradata/wislon/sysaux01.dbf

restoring datafile 00005 to /u01/app/oracle/oradata/wislon/example01.dbf

channel ch00: reading from backup piece bk_1170389824_45_1_782333872

channel ch00: restored backup piece 1

piece handle=bk_1170389824_45_1_782333872 tag=HOT_DB_BK_LEVEL0

channel ch00: restore complete, elapsed time: 00:00:55

channel ch00: starting datafile backupset restore

channel ch00: specifying datafile(s) to restore from backup set

restoring datafile 00001 to /u01/app/oracle/oradata/wislon/system01.dbf

restoring datafile 00004 to /u01/app/oracle/oradata/wislon/users01.dbf

restoring datafile 00008 to /u01/app/oracle/oradata/wislon/u01.dbf

channel ch00: reading from backup piece bk_1170389824_44_1_782333872

channel ch00: restored backup piece 1

piece handle=bk_1170389824_44_1_782333872 tag=HOT_DB_BK_LEVEL0

channel ch00: restore complete, elapsed time: 00:00:55

Finished restore at 03-MAY-12

released channel: ch00

RMAN>

RMAN>

八,对数据文件进行RECOVER

RMAN> RUN{

2> ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE';

3> SEND 'NB_ORA_SERV=master,NB_ORA_CLIENT=oracle10';

4> recover database;

5> RELEASE CHANNEL ch00;

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/23862439/viewspace-1058117/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2012-05-02

  • 博文量
    24
  • 访问量
    88112