收藏 分销(赏)

数据库备份方案样本.doc

上传人:天**** 文档编号:2506539 上传时间:2024-05-30 格式:DOC 页数:20 大小:117.04KB
下载 相关 举报
数据库备份方案样本.doc_第1页
第1页 / 共20页
数据库备份方案样本.doc_第2页
第2页 / 共20页
数据库备份方案样本.doc_第3页
第3页 / 共20页
数据库备份方案样本.doc_第4页
第4页 / 共20页
数据库备份方案样本.doc_第5页
第5页 / 共20页
点击查看更多>>
资源描述

1、数据库备份方案作者:Oracle Consulting Services文档创建日期:Aug 1, 最近变更日期:Mar 5 , 文档引用: 版本号:v1.0Note: Title, Subject, Last Updated Date, Reference Number, and Version are marked by a Word Bookmark so that they can be easily reproduced in the header and footer of documents. When you change any of these values, be car

2、eful not to accidentally delete the bookmark. You can make bookmarks visible by selecting Tools-OptionsView and checking the Bookmarks option in the Show region.审批:Note: To add additional approval lines, Press Tab from the last cell in the table above. Copy Number_Note:Note:Note: You can delete any

3、elements of this cover page that you do not need for your document. For example, Copy Number is only required if this is a controlled document and you need to track each copy that you distribute.文档控制变更统计20日期作者版本号变更参考文件审阅姓名职位发行拷贝号姓名地址1234Note: The copy numbers referenced above should be written into

4、the Copy Number space on the cover of each distributed copy. If the document is not controlled, you can delete this table and the Copy Number label from the cover page.目录文档控制2RMAN备份概述4在线热备份4多级增量备份4并行备份,恢复5降低所需要备份数据量5使用简单5配置RMAN6CATALOG数据库6磁带接口7多级备份策略7维护RMAN12检验RMAN备份信息12RMAN信息同时12使用RMAN进行恢复13恢复整个数据库

5、13恢复单个表空间13其它15archive 方法15Note: To update the table of contents, put the cursor anywhere in the table and press F9. To change the number of levels displayed, select the menu option InsertIndex and Tables, make sure the Table of Contents tab is active, and change the Number of Levels to a new value.

6、RMAN备份概述采取数据库提供RMAN备份工含有以下优点:支持在线热备份支持多级增量备份支持并行备份,恢复减小所需要备份量备份,恢复使用简单在线热备份是指备份不需要关闭数据库进行,在备份同时能够进行正常数据库多种操作,满足了7*24系统需要,对于本系统而言,数据库备份将不会影响INTERNET或INTRANET用户对数据库访问。多级增量备份多级增量备份是指第N级备份只需要备份最终一次同级或N-1级备份以后发生改变数据。能够经过下图来说明:上图是一个增量备份例子,即在第一个星期天做一个增量0级备份,然后在星期一,星期二做一个增量2级备份,在星期三做一个增量1级备份,然后类推。假设现在在星期五数据

7、库需要做恢复,则能够先恢复第一个星期天0级备份,然后恢复星期三1级备份,再恢复星期四和星期五2级备份就能够完成数据库恢复。因为在本系统录入后数据数据进入数据库后将大部分变为只读状态,所以采取对这些表空间只备份一次或比常常改变表空间备份次数更少方法,将能够很大地降低备份数据量。具体方案以下:对于表PROD_CONTENT_CN_TBL,PROD_VALUE_TBL因为做了相关序列号分区,采取当一个分区满了以后,在数据库里把该分区改成只读状态,然后做一个该表空间备份,然后在做数据库日常增量备份时忽略该表空间数据则能够大大降低要备份数据量。并行备份,恢复RMAN是经过开启数据库SERVER进程来进行

8、备份和恢复,而且支持开启多个SERVER进程来进行备份和恢复,在同一个SERVER进程内还支持多个BACKUPSET(备份集)同时产生。关键是经过设置多个通道及filesperset参数来达成并行目标。分配多个通道语句(以下语句分配两个通道)Allocate channel dev_1 type disk;Allocate channel dev_2 type disk;设置在一个通道同时打开备份文件语句(以下语句设置在一个通道下同时打开3个文件)backup filesperset 3。降低所需要备份数据量因为RMAN是工作在数据快一级,所以能够只备份分配数据快,这么就大大地降低了所需要备份

9、数据量,尤其是对于预先分配空间数据库而言。使用简单RMAN使用尤其简单,在进行备份和恢复时全部不需要指定需要备份或需要恢复数据文件,RMAN会自动地把备份或恢复所需要数据文件进行备份或进行恢复。降低了人为操作可能产生错误。如以下是备份整个数据库语句backup full tag basicdb format /bak/bak/basic/basic%u_%p_%c database ;以下是备份一个表空间语句backup tag tsusers format /bak/bak/basic/basic%u_%p_%c tablespace users ;以下是备份归档文件语句backup fil

