实例讲解基于Backup Exec 2012完全备份+差异备份恢复Exchange数据库

备份

mongodump --archive=gt_ut.archive --db gt_ut2018-03-22T18:11:33.555+0800 writing gt_ut.gt_counting_data to archive 'gt_ut.archive'2018-03-22T18:11:33.558+0800 done dumping gt_ut.gt_counting_data (2 documents)

备份到文件名为gt_ut.archive的文件

今天实验了一下,如何在所有文件,包括数据文件,在线日志文件,控制文件都丢失的情况下,利用RMAN备份恢复和还原数据库。该实验的重点是用到了Dummy实例。

继上一篇介绍”从Backup Eexc
2012的完全备份+差异备份中恢复Exchange邮箱项 “,本次主要介绍从备份中还原Exchange
2010 邮箱数据库。

尝试重复执行备份

会覆盖第一次的备份文件

mongodump --archive=gt_ut.archive --db gt_ut2018-03-22T18:11:59.565+0800 writing gt_ut.gt_counting_data to archive 'gt_ut.archive'2018-03-22T18:11:59.567+0800 done dumping gt_ut.gt_counting_data (2 documents)

具体步骤如下:


立即恢复

collection中删除了一条记录后执行mongorestore,删除的行又出来了,已经存在的行报错E11000 duplicate key error

mongorestore --archive=gt_ut.archive2018-03-22T18:13:28.986+0800 preparing collections to restore from2018-03-22T18:13:29.019+0800 reading metadata for gt_ut.gt_counting_data from archive 'gt_ut.archive'2018-03-22T18:13:29.019+0800 restoring gt_ut.gt_counting_data from archive 'gt_ut.archive'2018-03-22T18:13:29.035+0800 error: E11000 duplicate key error collection: gt_ut.gt_counting_data index: _id_ dup key: { : "concurrent_test" }2018-03-22T18:13:29.035+0800 no indexes to restore2018-03-22T18:13:29.035+0800 finished restoring gt_ut.gt_counting_data (2 documents)2018-03-22T18:13:29.035+0800 done

备份数据库

场景描述

删除DB后恢复

没有任何异常恢复成功

mongorestore --archive=gt_ut.archive2018-03-22T18:15:19.419+0800 preparing collections to restore from2018-03-22T18:15:19.439+0800 reading metadata for gt_ut.gt_counting_data from archive 'gt_ut.archive'2018-03-22T18:15:19.504+0800 restoring gt_ut.gt_counting_data from archive 'gt_ut.archive'2018-03-22T18:15:19.517+0800 no indexes to restore2018-03-22T18:15:19.517+0800 finished restoring gt_ut.gt_counting_data (2 documents)2018-03-22T18:15:19.517+0800 done
[oracle@node2 ~]$ rman target /

Recovery Manager: Release 11.2.0.4.0 - Production on Mon May 25 23:25:51 2015

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to target database: TEST (DBID=2176055307)

RMAN> backup database;

Starting backup at 25-MAY-15
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=20 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oracle/oradata/test/system01.dbf
input datafile file number=00002 name=/u01/app/oracle/oradata/test/sysaux01.dbf
input datafile file number=00003 name=/u01/app/oracle/oradata/test/undotbs01.dbf
input datafile file number=00005 name=/u01/app/oracle/oradata/test/users02.dbf
input datafile file number=00006 name=/u01/app/oracle/oradata/test/undotbs02.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/test/users01.dbf
channel ORA_DISK_1: starting piece 1 at 25-MAY-15
channel ORA_DISK_1: finished piece 1 at 25-MAY-15
piece handle=/u01/app/oracle/fast_recovery_area/TEST/backupset/2015_05_25/o1_mf_nnndf_TAG20150525T232624_bp6hs0oo_.bkp tag=TAG20150525T232624 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:02:01
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 25-MAY-15
channel ORA_DISK_1: finished piece 1 at 25-MAY-15
piece handle=/u01/app/oracle/fast_recovery_area/TEST/backupset/2015_05_25/o1_mf_ncsnf_TAG20150525T232624_bp6hx32w_.bkp tag=TAG20150525T232624 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:08
Finished backup at 25-MAY-15

RMAN> quit

利用Backup Exec
2012 备份作业计划对Exchange2010执行定期完全备份+差异备份;

