码迷,mamicode.com
首页 > 其他好文 > 详细

17.08.15

时间:2017-08-19 11:13:25      阅读:223      评论:0      收藏:0      [点我收藏+]

标签:fast   list   track   space   date   clear   ati   show all   报告   

RMAN备份

                  不归档                                       归档

         online       offline                        online       offline

完全  部分 完全  部分            完全  部分  完全  部分

 

shutdown nomount mount open

 

备份数据文件:

1.全数据库备份,部分备份

2.  联机备份(热备份)<数据库开启,一致性有差别>,脱机备份(冷备份)<关闭数据库之后备份,一致性高>

SQL> select file_id, file_name from dba_data_files;

RMAN> backup datafile 4;

RMAN> backup datafile 4, 5;

RMAN> backup datafile ‘/u01/app/oracle/oradata/orcl/users01.dbf‘;    备份数据文件

RMAN> backup tablespace users;   备份表空间(表空间中的文件)

RMAN> backup tablespace users, example;

RMAN> backup database;   备份数据库

RMAN> list backup;   查看备份

desc v$backup_set,浏览器查看备份

 

增量备份:

RMAN> backup incremental level 0 tablespace users;

RMAN> list backup of tablespace users;

SQL> create table t1(x int) tablespace users;

SQL> insert into t1 values (1);

SQL> commit;

RMAN> backup incremental level 1 tablespace users;

RMAN> list backup of tablespace users;

SQL> create table t2(x int) tablespace users;

SQL> insert into t2 values (1);

SQL> commit;

RMAN> backup incremental level 1 cumulative tablespace users;

RMAN> list backup of tablespace users;

开启块跟踪:

SQL> alter database enable block change tracking using file ‘/home/oracle/blk_trk.chg‘;

需要重新连接会话

SQL> select * from v$block_change_tracking;

SQL> select DATAFILE_BLOCKS, BLOCKS_READ, BLOCKS, USED_CHANGE_TRACKING from v$backup_datafile where INCREMENTAL_LEVEL>0;

SQL> create table t3(x int) tablespace users;

SQL> insert into t3 values (1);

SQL> commit;

RMAN> backup incremental level 1 tablespace users;

SQL> select DATAFILE_BLOCKS, BLOCKS_READ, BLOCKS, USED_CHANGE_TRACKING from v$backup_datafile where INCREMENTAL_LEVEL>0;

SQL> alter database disable block change tracking;               关闭

 

增量更新:

SQL> create table t1(x int) tablespace users;

SQL> insert into t1 values (1);

SQL> commit;

RMAN> backup incremental level 1 for recover of copy with tag ‘update_copy‘ tablespace users;         第一次创建的是0级备份

RMAN> list copy;              记录timescn

SQL> insert into t1 values (2);

SQL> commit;

RMAN> backup incremental level 1 for recover of copy with tag ‘update_copy‘ tablespace users;         2次创建的是1级备份

RMAN> list backup;         backupset格式

RMAN> recover copy of tablespace users with tag ‘update_copy‘;

RMAN> list copy;              timescn更新

脚本形式:

RMAN> run {

backup incremental level 1 for recover of copy with tag ‘update_copy‘ tablespace users;

recover copy of tablespace users with tag ‘update_copy‘;

}

 

备份归档日志:

RMAN> list archivelog all;

RMAN> backup archivelog all delete all input;  备份归档全部删除所有输入

RMAN> list archivelog all;

RMAN> list backup;

 

备份的维护:

查看:

RMAN> list backup;

RMAN> list copy;

RMAN> list backup of tablespace users;

RMAN> list backup of datafile 4;

RMAN> list archivelog all;

检查备份:

RMAN> delete backup;                    删除备份

RMAN> delete copy;

RMAN> list backup;         list copy;

RMAN> report need backup;          根据策略检查

RMAN> backup tablespace users;

RMAN> report need backup;

RMAN> CONFIGURE RETENTION POLICY TO REDUNDANCY 2;

RMAN> report need backup;

RMAN> CONFIGURE RETENTION POLICY clear;

RMAN> report obsolete;    报告所有废弃的备份

删除备份:

RMAN> delete backupset of tablespace users;

RMAN> delete backupset 1234;

RMAN> backup tablespace users;

RMAN> backup tablespace users;

RMAN> show all;

RMAN> delete obsolete;    删除超过冗余度的备份

crosscheck:

RMAN> delete backup;

RMAN> backup tablespace users;

RMAN> list backup of tablespace users;

$ mv /u01/app/oracle/fast_recovery_area/ORCL/backupset/…           改名

RMAN> restore datafile 4;               报错

RMAN> crosscheck backup;

RMAN> list backup of tablespace users;         报废状态

RMAN> list expired backup;

$ mv /u01/app/oracle/fast_recovery_area/ORCL/backupset/…            恢复原名

RMAN> crosscheck backup;

RMAN> list backup of tablespace users;         可用状态

RMAN> delete expired backup;

catalog:

$ cp /u01/app/oracle/fast_recovery_area/ORCL/backupset/…             复制

RMAN> delete backup;

RMAN> list backup;         backupset消失

$ mv /u01/app/oracle/fast_recovery_area/ORCL/backupset/…            恢复原名

RMAN> catalog recovery area noprompt;

RMAN> list backup;         backupset恢复

17.08.15

标签:fast   list   track   space   date   clear   ati   show all   报告   

原文地址:http://www.cnblogs.com/Zhang-x/p/7395306.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!