关闭

ORACLE RMAN备份的脚本配置

805人阅读 评论(0) 收藏 举报

ORACLE RMAN备份的脚本配置

一: 备份;

1:连接目标数据库:

rman>connect target sys/sysray@db或者rman target=sys/sysray@db


2:查询目标数据库的配置情况;

RMAN> SHOW ALL;

修改成如下配置:

CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION ON;
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO 'F:rman_back%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE CHANNEL 1 DEVICE TYPE DISK FORMAT "F:rman_back%U";
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO 'F:rman_backSNCFRAYDB.ORA';

3:备份控制和数据文件

RMAN>backup database;

4:备份日志文件;

rman>backup archivelog all delete input;

二: 恢复:

1:先将数据库工作在'已装载'模式下;

sql>shutdown immediate;

sql>startup mount;

sql>select status from v$instance;

2:rman>restore database;

3:rman>recover database;

数据库恢复成功;

sql>alter database open;

OK;

<二>:表空间的备份与恢复;数据库要工作在归档日志模式下;

1:表空间的备份;

rman>backup (tablespace users include current controlfile);

2:备份归档日志;

rman>backup (archivelog all delete input);

3:表空间恢复;

3.1:表空间的脱机;

rman> sql'alter tablespace users offline immediate';

3.2:表空间所属数据文件还原;

rman>restore(tablespace users);

3.3:表空间恢复过程;

rman>recover tablespace users;

3.4:表空间联机的过程;

rman>sql'alter tablespace users online';

<三>:数据文件的备份恢复;数据库要工作在归档日志模式下;

1:备份数据文件;

rman>backup (datafile 'd:oracleoradatadbnameusers01.dbf');

2:备份所有归档日志文件;

rman>backup (archivelog all delete input);

3:数据文件的恢复;

3.1:将数据文件所属的表空间users脱机;

rman>sql'alter tablespace users offline immediate';

3.2:将数据文件还原的过程;

rman>restore (datafile 'd:oracleoradatadbnameusers01.dbf') ;

3.3:数据文件的恢复过程;

rman>recover datafile 'd:oracleoradatadbnameusers01.dbf';

3.4数据文件所属的表空间的联机;

rman>sql'alter tablespace users online';

OK;

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:19056次
    • 积分:283
    • 等级:
    • 排名:千里之外
    • 原创:8篇
    • 转载:2篇
    • 译文:0篇
    • 评论:4条
    文章存档
    最新评论