模拟数据丢失

每周日 10:00
执行完全备份,每天10:30执行差异备份;

[oracle@node2 ~]$ cd /u01/app/oracle/oradata/test
[oracle@node2 test]$ ls
control01.ctl  redo01.log  redo03.log  sysaux01.dbf  temp01.dbf     undotbs02.dbf  users02.dbf
control01.dbf  redo02.log  redo04.log  system01.dbf  undotbs01.dbf  users01.dbf
[oracle@node2 test]$ rm ./*

user1邮箱,所在数据库名为Test,有两封邮件”Test01″、”Test02″,然后执行完全备份;

试着登录数据库查询数据,会报以下错误:

完全备份和差异备份之间,给user1再发送一封标题为”Test03完全备份后,差异备份前”的邮件,等待差异备份执行;

[oracle@node2 ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Mon May 25 23:35:49 2015

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

Connected.
SQL> select * from scott.dept;
select * from scott.dept
*
ERROR at line 1:
ORA-01012: not logged on
Process ID: 0
Session ID: 0 Serial number: 0

执行后,彻底删除邮箱user1,然后从完全备份+差异备份中恢复整个数据库Test.

看看ORACLE相关进程,会发现实例并没有奔溃,进程还在


[oracle@node2 ~]$ ps -ef |grep ora
root      1362  1320  0 19:25 ?        00:00:08 hald-addon-storage: polling /dev/sr0 (every 2 sec)
root      2809  1384  0 22:22 ?        00:00:00 sshd: oracle [priv]
oracle    2811  2809  0 22:22 ?        00:00:01 sshd: oracle@pts/7
oracle    2812  2811  0 22:22 pts/7    00:00:00 -bash
root      3006  1384  0 22:31 ?        00:00:00 sshd: oracle [priv]
oracle    3008  3006  0 22:31 ?        00:00:00 sshd: oracle@pts/1
oracle    3009  3008  0 22:31 pts/1    00:00:00 -bash
root      3120  1384  0 22:34 ?        00:00:00 sshd: oracle [priv]
oracle    3122  3120  0 22:34 ?        00:00:00 sshd: oracle@pts/8
oracle    3123  3122  0 22:34 pts/8    00:00:00 -bash
root      3482  1384  0 22:57 ?        00:00:00 sshd: oracle [priv]
oracle    3484  3482  0 22:57 ?        00:00:01 sshd: oracle@pts/3
oracle    3485  3484  0 22:57 pts/3    00:00:00 -bash
root      3566  1384  0 23:01 ?        00:00:00 sshd: oracle [priv]
oracle    3568  3566  0 23:01 ?        00:00:00 sshd: oracle@pts/9
oracle    3569  3568  0 23:01 pts/9    00:00:00 -bash
oracle    4035     1  0 23:23 ?        00:00:00 ora_pmon_test
oracle    4037     1  0 23:23 ?        00:00:00 ora_psp0_test
oracle    4039     1  4 23:23 ?        00:00:32 ora_vktm_test
oracle    4043     1  0 23:23 ?        00:00:00 ora_gen0_test
oracle    4045     1  0 23:23 ?        00:00:00 ora_diag_test
oracle    4047     1  0 23:23 ?        00:00:00 ora_dbrm_test
oracle    4049     1  0 23:23 ?        00:00:00 ora_dia0_test
oracle    4051     1  0 23:23 ?        00:00:00 ora_mman_test
oracle    4053     1  0 23:23 ?        00:00:00 ora_dbw0_test
oracle    4055     1  0 23:23 ?        00:00:00 ora_lgwr_test
oracle    4057     1  0 23:23 ?        00:00:00 ora_ckpt_test
oracle    4059     1  0 23:23 ?        00:00:00 ora_smon_test
oracle    4061     1  0 23:23 ?        00:00:00 ora_reco_test
oracle    4063     1  0 23:23 ?        00:00:02 ora_mmon_test
oracle    4065     1  0 23:23 ?        00:00:00 ora_mmnl_test
oracle    4067     1  0 23:23 ?        00:00:00 ora_d000_test
oracle    4069     1  0 23:23 ?        00:00:00 ora_s000_test
oracle    4081     1  0 23:23 ?        00:00:00 ora_arc0_test
oracle    4083     1  0 23:23 ?        00:00:00 ora_arc1_test
oracle    4085     1  0 23:23 ?        00:00:00 ora_arc2_test
oracle    4087     1  0 23:23 ?        00:00:00 ora_arc3_test
oracle    4089     1  0 23:23 ?        00:00:00 ora_qmnc_test
oracle    4103     1  0 23:24 ?        00:00:01 ora_cjq0_test
oracle    4105     1  0 23:24 ?        00:00:00 ora_q000_test
oracle    4107     1  0 23:24 ?        00:00:00 ora_q001_test
oracle    4109     1  0 23:24 ?        00:00:05 ora_vkrm_test
oracle    4129     1  0 23:24 ?        00:00:00 ora_smco_test
oracle    4131     1  0 23:24 ?        00:00:00 ora_w000_test
oracle    4149     1  0 23:29 ?        00:00:00 ora_w001_test
oracle    4151     1  0 23:29 ?        00:00:00 ora_w002_test
oracle    4153     1  0 23:30 ?        00:00:00 ora_w003_test
oracle    4178  3123  0 23:35 pts/8    00:00:00 sqlplus   as sysdba
oracle    4186  4178  0 23:36 ?        00:00:00 oracletest (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
oracle    4187  3485  0 23:36 pts/3    00:00:00 ps -ef
oracle    4188  3485  0 23:36 pts/3    00:00:00 grep ora

关闭数据库

设置备份作业计划,根据需求设置好作业计划时间,备份内容

SQL> shutdown abort
ORACLE instance shut down.

现在开始恢复数据库,在这里会借助Oracle的dummy实例,即哑实例。

备份内容:选择”Microsoft
Information Store”,并设置作业计划时间,如图示:

[oracle@node2 ~]$ export ORACLE_SID=dummy
[oracle@node2 ~]$ rman target /

Recovery Manager: Release 11.2.0.4.0 - Production on Mon May 25 23:44:28 2015

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to target database (not started)

RMAN> startup nomount

startup failed: ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/u01/app/oracle/product/11.2.0.1/db_1/dbs/initdummy.ora'

starting Oracle instance without parameter file for retrieval of spfile
Oracle instance started

Total System Global Area    1071333376 bytes

Fixed Size                     1369420 bytes
Variable Size                281021108 bytes
Database Buffers             784334848 bytes
Redo Buffers                   4608000 bytes

RMAN> restore spfile to '/u01/app/oracle/product/11.2.0.1/db_1/dbs/spfiletest.ora' from '/u01/app/oracle/fast_recovery_area/TEST/backupset/2015_05_25/o1_mf_ncsnf_TAG20150525T232624_bp6hx32w_.bkp';

Starting restore at 25-MAY-15
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=171 device type=DISK

channel ORA_DISK_1: restoring spfile from AUTOBACKUP /u01/app/oracle/fast_recovery_area/TEST/backupset/2015_05_25/o1_mf_ncsnf_TAG20150525T232624_bp6hx32w_.bkp
channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
Finished restore at 25-MAY-15

RMAN> shutdown immediate

Oracle instance shut down

图片 1

在这里,我们将spfile恢复到实例默认的目录,即$ORACLE_HOME/dbs,采用的是默认值,即spfile实例名.ora。这样,在将数据库启动到nomount状态下,直接startup
nomount即可。

更新后,可以看到下次备份时间变为我们计划中设置的时间了:

恢复控制文件

图片 2

[oracle@node2 ~]$ export ORACLE_SID=test
[oracle@node2 ~]$ rman target /

Recovery Manager: Release 11.2.0.4.0 - Production on Mon May 25 23:54:50 2015

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to target database (not started)

RMAN> startup nomount

Oracle instance started

Total System Global Area     313860096 bytes

Fixed Size                     1364340 bytes
Variable Size                268439180 bytes
Database Buffers              37748736 bytes
Redo Buffers                   6307840 bytes

RMAN> restore controlfile from '/u01/app/oracle/fast_recovery_area/TEST/backupset/2015_05_25/o1_mf_ncsnf_TAG20150525T232624_bp6hx32w_.bkp';

Starting restore at 26-MAY-15
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=136 device type=DISK

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/u01/app/oracle/oradata/test/control01.ctl
output file name=/u01/app/oracle/fast_recovery_area/test/control02.ctl
Finished restore at 26-MAY-15

备份前,看一下数据库”Test”有哪些用户:

注意,要重新设置ORACLE_SID的值,不然启动的依旧是dummy实例。

通过筛选器,很容易看到该数据库中只有user1用户邮箱;

将数据库启动到mount阶段

图片 3

RMAN> alter database mount;

database mounted
released channel: ORA_DISK_1

登录user1
OWA查看邮件(完整备份前):

还原和恢复数据库

图片 4

RMAN> restore database;

Starting restore at 26-MAY-15
Starting implicit crosscheck backup at 26-MAY-15
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=136 device type=DISK
Crosschecked 4 objects
Finished implicit crosscheck backup at 26-MAY-15

Starting implicit crosscheck copy at 26-MAY-15
using channel ORA_DISK_1
Finished implicit crosscheck copy at 26-MAY-15

searching for all files in the recovery area
cataloging files...
cataloging done

List of Cataloged Files
=======================
File Name: /u01/app/oracle/fast_recovery_area/TEST/backupset/2015_05_25/o1_mf_ncsnf_TAG20150525T232624_bp6hx32w_.bkp

using channel ORA_DISK_1

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to /u01/app/oracle/oradata/test/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /u01/app/oracle/oradata/test/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/test/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/test/users01.dbf
channel ORA_DISK_1: restoring datafile 00005 to /u01/app/oracle/oradata/test/users02.dbf
channel ORA_DISK_1: restoring datafile 00006 to /u01/app/oracle/oradata/test/undotbs02.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/TEST/backupset/2015_05_25/o1_mf_nnndf_TAG20150525T232624_bp6hs0oo_.bkp
channel ORA_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/TEST/backupset/2015_05_25/o1_mf_nnndf_TAG20150525T232624_bp6hs0oo_.bkp tag=TAG20150525T232624
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:02:06
Finished restore at 26-MAY-15

RMAN> recover database;

Starting recover at 26-MAY-15
using channel ORA_DISK_1

starting media recovery

unable to find archived log
archived log thread=1 sequence=1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 05/26/2015 00:19:20
RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 1 and starting SCN of 956515

RMAN> alter database open resetlogs;

database opened

等待完全备份作业执行………….

至此,数据库恢复完毕,该恢复属于不完全恢复,毕竟,在线日志文件在“模拟数据丢失”那一步已被删除,完全恢复已不可能,同时,上述倒数第二步recover
database提示所需的归档文件不存在,指的也是已被删除的在线日志文件。在这里,直接resetlogs即可。

完全备份完成:

总结:

图片 5

1> 如果启用了RMAN的自动备份功能configure autobackup
on,在恢复spfile和controlfile那一步可直接执行restore spfile from
autobackup和restore controlfile from
autobackup,不用上述那么麻烦,需要指定备份集。当然,在这种情况下,需指定dbid。

完全备份完成后,给user1发送第三封邮件,标题为”Test03
完全备份后差异备份前”,登录user1 OWA

2>
OCP官方教材里面其实也提供了在一切都丢失的情况下,如何执行数据库的还原和恢复的脚本,具体如下:

查看邮件:

RMAN> run{startup nomount pfile=dummy.pfile;
2> set dbid=2176055307;
3> restore spfile from autobackup;
4> shutdown abort;
5> startup nomount;
6> restore controlfile from autobackup;
7> alter database mount;
8> restore database;
9> recover database;
10> alter database open resetlog;}

图片 6

关于这个脚本,说明如下:

等待差异备份作业执行………….

第1行,使用只有一个参数(DB_NAME)的哑参数文件启动实例

差异备份成功完成后,在Exchange
管理控制中删除user1邮箱,默认邮箱删除后,并没有真正从数据库中删除,而是在”断开连接的邮箱”中保留一定周期(默认30天),之后才会从数据库删除。

第2行,告诉RMAN所使用的数据库的DBID

如图示:

第3行,根据默认目录和默认值,从最近的自动备份集中提取spfile

图片 7

第4行,关闭哑实例

在Exchange Management Shell中执行如下指令彻底删除user1邮箱:

第5行,利用还原的spfile启动实例

获取user1邮箱的guid:

第6行,从最近的备份集中提取控制文件

图片 8

You can leave a response, or trackback from your own site.

Leave a Reply

网站地图xml地图