Oracle中的数据库备份-导出数据库还是使用其他工具?


10

我所见到的关于在组织中由DBA执行的“实践”之一是使用exp/等工具将完整的数据库导出expdp视为备份。

这是一个好习惯吗?与这种方法相比,使用RMAN有什么好处?


使用RMAN,数据库复制容易得多
Sumnibot 2011年

Answers:


7

RMAN的优点是PITR-时间点恢复。您可以对DBF进行RMAN备份,对归档的重做日志进行RMAN备份,并将数据库恢复到最新的归档重做日志备份之前的任何时间点。这种方法的缺点是它的粒度很粗-您只能在表空间级别进行恢复。

exp / expdp的优点是您拥有数据库的一致副本,您可以将其导入到新创建的空白数据库中。但是,您无法前滚它-此时它是一个完全独立的独立数据库,与原始数据库没有逻辑关系。但是很容易仅恢复单个表,甚至从导出中恢复几行。

一个好的方法是定期进行RMAN完整和增量数据文件备份,对归档的重做日志进行连续备份(例如,一个归档日志备份完成后,立即开始下一个备份,以便您将日志“流式传输”到磁带上)然后教育用户在使用exp / imp时,他们可以执行自己的“备份”(在需要数据的实际副本的情况下)和闪回(因此在DML出现错误的情况下,他们可以进行自己的恢复)。

请记住-备份是供DBA从硬件灾难性故障中恢复的。这不是最终用户的利益(否则您将花费​​全部时间进行还原到测试系统,并将几行复制回原始行!)。


5

Exp / Expdp作为备用解决方案就像说汽配店是您的备用汽车。从技术上讲,它可以使您恢复正常运行,但只会给您带来痛苦和折磨。

Exp或Expdp可用作文件系统冷备份或rman热备份或冷备份的辅助备份(其他Oracle备份客户端软件通常仅运行RMAN命令)。

典型的方法如下:

1 cold backup weekly
1 hot backup daily

而且,如果您确实想保持谨慎,请定期将存档的重做日志移出服务器(每小时工作一次),或者将远程位置设置为第二个存档日志目标。

-RMAN *新-

我的典型RMAN会议:

rman target=/

backup as compressed backupset database plus archivelog delete input;

delete obsolete;

exit

“将备份作为压缩的备份集...”:您也可以创建一个映像,该映像是一个字节,用于数据文件的字节复制。作为每周备份,这会很好。

“ ...数据库...”:很明显

“ ... plus archivelogs ...”:给我们时间点恢复(以及时间点克隆[rman中的重复命令])

“ ...删除输入”:删除已备份的归档日志。您也可以将其设置为删除至少备份两次的备份,等等。

“删除过时”:配置了rman保留策略(我的保留时间为5天)后,这将删除该窗口之外的备份。这并不意味着我们只能在5天前恢复。您仍应每天在闪回恢复区进行磁带/服务器外备份。这仅意味着在线上将有5天的恢复,然后您需要从磁带/服务器外备份中恢复闪回恢复区项目,然后在rman中注册它们以使用它们。

这是会话中的实际日志,对路径进行了稍微修改,等等:

oracle@prodserver[PROD]$ rman target=/

Recovery Manager: Release 10.2.0.4.0 - Production on Wed Jan 5 21:00:00 2011

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

connected to target database: PROD (DBID=randomnumber)

RMAN> backup
2> as compressed backupset
3> database
4> include current controlfile
5> plus archivelog delete input;
6> backup spfile;
7> delete obsolete;
8>

Starting backup at 05-JAN-11
current log archived
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=291 devtype=DISK
channel ORA_DISK_1: starting compressed archive log backupset
channel ORA_DISK_1: specifying archive log(s) in backup set
input archive log thread=1 sequence=743 recid=743 stamp=739623589
input archive log thread=1 sequence=744 recid=744 stamp=739623940
input archive log thread=1 sequence=745 recid=745 stamp=739624712
input archive log thread=1 sequence=746 recid=746 stamp=739625380
input archive log thread=1 sequence=747 recid=747 stamp=739659606
channel ORA_DISK_1: starting piece 1 at 05-JAN-11
channel ORA_DISK_1: finished piece 1 at 05-JAN-11
piece handle=/u03/oraflash/PROD/backupset/2011_01_05/o1_mf_annnn_TAG20110105T210008_6lb8kb4o_.bkp tag=TAG20110105T210008 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:26
channel ORA_DISK_1: deleting archive log(s)
archive log filename=/u03/oraflash/PROD/archivelog/2011_01_05/o1_mf_1_743_6l95ckxx_.arc recid=743 stamp=739623589
archive log filename=/u03/oraflash/PROD/archivelog/2011_01_05/o1_mf_1_744_6l95plo2_.arc recid=744 stamp=739623940
archive log filename=/u03/oraflash/PROD/archivelog/2011_01_05/o1_mf_1_745_6l96gpok_.arc recid=745 stamp=739624712
archive log filename=/u03/oraflash/PROD/archivelog/2011_01_05/o1_mf_1_746_6l973l32_.arc recid=746 stamp=739625380
archive log filename=/u03/oraflash/PROD/archivelog/2011_01_05/o1_mf_1_747_6lb8k57v_.arc recid=747 stamp=739659606
Finished backup at 05-JAN-11

