RMAN配置

$ rman target /        或rman target sys/[email protected]

RMAN> show all;查看系统里所有备份的配置

RMAN> CONFIGURE CONTROLFILE AUTOBACKUP On;打开控制文件自动备份

RMAN> CONFIGURE CONTROLFILE AUTOBACKUP clear; 恢复默认

RMAN> backup tablespace users;

RMAN> list backup;

SQL> desc v$backup_set          浏览器中也可以查看

自动通道管理:

RMAN> CONFIGURE DEVICE TYPE DISK PARALLELISM 2;

RMAN> backup tablespace users, example;

$ mkdir /home/oracle/disk1 /home/oracle/disk2

RMAN> configure channel 1 device type disk to destination ‘/home/oracle/disk1‘;

RMAN> configure channel 2 device type disk to destination ‘/home/oracle/disk2‘;

RMAN> backup tablespace users, example;

恢复默认

RMAN> CONFIGURE DEVICE TYPE DISK clear;

RMAN> CONFIGURE CHANNEL 1 device type disk clear;

RMAN> CONFIGURE CHANNEL 2 device type disk clear;

手动通道管理:

RMAN> run {

allocate channel c1 device type disk to destination ‘/home/oracle/disk1‘;

allocate channel c2 device type disk to destination ‘/home/oracle/disk2‘;

backup tablespace users, example;

backup (tablespace users channel c1)(tablespace example channel c2);

}

backup section size 500M datafile 1;

指定备份格式:

RMAN> backup tablespace users;生成标准备份集

RMAN> backup as compressed backupset tablespace users;生成压缩备份集

RMAN> backup as copy tablespace users;生成镜像文件备份集

RMAN> list backup of tablespace users;查看备份信息

RMAN> list copy of tablespace users;

备份的加密:

RMAN备份

不归档                                          归档

online       offline                          online       offline

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

shutdown nomount mount open

Backup  备份    datafile  数据文件  tablespace表空间  database数据库

备份数据文件:

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;incremental 增量的  level固定的后面一定要跟上

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> backup incremental level 1 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;              记录time和scn

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;              time和scn更新

脚本形式:

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;                      删除备份               report:报告

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恢复

时间: 2024-10-11 22:24:40

RMAN配置的相关文章

RMAN 配置、监控与管理

========================= -- RMAN 配置.监控与管理 --========================= 一.通道及通道分配 1.通道的概念 一个通道代表一个到设备(磁盘或磁带)的数据流并且在目标数据库或辅助数据库实例上产生一个相应的服务器会话(server session) 多个通道则产生多个服务器会话,这些服务器会话(或进程)将完成备份.还原与恢复操作等 通道分为备份或还原到磁盘的磁盘通道(disk channel).备份还原到磁带的磁带通道(SBT) 在

RMAN配置DataGuard from Active database with ASM

一.  环境 主库:安装grid软件及创建磁盘组:安装数据库软件并创建数据库, 备库:仅安装grid软件并创建asm磁盘组,同时安装数据库软件即可. 主机名 数据库版本 dbname db_unique_name ip地址 系统版本 server1(主) oracle11204 Jason jason 192.168.1.250 rhel6.6_x86_64 server2(备) jason2 192.168.1.252 二.  主库配置 1.  确定主数据库开启强制LOGGING模式 [[em

Rman配置DataGuard using Backup-based duplication with a target connection with filesystem

一.  环境 主机名 数据库版本 dbname db_unique_name IP地址 系统版本 Jason1(主) oracle11204 Jason jason1 192.168.1.99 rhel6.6_x86_64 jason2(备) jason2 192.168.1.100 二.  主库配置 1.  确定主数据库开启强制LOGGING模式 [[email protected] ~]$ sqlplus /nolog SQL*Plus: Release 11.2.0.4.0 Product

RMAN配置DataGuard from active database with filesystem

一.  环境 主机名 数据库版本 dbname db_unique_name IP地址 系统版本 Jason1(主) oracle11204 Jason jason1 192.168.1.99 rhel6.6_x86_64 jason2(备) jason2 192.168.1.10 二.  主库配置 1.  确定主数据库开启强制LOGGING模式 [[email protected] ~]$ sqlplus /nolog SQL*Plus: Release 11.2.0.4.0 Producti

Rman配置DataGuard 使用主库未配置时备份 with filesystem

一.    环境 主机名 数据库版本 dbname db_unique_name IP地址 系统版本 Jason1(主) oracle11204 Jason jason1 192.168.1.99 rhel6.6_x86_64 jason2(备) jason2 192.168.1.100 二.    主库配置 1.  确定主数据库开启强制LOGGING模式 [[email protected] ~]$ sqlplus /nolog SQL*Plus: Release 11.2.0.4.0 Pro

11g rman 配置catalog

1.官方文档 https://docs.oracle.com/cd/E11882_01/backup.112/e10642/rcmcatdb.htm#BRADV89656 2.配置步骤如下 --创建表空间 create tablespace catalog datafile size 2G; SQL> create tablespace catalog datafile size 2G; Tablespace created. SQL> --创建用户 CREATE USER rman IDEN

配置RMAN备份环境

关于配置RMAN备份环境你可以给每个目标数据库设置一些固定的配置,这些配置控制着RMAN多个方面的行为.例如,你可配置备份的保存策略.默认的备份目录.默认的备份设备类型等.你可以用show命令来查看配置及用configure来修改RMAN的配置. 1.查看和清除RMAN配置参数show命令可以查看RMAN当前的配置情况,以及这些参数当前是否设置了默认值.SHOW ALL; --查看说有的配置情况 你也可以通过SHOW命令加指定的配置参数的名字来查看它的值.例:SHOW RETENTION POL

RMAN查看配置、校验、备份记录和删除、改变状态备份

=================== 连接到目标数据库(不用恢复目录数据库) rman target / nocatalog 显示rman配置 RMAN> show all; ==================== 报告目标数据库的物理结构 RMAN> report schema; 报告陈旧备份 RMAN> report obsolete; 报告不可恢复的数据文件 RMAN> report unrecoverable; 列出备份信息 RMAN> list backup;

Oracle 11g R2 RAC RMAN备份脚本示例

一.将RAC切换成归档模式 1. 修改数据库的归档模式,通常在安装RAC的时候都会配置归档并且使用闪回区,已经配置过归档下面的方式可以略过. SQL> alter system set cluster_database=false scope=spfile sid='*'; 2. 关闭所有实例(两边都要shutdown) SQL> shutdown immediate 或直接关闭所有实例   $ srvctl stop database -d orcl 3. 在任意一个实例上将数据库启动到mo