数据库备份和恢复方案及步骤_第1页
数据库备份和恢复方案及步骤_第2页
数据库备份和恢复方案及步骤_第3页
数据库备份和恢复方案及步骤_第4页
数据库备份和恢复方案及步骤_第5页
已阅读5页,还剩5页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、操作系统:GNU/Linux数据库管理系统:Oracle10g一、安装Recovery Catalog1, 用dbca创建一个DATABASE catdb,用于存放recovery catalog dataoraclelocalhost $dbca2, 在catdb中创建一个名为rcat_ts的表空间作为用户rman的默认表空间oraclelocalhost $sqlplus sys/oraclecatdb as sysdbaSQL create tablespace rcat_ts;SQL create user rman identified by oracle temporary tab

2、lespace tempDefault tablespace rcat_ts quota unlimited on rcat_ts;3, 授予catlog所有者rman recovery_catalog_owner角色,该角色提供给用户所有查询和维护recovery catalog所必需的权限SQL grant connect,resource,recovery_catalog_owner to rman;4, 启动rman,以catalog所有者rman登录 oraclelocalhost $rman catalog rman/oraclecatdbRMAN create catalog t

3、ablespace rcat_ts;5,用rman同时连接到target数据库、catalog数据库,在新建的recovery catalog中注册target数据库oraclelocalhost $rman target sys/oracleorcl catalog rman/oraclecatdb RMAN register database;, 察看已在recovery catalog中注册的target数据库oraclelocalhost $sqlplus rman/oraclecatdbSQLselect * from db;二、 配置RMAN1,同时连接target数据库和reco

4、very catalog数据库oraclelocalhost $rman target sys/oracleorcl catalog rman/oraclecatdb2,RMANshow all(检查配置) configure default device type to disk ( 设置默认的备份的设备为磁盘) CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; (设置备份的并行级别) configure channel 1 device type disk format /home/new/backup_%

5、U(设置备份文件格式) configure channel 2 device type disk format /home/oracle/backup_%U(设置备份文件格式) configure controlfile autobackup on (打开控制文件的自动备份) configure controlfile autobackup format for device type disk to /home/new/ctl_%F (设置控制文件备份格式)三. 备份测试 备份全库1,同时连接target数据库和recovery catalog数据库oraclelocalhost $rman

6、 target sys/oracleorcl catalog rman/oraclecatdb2,RMAN backup database plus archivelog delete input;3,连接target数据库oraclelocalhost $sqlplus sys/oracleorcl as sysdbaSQL conn hr/hr;SQL select salary from employees where employee_id=157;SQL update employees set salary =2000 where employee_id=157;SQL commi

7、t;SQL select salary from employees where employee_id=157;四. 恢复测试复原及恢复全库1,连接target数据库oraclelocalhost $sqlplus sys/oracleorcl as sysdba2,把target数据库先关闭,然后启动到mount状态SQL shutdown immediate;SQL startup mount;3,复原及恢复全库RMAN restore database channel ORA_DISK_1: restore complete, elapsed time: 00:05:10RMAN re

8、cover databasemedia recovery complete, elapsed time: 00:00:074,连接target数据库oraclelocalhost $sqlplus sys/oracleorcl as sysdba5,打开target数据库SQL alter database open;6,查看已录入的事物SQL conn hr/hr;SQL select salary from employees where employee_id=157; 假设备份了一个表空间users 恢复表空间: rman target rman/rmantest2006 catalo

9、g rman/rmantest2007 sql alter tablespace users offline immediate(使TEST2006的USERS表空间脱机) 进入test2006 select tablespace_name,status from dba_tablespaces; (检查USERS已经脱机) 退出RMAN 删除D:oracleoradataTEST2006users01.dbf rman target rman/rmantest2006 catalog rman/rmantest2007 restore tablespace users recover tab

10、lespace users sql alter tablespace users online(使TEST2006的USERS表空间在线) 进入test2006 select tablespace_name,status from dba_tablespaces; (检查USERS已经在线)三、物理(热)备份。Linux 下Oracle10.2.0.1 RMAN备份及恢复步骤介绍切换服务器归档模式,如果已经是归档模式可跳过此步:%sqlplus /nolog (启动sqlplus)SQL conn / as sysdba (以DBA身份连接数据库)SQL shutdown immediate;

11、 (立即关闭数据库)SQL startup mount (启动实例并加载数据库,但不打开)SQL alter database archivelog; (更改数据库为归档模式)SQL alter database open; (打开数据库)SQL alter system archive log start; (启用自动归档)SQL exit (退出)2、连接:%rman target=gti/gti123LANDF; (启动恢复管理器)3、基本设置:RMAN configure default device type to disk; (设置默认的备份设备为磁盘)RMAN configure