Starting backup at 05-JAN-11
using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/u02/oradata/PROD/system01.dbf
input datafile fno=00005 name=/u02/oradata/PROD/software.dbf
input datafile fno=00003 name=/u02/oradata/PROD/sysaux01dbf
input datafile fno=00002 name=/u02/oradata/PROD/undotbs01.dbf
input datafile fno=00004 name=/u02/oradata/PROD/users.dbf
channel ORA_DISK_1: starting piece 1 at 05-JAN-11
channel ORA_DISK_1: finished piece 1 at 05-JAN-11
piece handle=/u03/oraflash/PROD/backupset/2011_01_05/o1_mf_nnndf_TAG20110105T210135_6lb8n0y4_.bkp tag=TAG20110105T210135 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:45
channel ORA_DISK_1: starting compressed full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 05-JAN-11
channel ORA_DISK_1: finished piece 1 at 05-JAN-11
piece handle=/u03/oraflash/PROD/backupset/2011_01_05/o1_mf_ncsnf_TAG20110105T210135_6lb8qblm_.bkp tag=TAG20110105T210135 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
Finished backup at 05-JAN-11

Starting backup at 05-JAN-11
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed archive log backupset
channel ORA_DISK_1: specifying archive log(s) in backup set
input archive log thread=1 sequence=748 recid=748 stamp=739659803
channel ORA_DISK_1: starting piece 1 at 05-JAN-11
channel ORA_DISK_1: finished piece 1 at 05-JAN-11
piece handle=/u03/oraflash/PROD/backupset/2011_01_05/o1_mf_annnn_TAG20110105T210323_6lb8qf3l_.bkp tag=TAG20110105T210323 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
channel ORA_DISK_1: deleting archive log(s)
archive log filename=/u03/oraflash/PROD/archivelog/2011_01_05/o1_mf_1_748_6lb8qcrr_.arc recid=748 stamp=739659803
Finished backup at 05-JAN-11

Starting backup at 05-JAN-11
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 05-JAN-11
channel ORA_DISK_1: finished piece 1 at 05-JAN-11
piece handle=/u03/oraflash/PROD/backupset/2011_01_05/o1_mf_nnsnf_TAG20110105T210329_6lb8qlnm_.bkp tag=TAG20110105T210329 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
Finished backup at 05-JAN-11

RMAN retention policy will be applied to the command
RMAN retention policy is set to recovery window of 5 days
using channel ORA_DISK_1
Deleting the following obsolete backups and copies:
Type                 Key    Completion Time    Filename/Handle
-------------------- ------ ------------------ --------------------
Backup Set           55     30-DEC-10        
  Backup Piece       55     30-DEC-10          /u03/oraflash/PROD/backupset/2010_12_30/o1_mf_nnndf_TAG20101230T210026_6ktg9v8w_.bkp
Backup Set           56     30-DEC-10        
  Backup Piece       56     30-DEC-10          /u03/oraflash/PROD/backupset/2010_12_30/o1_mf_ncsnf_TAG20101230T210026_6ktgdvnt_.bkp
Backup Set           57     30-DEC-10        
  Backup Piece       57     30-DEC-10          /u03/oraflash/PROD/backupset/2010_12_30/o1_mf_annnn_TAG20101230T210204_6ktgdy5j_.bkp
Backup Set           58     30-DEC-10        
  Backup Piece       58     30-DEC-10          /u03/oraflash/PROD/backupset/2010_12_30/o1_mf_nnsnf_TAG20101230T210210_6ktgf3pz_.bkp
Backup Set           59     31-DEC-10        
  Backup Piece       59     31-DEC-10          /u03/oraflash/PROD/backupset/2010_12_31/o1_mf_annnn_TAG20101231T210008_6kx2ob5r_.bkp
deleted backup piece
backup piece handle=/u03/oraflash/PROD/backupset/2010_12_30/o1_mf_nnndf_TAG20101230T210026_6ktg9v8w_.bkp recid=55 stamp=739141227
deleted backup piece
backup piece handle=/u03/oraflash/PROD/backupset/2010_12_30/o1_mf_ncsnf_TAG20101230T210026_6ktgdvnt_.bkp recid=56 stamp=739141323
deleted backup piece
backup piece handle=/u03/oraflash/PROD/backupset/2010_12_30/o1_mf_annnn_TAG20101230T210204_6ktgdy5j_.bkp recid=57 stamp=739141326
deleted backup piece
backup piece handle=/u03/oraflash/PROD/backupset/2010_12_30/o1_mf_nnsnf_TAG20101230T210210_6ktgf3pz_.bkp recid=58 stamp=739141331
deleted backup piece
backup piece handle=/u03/oraflash/PROD/backupset/2010_12_31/o1_mf_annnn_TAG20101231T210008_6kx2ob5r_.bkp recid=59 stamp=739227610
Deleted 5 objects


Recovery Manager complete.

1
在当今时代,实际上甚至不需要考虑冷备份。如果您还不备份存档的重做日志,那么热备份有什么意义呢?
Gaius

如果需要更多详细信息,那么我很乐于详细说明,否则,有关rman的大多数文章都讨论了归档的重做日志备份。它之间的区别是:“备份数据库”和“备份数据库加归档日志”,当然两者之间还有所有其他变体。
REW

请提出您的答案!
2011年

感谢@REW提供详细的答案,希望我能再次为您+1
Sathyajith Bhat 2011年

4

RMAN的优点如下:

  • 使用Windows概念实施自动备份保留策略。您可以指定应该保留备份的天数,并选择保留策略:过期后将其删除,如果没有可用空间用于新备份,则将它们删除。
  • 在写入媒体或使用多个磁盘控制器时使用通道来提高性能
  • 轻松还原-基本上,您只需列出自己的备份并指定要从中执行数据库还原的备份
  • RMAN可以将其备份元数据保存在称为RMAN信息库的独立表中,该表可以保存您执行的所有备份的大量记录,而不是控制文件
  • 您可以指定默认的备份副本数,而且后者可以保存在不同的物理磁盘(介质)上
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.