10、esperset 3 archivelog all delete input;归档文件会在备份后自动删除。配置RMAN配置RMAN包含配置CATALOG数据库,配置数据库和媒体管理软件接口,制订RMAN多级备份方案,写RMAN备份脚本CATALOG数据库因为RMAN自动维护备份和恢复所需要多种信息,所以RMAN必需把这些以某种形式保留。RMAN支持两种形式保留这些信息,数据库控制文件或创建一个单独数据库来保留RMAN信息。 当选择把RMAN信息存放在控制文件时,控制文件丢失时将造成备份将不能进行恢复。所以若采取RMAN做备份,推荐一定采取RMAN CATALOG数据库来单独存放备份信息。这个单

11、独数据库(称为CATALOG数据库)只需要很小空间,既能够和被备份数据库(E10K)放在同一主机上,也能够单独放在另一台主机上(假如条件许可,推荐放在一台单独主机上来确保最大可恢复性)。备份CATALOG数据库:因为CATALOG数据库包含了全部备份信息,所以该数据库本身也是需要经过某种方法进行备份,但因为该数据库很小(十二个月内可能才增加十几二十兆),所以既能够对它进行冷备份,也能够进行逻辑输出(EXPORT)。配置CATALOG数据库:1. 用dbassist创建数据库。2. 创建表空间create tablespace ts_rmandatafile=d:oratestrman.dbfs

12、ize=100M;3. 在该数据库创建RMAN数据库用户:create user rman identified by rman default tablespace ts_rman temporary tablespace temp;grant connect ,resource , RECOVERY_CATALOG_OWNER to rman.4. 连接到目标数据库和CATALOG数据库rman target system/managertarget_tnsname rcvcat rman/rmancatalog_tnsname 5. 创建CATALOG用户表:rmancreate cat

13、alog6. 登记目标数据库:rmanregister database这么就能够利用该RMAN数据库来备份目标数据库了。解除登记数据库开启rman并连接到目标数据库。% rman target sys/change_on_installprod1 nocatalog RMAN-06005: connected to target database: RMAN (DBID=) List the copies and backup sets recorded in the control file and then issue change . delete statements to dele

14、te them from the O/S. See Generating Lists and Deleting Backups and Copies and Updating Their Status in the RMAN Metadata. Use SQL*Plus to connect to your recovery catalog database and execute the following query in the recovery catalog to find the correct row of the DB table, setting DB_ID equal to

15、 the value you obtained from step 1. For example, enter: SQL SELECT db_key, db_id FROM db WHERE db_id = ; This query should return exactly one row. DB_KEY DB_ID - - 1 1 row selected. While still connected to the recovery catalog, enter the following, where DB_KEY and DB_ID are the corresponding colu

16、mns from the row you got from the query in step 2: SQL EXECUTE dbms_rcvcat.unregisterdatabase(db_key, db_id) For example, enter: SQL EXECUTE dbms_rcvcat.unregisterdatabase(1 , )磁带接口当使用专用磁带管理工具时,必需配置数据库和磁带接口,通常是管理工具提供一个动态连接库和数据库进行连接。以下是一个测试RMAN脚本:run allocate channel dev1 type diskresync catalog;back

17、up format /archive/ctl%u_%p_%c current controlfile;release channel dev1;多级备份策略采取多级备份是为了降低了恢复所需要时间和降低天天备份所需要时间,而又确保系统有很好恢复性。不过在恢复时间和备份时间要有一个权衡。比如只要开始一个全备份和备份全部产生归档文件就能够确保把数据库恢复到最新状态,不过通常来说实际上并不会这么进行(因为在恢复时将需要很长很长时间),多级备份就是为了处理这么问题。以下是一个提议方案。每六个月做一个数据库全备份(包含只读表空间)每个月做一次零级备份(不包含只读表空间)每个星期做一次一级备份天天做一个二级

18、备份任何表空间改成只读状态后做一个该表空间备份。当需要时(如四个小时归档文件系统就要靠近满了)备份归档文件数据库全备份脚本:run allocate channel dev1 type disk ;allocate channel dev2 type disk ;allocate channel dev3 type disk ;backup full tag dbfull format /o9i/testrman/full%u_%p_%c database ;sql alter system archive log current ;backup filesperset 3 archivelo

19、g all delete input;release channel dev1;release channel dev2;release channel dev3;零级备份脚本(只读表空间除外)run allocate channel dev1 type disk ;allocate channel dev2 type disk ;allocate channel dev3 type disk ;backup incremental level 0 tag dbL0 format /o9i/testrman/basic%u_%p_%c database skip readonly;sql al