12、 device type disk parallelism 2; (设置备份的并行级别,通道数)RMAN CONFIGURE CHANNEL 1 DEVICE TYPE DISK FORMAT /home/oracle/backup/data/backup_%U; (设置备份的文件格式,只适用于磁盘设备)RMAN CONFIGURE CHANNEL 2 DEVICE TYPE DISK FORMAT /home/oracle/backup/data1/backup_%U; (设置备份的文件格式,只适用于磁盘设备)RMAN configure controlfile autobackup on;

13、 (打开控制文件与服务器参数文件的自动备份)RMAN configure controlfile autobackup format for device type disk to /home/oracle/backup/data/ctl_%F; (设置控制文件与服务器参数文件自动备份的文件格式)4、查看所有设置:RMAN show all5、查看数据库方案报表:RMAN report schema;6、备份全库:RMAN backup database plus archivelog delete input; (备份全库及控制文件、服务器参数文件与所有归档的重做日志,并删除旧的归档日志)7

14、、备份表空间: 热备份(归档状态下才有效果) 1、alter tablespace tablespace_name start backup; 2、拷贝你的该表空间的数据文件备份 3、alter tablespace tablespace_name end backup; 4、一个一个表空间做完,就备份完了RMAN backup tablespace system plus archivelog delete input; (备份指定表空间及归档的重做日志,并删除旧的归档日志)RMAN backup tablespace UNDOTBS plus archivelog delete input

15、; (备份指定表空间及归档的重做日志,并删除旧的归档日志)RMAN backup tablespace SYSAUX plus archivelog delete input; (备份指定表空间及归档的重做日志,并删除旧的归档日志)RMAN backup tablespace TEMP plus archivelog delete input; (备份指定表空间及归档的重做日志,并删除旧的归档日志)8、备份归档日志:RMAN backup archivelog all delete input;9、复制数据文件:RMAN copy datafile 1 to /home/oracle/prod

16、uct/10.2.0.1/backup/system.copy;/*RMAN copy /home/oracle/data/gti_sys01.dbf to /home/oracle/product/10.2.0.1/backup/system.copy;RMAN copy /home/oracle/data/gti_undotbs.dbf 1 to /home/oracle/product/10.2.0.1/backup/undo.copy;RMAN copy /home/oracle/data/sysaux_01.dbf 1 to /home/oracle/product/10.2.0.1

17、/backup/sysaux.copy;*/10、查看备份和文件复本:RMAN list backup;11、验证备份:RMAN validate backupset 3;12、从自动备份中恢复服务器参数文件:RMAN shutdown immediate; (立即关闭数据库)RMAN startup nomount; (启动实例)RMAN restore spfile to pfile /backup1/initgti.ora from autobackup; (从自动备份中恢复服务器参数文件)13、从自动备份中恢复控制文件:RMAN shutdown immediate; (立即关闭数据库

18、)RMAN startup nomount; (启动实例)RMAN restore controlfile to /backup1 from autobackup; (从自动备份中恢复控制文件)13、恢复和复原全数据库:RMAN shutdown immediate; (立即关闭数据库)RMAN exit (退出)%mv /home/oracle/product/10.2.0.1/dbs/snapcf_gti.f /home/oracle/product/10.2.0.1/dbs/snapcf_gti.f.bak (将数据文件重命名)%rman target=gti/gti123LANDF;

19、(启动恢复管理器)RMAN startup pfile=/home/oracle/product/10.2.0.1/dbs/initgti.ora (指定初始化参数文件启动数据库)RMAN restore database; (还原数据库)RMAN recover database; (恢复数据库)RMAN alter database open; (打开数据库)14、恢复和复原表空间:RMAN sql alter tablespace users offline immediate; (将表空间脱机)RMAN exit (退出恢复管理器)%mv /home/oracle/product/10

20、.2.0.1/dbs/gti_sys01.dbf /home/oracle/data/gti_sys01.dbf.bak (将表空间重命名)%mv /home/oracle/data/gti_undotbs.dbf /home/oracle/data/gti_undotbs.dbf.bak (将表空间重命名)%mv /home/oracle/data/sysaux_01.dbf /home/oracle/data/sysaux_01.dbf.bak (将表空间重命名)%rman target=gti/gti123LANDF; (启动恢复管理器)RMAN restore tablespace u

21、sers; (还原表空间)RMAN recover tablespace users; (恢复表空间)RMAN sql alter tablespace users online; (将表空间联机)15、增量备份与恢复:第一天的增量基本备份:RMAN backup incremental level=0 database plus archivelog delete input;第二天的增量差异备份:RMAN backup incremental level=2 database plus archivelog delete input;第三天的增量差异备份:RMAN backup incremental level=2 database plus archivelog delete input;第四天的增量差异备份:RMAN backup incremental level=1 database p

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论