RMAN 备份的概念和术语
1、open 状态的备份
2、closed 状态的备份
3、complete backup
4、Incremental backup
冷备份:一致性备份、脱机备份、closed 备份
热备份:非一致性备份、热备份、open 备份
open 状态的备份只能在处于归档日志方式进行,在非归档模式下只能进行clean closed 备份,并且数据库必须启动到 mounted 状态
RMAN 可以备份的文件:
data file
control file
archived redo logfile
spfile
backupset piece
RMAN 无法备份的文件:
临时文件(临时表空间)
online redo logfile
password file
static pfile
Oracle Net 配置文件
RMAN 可以生成的备份类型:
backup set:可以使完整备份集,也可以是增量备份集
compressed backup set
image copy:只能是完整的备份文件副本
RMAN 的备份和还原均由称为 channel 的 server process 执行,channel 可以是 disk 类型
也可以是 sbt 磁带类型
RMAN repository (知识库)存储有关备份的元数据:
包括构成备份集的piece的名称和位置、backup piece 中包含的文件及 image 副本的名称和位置
RMAN 知识库是自动备份和恢复的关键,RMAN 通过知识库计算出备份和还原的最有效方式。
知识库存储在控制文件中,如果配置了 catalog 数据库,也会存储在 catalog 数据库中。
target database:要 backup、restore 或 recover 的数据库
catalog database:存储 RMAN 备份的元数据,可以集中存储多个数据库的备份元数据
auxiliary database:用于利用备份集 duplicate standby database 和 auxiliary database
Server managed backup
一致性备份(冷备份)
条件:clearn close 数据库,startup mount 数据库
要执行一致性备份,数据库必须处于 mounted 状态,原因如下:
RMAN 需要读取控制文件,以便查找要备份的数据文件。如果在 mounted 状态下使用 user-managed 备份
,这种备份将无效。因为在 mounted 状态下,复制控制文件时,可能已对控制文件执行了 write 操作。这样
通过操作系统命令复制的控制文件副本就与实际控制文件不一致了。RMAN 通过获取控制文件的 read consistence
快照并对其进行备份,以避免此问题。
RMAN 冷备脚本
run {
shutdown immediate;
startup mount;
allocate channel ch1 type disk;
allocate channel ch2 type disk;
allocate channel ch3 type disk;
backup as compressed backupset database
format '/backup/full/full_%U.bak';
alter database open;
}
存储为脚本 closed_full_backup.rman 执行
rman target / @/home/oracle/scripts/bin/closed_full_backup.rman
使用 Database Control schedule backup job 执行自动脱机备份
配置过程请见文档,备份脚本如下:
run {
allocate channel oem_backup_disk1 type disk format '/backup/level_0/%U' maxpiecesize 2 G;
allocate channel oem_backup_disk2 type disk format '/backup/level_0/%U' maxpiecesize 2 G;
allocate channel oem_backup_disk3 type disk format '/backup/level_0/%U' maxpiecesize 2 G;
backup incremental level 0 cumulative as BACKUPSET tag '%TAG' database;
backup as BACKUPSET tag '%TAG' archivelog all not backed up;
release channel oem_backup_disk1;
release channel oem_backup_disk2;
release channel oem_backup_disk3;
}
run {
allocate channel oem_backup_disk1 type disk format '/backup/level_0/%U' maxpiecesize 1000 G;
allocate channel oem_backup_disk2 type disk format '/backup/level_0/%U' maxpiecesize 1000 G;
allocate channel oem_backup_disk3 type disk format '/backup/level_0/%U' maxpiecesize 1000 G;
backup as BACKUPSET tag '%TAG' current controlfile;
release channel oem_backup_disk1;
release channel oem_backup_disk2;
release channel oem_backup_disk3;
}
1、open 状态的备份
2、closed 状态的备份
3、complete backup
4、Incremental backup
冷备份:一致性备份、脱机备份、closed 备份
热备份:非一致性备份、热备份、open 备份
open 状态的备份只能在处于归档日志方式进行,在非归档模式下只能进行clean closed 备份,并且数据库必须启动到 mounted 状态
RMAN 可以备份的文件:
data file
control file
archived redo logfile
spfile
backupset piece
RMAN 无法备份的文件:
临时文件(临时表空间)
online redo logfile
password file
static pfile
Oracle Net 配置文件
RMAN 可以生成的备份类型:
backup set:可以使完整备份集,也可以是增量备份集
compressed backup set
image copy:只能是完整的备份文件副本
RMAN 的备份和还原均由称为 channel 的 server process 执行,channel 可以是 disk 类型
也可以是 sbt 磁带类型
RMAN repository (知识库)存储有关备份的元数据:
包括构成备份集的piece的名称和位置、backup piece 中包含的文件及 image 副本的名称和位置
RMAN 知识库是自动备份和恢复的关键,RMAN 通过知识库计算出备份和还原的最有效方式。
知识库存储在控制文件中,如果配置了 catalog 数据库,也会存储在 catalog 数据库中。
target database:要 backup、restore 或 recover 的数据库
catalog database:存储 RMAN 备份的元数据,可以集中存储多个数据库的备份元数据
auxiliary database:用于利用备份集 duplicate standby database 和 auxiliary database
Server managed backup
一致性备份(冷备份)
条件:clearn close 数据库,startup mount 数据库
要执行一致性备份,数据库必须处于 mounted 状态,原因如下:
RMAN 需要读取控制文件,以便查找要备份的数据文件。如果在 mounted 状态下使用 user-managed 备份
,这种备份将无效。因为在 mounted 状态下,复制控制文件时,可能已对控制文件执行了 write 操作。这样
通过操作系统命令复制的控制文件副本就与实际控制文件不一致了。RMAN 通过获取控制文件的 read consistence
快照并对其进行备份,以避免此问题。
RMAN 冷备脚本
run {
shutdown immediate;
startup mount;
allocate channel ch1 type disk;
allocate channel ch2 type disk;
allocate channel ch3 type disk;
backup as compressed backupset database
format '/backup/full/full_%U.bak';
alter database open;
}
存储为脚本 closed_full_backup.rman 执行
rman target / @/home/oracle/scripts/bin/closed_full_backup.rman
使用 Database Control schedule backup job 执行自动脱机备份
配置过程请见文档,备份脚本如下:
run {
allocate channel oem_backup_disk1 type disk format '/backup/level_0/%U' maxpiecesize 2 G;
allocate channel oem_backup_disk2 type disk format '/backup/level_0/%U' maxpiecesize 2 G;
allocate channel oem_backup_disk3 type disk format '/backup/level_0/%U' maxpiecesize 2 G;
backup incremental level 0 cumulative as BACKUPSET tag '%TAG' database;
backup as BACKUPSET tag '%TAG' archivelog all not backed up;
release channel oem_backup_disk1;
release channel oem_backup_disk2;
release channel oem_backup_disk3;
}
run {
allocate channel oem_backup_disk1 type disk format '/backup/level_0/%U' maxpiecesize 1000 G;
allocate channel oem_backup_disk2 type disk format '/backup/level_0/%U' maxpiecesize 1000 G;
allocate channel oem_backup_disk3 type disk format '/backup/level_0/%U' maxpiecesize 1000 G;
backup as BACKUPSET tag '%TAG' current controlfile;
release channel oem_backup_disk1;
release channel oem_backup_disk2;
release channel oem_backup_disk3;
}