20、ter system archive log current ;backup filesperset 3 archivelog all delete input;release channel dev1;release channel dev2;release channel dev3;一级备份脚本run allocate channel dev1 type disk ;allocate channel dev2 type disk ;allocate channel dev3 type disk ;backup incremental level 1 tag dbL1 format /o9i

21、/testrman/basic%u_%p_%c ddatabase skip readonly;sql alter system archive log current ;backup filesperset 3 archivelog all delete input;release channel dev1;release channel dev2;release channel dev3;二级备份脚本run allocate channel dev1 type disk ;allocate channel dev2 type disk ;allocate channel dev3 type

22、 disk ;backup incremental level 2 tag dbL2 format /o9i/testrman/basic%u_%p_%c ddatabase skip readonly;sql alter system archive log current ;backup filesperset 3 archivelog all delete input;release channel dev1;release channel dev2;release channel dev3;表空间备份脚本(以users表空间为例)run allocate channel dev1 ty

23、pe disk ;allocate channel dev2 type disk ;allocate channel dev3 type disk ;backup tag tsusers format /o9i/testrman/basic%u_%p_%c tablespace users;sql alter system archive log current ;backup filesperset 3 archivelog all delete input;release channel dev1;release channel dev2;release channel dev3;归档文件

24、备份脚本run allocate channel dev1 type disk ;allocate channel dev2 type disk ;allocate channel dev3 type disk ;backup filesperset 3 archivelog all delete input;release channel dev1;release channel dev2;release channel dev3;则天天所需要备份数据量只有一天改变量。而做恢复时最多只要恢复当月一个零级备份+三个一级备份+6个二级备份+当日归档文件。假如不能接收这么恢复时间,就只能够降低零级

25、备份之间时间间隔(如能够每个星期做一个零级备份,这么恢复时最多只需要恢复一个星期数据量)。备份CATALOG数据库(数据库逻辑输出)exp pafile=exp.dat其中exp.dat以下userid=rman/rmanfile=rmanexp.dmp维护RMANRMAN维护工作关键是:1 查看备份信息2 因为手工删除了备份文件或归档文件需要把RMAN CATALOG数据库信息和手工删除信息同时。检验RMAN备份信息列出已经过时备份:RMANreport obsolete删除过时备份信息RMAN allocate channel for maintenance type disk;RMAN

26、change backupset id delete;RMAN release channel;RMAN信息同时当手工删除了数据库归档文件后,要实施以下脚本进行同时:RMAN allocate channel for maintenance type disk;RMAN change archivelog all crosscheck;RMAN release channel;当手工删除了数据库RMAN备份文件后,要实施以下脚本进行同时:RMAN allocate channel for maintenance type disk;RMAN crosscheck backup;RMAN del

27、ete expired backup;RMAN release channel;使用RMAN进行恢复数据库恢复比较复杂,有很多不一样情况必需在了解ORACLE数据库结构条件下用不一样方法处理,RMAN好处于于大部分情况不需要了解数据库结构而使用部分最简单语句来进行恢复,这里只讨论了最常见最一般恢复情况恢复整个数据库在恢复整个数据库之前必需让数据库处于安装状态(mount状态)svrmgrlstartup mountrmanrun allocate channel dev1 type disk ;allocate channel dev2 type disk ;allocate channel

28、dev3 type disk ;restore database ;recover database ;release channel dev1 ;release channel dev2 ;release channel dev3 ;恢复单个表空间在恢复该表空间之前让该表空间处于脱机状态(offline状态)svrmgrlalter tablespace users offline;rmanrun allocate channel dev1 type disk ;allocate channel dev2 type disk ;allocate channel dev3 type disk ;restore tablespace users ;recover tablespace users ;release channel dev1 ;release channel dev2 ;release channel dev3 ;其它数据库要使用RMAN必需符合部分条件archive 方法数据库要运行在归档模式下,这么数据库将有很好可恢复性

展开阅读全文
部分上传会员的收益排行 01、路***(¥15400+),02、曲****(¥15300+),
03、wei****016(¥13200+),04、大***流(¥12600+),
05、Fis****915(¥4200+),06、h****i(¥4100+),
07、Q**(¥3400+),08、自******点(¥2400+),
09、h*****x(¥1400+),10、c****e(¥1100+),
11、be*****ha(¥800+),12、13********8(¥800+)。
相似文档                                   自信AI助手自信AI助手
搜索标签

当前位置:首页 > 通信科技 > 数据库/数据算法

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        获赠5币

©2010-2025 宁波自信网络信息技术有限公司  版权所有

客服电话:4008-655-100  投诉/维权电话:4009-655-100

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :gzh.png    weibo.png    LOFTER.png 

客服