`
logicgate
  • 浏览: 98631 次
  • 性别: Icon_minigender_1
  • 来自: 新力吐皮
社区版块
存档分类
最新评论

Oracle 学习笔记: Backup & Recovery 常用命令

阅读更多

1 . set database to archivelog mode

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

SQL> startup mount;
ORACLE instance started.

Total System Global Area  251658240 bytes
Fixed Size                  1248356 bytes
Variable Size              83887004 bytes
Database Buffers          159383552 bytes
Redo Buffers                7139328 bytes
Database mounted.

SQL> alter database archivelog;
Database altered.

SQL> alter database open;
Database altered.

SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     1319
Next log sequence to archive   1321
Current log sequence           1321

 

2 . define flash recovery area

SQL> alter system set db_recovery_file_dest='D:\oracle\flash_recovery_area' scope=both;
System altered.
SQL> alter system set db_recovery_file_dest_size=15G scope=both;
System altered.

 

Oracle will use Oracle Managed File (OMF) for the flash recovery area. The free space in recovery area can be checked using OEM: All Metrics -> Recovery Area, or query vflash_recovery_area_usage view. To get more free space, you can use the following command to backup and then delete all the archived log files.

RMAN> backup archivelog all delete all input; 

 

3 . define multiple archived log destinations

SQL> alter system set log_archive_dest_1='location=use_db_recovery_file_dest' scope=both;
System altered.
SQL> alter system set log_archive_dest_2='location=D:\oracle\archivelog_area1' scope=both;
System altered.

 

4 . CONTROL_FILE_RECORD_KEEP_TIME

 

This parameter specify the minimum days the RMAN information is stored in the control file before overwritten. The default value is 7 days. When using catalog, a smaller value should be chosen.

 

5 . starting RMAN

rman target /
rman target / nocatalog
rman target sys/change_on_install@orcl
rman target sys/change_on_install@orcl catalog rman/rman@catdb
rman target sys/change_on_install log=xxx.log append
rman target sys/change_on_install cmdfile=xxx.rcv

 

6 . RMAN persistent settings

 

6.1 display settings

RMAN> show all;
RMAN> show controlfile autobackup;
RMAN> show retention policy;

 

6.2 configure settings

RMAN> configure retention policy to recovery window of 7 days;
RMAN> configure backup optimization on;
RMAN> configure default device type to disk;
RMAN> configure controlfile autobackup on;
RMAN> configure controlfile autobackup format for device type disk to '%F';
RMAN> configure device type disk backup type to compressed backupset parallelism 1;
RMAN> configure datafile backup copies for device type disk to 1;
RMAN> configure archivelog backup copies for device type disk to 1;
RMAN> configure channel device type disk maxpiecesize 1 G;
RMAN> configure maxsetsize to unlimited;
RMAN> configure encryption for database off;
RMAN> configure encryption algorithm 'AES128';
RMAN> configure archivelog deletion policy to none;
RMAN> configure snapshot controlfile name to 'D:\oracle\flash_recovery_area\sncfepcit.ora';

 

If the control file autobackup is enabled, then RMAN automatically backs up the control file and spfile in one of two circumstances:
- A successful backup is recorded in the RMAN repository
- A structural change to the database affects the contents of the control file

Control file autobackups are stored in the flash recovery area, unless otherwise specified.

 

6.3 reset settings to default value

RMAN> configure controlfile autobackup clear;
RMAN> configure retention policy clear;

 

7. RMAN commands

 

7.1 backup commands

RMAN> backup database;
RMAN> backup copy of database;
RMAN> backup as compressed backupset database;
RMAN> backup as backupset format ''/BACKUP/df_%d_%s_%p.bus' tablespace users;
RMAN> backup database plus archivelog delete all input;
RMAN> backup archivelog from sequence=234 delete input;
RMAN> backup tag='month_full_backup' datafile 1, 2, 3, 4;
RMAN> backup incremental level 0 database;
RMAN> backup incremental level 1 database;
RMAN> backup incremental level 1 cumulative database;

RMAN> run {
2> allocate channel c1 device type sbt;
3> allocate channel c2 device type sbt;
4> allocate channel c3 device type sbt;
5> backup incremental level = 0
6> format '/disk1/backup/df_%d_%s_%p.bak'
7> (datafile 1,4,5 channel c1)
8> (datafile 2,3,9 channel c2)
9> (datafile 6,7,8 channel c3);
10> alter system archive log current;
11> }

 

7.2 block change tracking

SQL> alter database enable block change tracking using file ''/mydir/rman_change_track.f' reuse;
SQL> alter database disable block change tracking;

 

7.3 incrementally updating backups

RMAN> backup as copy incremental level 0 datafile 1 tag 'basecopy';
RMAN> backup incremental level 1 for recover of copy with tag 'basecopy' datafile 1;
RMAN> recover copy of datafile 1 with tag 'basecopy';

 

7.4 list commands

RMAN> list backup of database summary;
RMAN> list backup of tablespace system summary;
RMAN> list backup of datafile {n|'file_name'} summary;
RMAN> list backup of database by {file|backup};
RMAN> list copy of database;

 

7.5 report commands

RMAN> report schema;
RMAN> report need backup incremental 0 database;
RMAN> report need backup days 3;
RMAN> report need backup redundancy 2;
RMAN> report need backup recovery window of 3 days;
RMAN> report obsolete redundancy 2;
RMAN> report obsolete recovery window of 3 days;

 

7.6 delete commands

RMAN> delete noprompt expired copy;
RMAN> delete noprompt expired backup;
RMAN> delete noprompt obsolete;
RMAN> delete obsolete redundancy 2;
RMAN> delete obsolete recovery window of 3 days;
RMAN> delete backupset 4;

 

8. RMAN v$ views

V$ARCHIVED_LOG
V$BACKUP_CORRUPTION
V$BACKUP_DEVICE
V$BACKUP_FILES
V$BACKUP_PIECE
V$BACKUP_REDOLOG
V$BACKUP_SET
V$BACKUP_SPFILE
V$COPY_CORRUPTION
V$RMAN_CONFIGURATION
分享到:
评论

相关推荐

    DAVE Oracle RMAN 学习笔记

    ### DAVE Oracle RMAN 学习笔记 #### RMAN(Recovery Manager)工作原理与实现过程 RMAN作为Oracle数据库的备份与恢复工具,在Oracle环境中扮演着至关重要的角色。RMAN并非直接执行备份操作,而是作为一个协调者,...

    rman读书笔记

    RMAN(Recovery Manager)是 Oracle 数据库的一种备份和恢复工具,提供了各种备份命令,涉及数据库备份、文件备份、表空间备份、控制文件备份、初始化参数备份、增量备份(差异和累积)等多种备份方式。本文将对 ...

    oracle学习笔记

    ### Oracle学习笔记知识点详解 #### 一、Oracle内存结构 Oracle数据库在运行时会占用大量内存,这些内存被划分为不同的区域,每种区域都服务于特定的目的。 ##### 1. SGA (System Global Area) SGA是Oracle实例...

    韩顺平 oracle 课堂笔记

    韩顺平的课堂笔记中,涉及了数据库的备份与恢复策略,包括逻辑备份(logical backup)和物理备份(physical backup)的区别,以及如何使用Oracle的RMAN (Recovery Manager) 工具进行高效的数据恢复。 #### 九、Oracle ...

    Oracle 19C OCP课堂笔记.zip

    - **Backup and Recovery**: 学习RMAN(恢复管理器)备份策略、增量备份、归档日志管理以及介质恢复。 - **Performance Tuning**: 使用AWR(自动工作负载仓库)、ASH(活动会话历史)和SQL Tuning Advisor进行性能...

    RMAN学习笔记

    Oracle RMAN(Recovery Manager)是Oracle数据库管理系统中一个强大的备份和恢复工具,它提供了全面的数据保护方案,包括备份、恢复、数据复制、性能优化等多个功能。本学习笔记将逐步介绍RMAN的基础知识,帮助初学...

    《涂抹Oracle_三思笔记之一步一步学Oracle》360页精简版

    ### Oracle学习精简版知识点概览 #### 一、Oracle发展历程概述 - **起源** (1977年): Oracle由Larry Ellison、Bob Miner和Ed Oates创立,初衷是为美国中央情报局(CIA)开发数据库软件。 - **发展** (1980年代): ...

    rman学习笔记.txt

    ### RMAN 学习笔记详解 #### 一、RMAN 基础概念与环境配置 **RMAN(Recovery Manager)**是Oracle数据库提供的一个强大的备份与恢复工具,能够帮助用户实现对Oracle数据库的数据备份、恢复以及灾难恢复等功能。 ...

    oracle rman笔记

    ### Oracle RMAN学习笔记 #### 一、RMAN概述与基本概念 RMAN(Recovery Manager)是Oracle数据库提供的一款强大的备份与恢复工具,用于管理数据库的备份与恢复操作,提高系统的可恢复性和数据安全性。 - **RMAN的...

    Oracle Rman 详解

    Oracle RMAN,全称为Recovery Manager,是Oracle数据库系统中用于数据备份与恢复的重要工具。它提供了全面的数据保护方案,包括备份、恢复、检查点管理、数据库克隆以及介质故障的处理。以下是对Oracle RMAN的详细...

    Oracle11g维护培训课件(华为内部教材)

    - **Improved Backup and Recovery Tools**:改进了备份与恢复工具,如RMAN(Recovery Manager)。 #### 三、Oracle 11g维护关键技术 ##### 3.1 数据库备份与恢复 - **RMAN**:用于数据库备份和恢复的核心工具。 -...

    一步一步学RMAN_三思笔记.pdf

    “一步一步学RMAN_三思笔记.pdf”是一份关于Oracle Recovery Manager(简称RMAN)的学习资料,主要面向初学者,通过轻松幽默的语言介绍了RMAN的基本概念、操作方式以及如何进行数据库的备份与恢复等关键知识点。...

    oracle 9i rman 备份与恢复技术.pdf

    本文将基于“Oracle 9i RMAN 备份与恢复技术”学习笔记,深入探讨RMAN的设置、配置以及关键操作,包括备份、恢复和高级恢复技术。 #### 配置数据库为ARCHIVELOG模式 在Oracle 9i中,为了充分利用RMAN的功能,强烈...

    10g备份与恢复读书笔记hxp.pdf

    通过学习这些内容,可以帮助DBA更好地掌握Oracle 10g的备份恢复机制,为保障数据安全提供有力的支持。需要注意的是,在实际操作过程中还需结合具体的业务需求和环境特点来灵活运用这些技术。 以上内容涵盖了文档中...

    网络宝典123

    ### Oracle学习1_笔记知识点详解 #### 一、Oracle职业方向定位 - **开发方向**: - **主要内容**:编写存储过程、触发器以及使用Oracle的开发工具(如Oracle Developer Suite)创建form。 - **技能要求**:较强...

    [三思笔记]一步一步学RMAN

    ### 从《三思笔记》逐步学习RMAN #### 一、引言 RMAN(Recovery Manager)是Oracle数据库自带的一款强大而灵活的数据备份与恢复工具。它为Oracle数据库管理员提供了一系列自动化备份和恢复解决方案,包括增量备份...

    [三思笔记]一步一步学rman【精华】

    RMAN(Recovery Manager)是Oracle数据库管理系统中的一项重要工具,用于实现数据库的备份、恢复和灾难恢复等功能。它能够有效地保护数据库免受物理损坏,并且可以高效地进行数据恢复。本文将基于“[三思笔记]一步...

Global site tag (gtag.js) - Google Analytics