备份篇
backup database format 'd:\backup_%U';
list backup of database;
backup tablespace users;
list backup of tablespace users;
delete backupset 4;
backup datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\DBCOOL\DATAFILE\O1_MF_USERS_5RBDL7B8_.DBF';
list backup of datafile 4;
backup current controlfile;
backup database include current controlfile;
backup datafile 1;
备份system表空间也会触发控制文件的自动备份
configure controlfile autobackup on;
rman做任何备份操作,都会自动对控制文件做备份
list backup of controlfile;
backup archivelog all;
backup current controlfile plus archivelog;
list backup of archivelog all;
backup backupset all; 备份备份集
list expired backup; 列出无效备份
delete obsolete;删除过期备份
crosscheck backup;检查所有备份集
delete expired backup;删除无效备份
delete backup; 删除所有备份集
report need backup;查看所有需要备份的文件
report obsolete;查看过期备份
change backupset n unavailable; 修改指定备份集状态为unavailable不可用
change archivelog logseq=n unavailable/delete;修改或删除指定归档文件状态为不可用
backup incremental level=0 database format 'd:\backup_database.dbf';
backup incremental level=1 tablespace users;
backup incremental level=1 datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\DBCOOL\DATAFILE\O1_MF_USERS_5RBDL7B8_.DBF';
oracle 10g后 启用block change tracking,rman不用再去扫描数据文件中的每一个块了,直接通过快变化跟踪文件就可以获取哪些块发生了修改的信息
alter database enable block change tracking;
alter database disable block change tracking;
select status from v$block_change_tracking;
注:虽然备份时间减少,备份集大小减少,但是进行恢复时,所花费的时间有可能增加,因为数据库恢复时不得不读取多个备份集才能完成恢复操作
对于基于时间的备份保留策略,一般建议control_file_record_keep_time初始化参数值不小于在rman中设置的备份保留时间
复合备份
backup copies 3 database;
run{
set backup copies 2;
backup device type disk format 'd:\1.dbf','d:\2.dbf' tablespace users;
}
生成两份备份集,分别存储到'd:\1.dbf'和'd:\2.dbf'目录
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; #
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1;#
自动分配通道时才有效
run{
allocate channel c1 device type disk maxpiecesize=10m format 'd:\backup_tablespace_system_%U';
backup tablespace system;
}
限制备份片段
rman恢复目录:可以运行脚本 保留更多历史信息 管理多个数据库
create tablespace rman datafile '***\rman.dbf' size 50m;
grant connect,resource,recovery_catalog_owner to rman identified by rman;
create catalog tablespace rman;
rman target / catalog rman/rman@dbcool
register database;
unregister database;
备份优化
configure backup optimization on;
只备份变化过,前提是没变化的文件必须已经备份过
对备份集进行压缩
backup as compressed backupset tablespace system;
启用加密备份
configure encryption for database on/off;数据库级加密
configure encryption for tablespace users on/off;表空间级加密
set encryption on identified by *** only; 恢复时必须使用密钥才能进行恢复
backup database skip inaccessiable plus archivelog filesperset 20 delete all input;
//inaccessiable 不可读的文件
//offline 跳过offline数据文件
//readonly 跳过read only数据文件
//filesperset 备份集中包含文件
//plus archivelog 会自动对归档日志进行归档
crosscheck backupset;
delete noprompt obsolete;
configure ....clear恢复默认设置
configure device type disk parallelism 2;设置并行备份注意执行的备份命令中要指定filesperset,否则无效
CONFIGURE ENCRYPTION ALGORITHM 'AES128';配置默认的加密算法
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE;配置归档文件删除策略
两个选项:设置成applied on standby时当通过附加的delete input子句删除standby数据库任需要的日志时会报错,不过用户任然可以手动通过delete archivelog方式删除
设置成none,则不启用归档文件的删除策略
通过set命令进行会话级配置
set dbid n 指定数据库标识符 n 10为数字组成 只能在nomount模式下执行
给数据文件指定新的路径和名称
set newname for datafile 4 to 'd:\users01.dbf';
设置恢复到的时间点或scn
set until time "to_date('2009-4-18 14:23:54','yyyy-mm-dd hh24:mi:ss')";
定义备份片段的冗余数
set backup copies 3;
指定归档日志存储路径
set archivelog destination to 'd:\archive\';
差异备份和增量备份区别:
差异备份是同级别间是认可的,增量备份同级别间是不认可的,增量备份恢复效率要高些
backup database format 'd:\backup_%U';
list backup of database;
backup tablespace users;
list backup of tablespace users;
delete backupset 4;
backup datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\DBCOOL\DATAFILE\O1_MF_USERS_5RBDL7B8_.DBF';
list backup of datafile 4;
backup current controlfile;
backup database include current controlfile;
backup datafile 1;
备份system表空间也会触发控制文件的自动备份
configure controlfile autobackup on;
rman做任何备份操作,都会自动对控制文件做备份
list backup of controlfile;
backup archivelog all;
backup current controlfile plus archivelog;
list backup of archivelog all;
backup backupset all; 备份备份集
list expired backup; 列出无效备份
delete obsolete;删除过期备份
crosscheck backup;检查所有备份集
delete expired backup;删除无效备份
delete backup; 删除所有备份集
report need backup;查看所有需要备份的文件
report obsolete;查看过期备份
change backupset n unavailable; 修改指定备份集状态为unavailable不可用
change archivelog logseq=n unavailable/delete;修改或删除指定归档文件状态为不可用
backup incremental level=0 database format 'd:\backup_database.dbf';
backup incremental level=1 tablespace users;
backup incremental level=1 datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\DBCOOL\DATAFILE\O1_MF_USERS_5RBDL7B8_.DBF';
oracle 10g后 启用block change tracking,rman不用再去扫描数据文件中的每一个块了,直接通过快变化跟踪文件就可以获取哪些块发生了修改的信息
alter database enable block change tracking;
alter database disable block change tracking;
select status from v$block_change_tracking;
注:虽然备份时间减少,备份集大小减少,但是进行恢复时,所花费的时间有可能增加,因为数据库恢复时不得不读取多个备份集才能完成恢复操作
对于基于时间的备份保留策略,一般建议control_file_record_keep_time初始化参数值不小于在rman中设置的备份保留时间
复合备份
backup copies 3 database;
run{
set backup copies 2;
backup device type disk format 'd:\1.dbf','d:\2.dbf' tablespace users;
}
生成两份备份集,分别存储到'd:\1.dbf'和'd:\2.dbf'目录
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; #
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1;#
自动分配通道时才有效
run{
allocate channel c1 device type disk maxpiecesize=10m format 'd:\backup_tablespace_system_%U';
backup tablespace system;
}
限制备份片段
rman恢复目录:可以运行脚本 保留更多历史信息 管理多个数据库
create tablespace rman datafile '***\rman.dbf' size 50m;
grant connect,resource,recovery_catalog_owner to rman identified by rman;
create catalog tablespace rman;
rman target / catalog rman/rman@dbcool
register database;
unregister database;
备份优化
configure backup optimization on;
只备份变化过,前提是没变化的文件必须已经备份过
对备份集进行压缩
backup as compressed backupset tablespace system;
启用加密备份
configure encryption for database on/off;数据库级加密
configure encryption for tablespace users on/off;表空间级加密
set encryption on identified by *** only; 恢复时必须使用密钥才能进行恢复
backup database skip inaccessiable plus archivelog filesperset 20 delete all input;
//inaccessiable 不可读的文件
//offline 跳过offline数据文件
//readonly 跳过read only数据文件
//filesperset 备份集中包含文件
//plus archivelog 会自动对归档日志进行归档
crosscheck backupset;
delete noprompt obsolete;
configure ....clear恢复默认设置
configure device type disk parallelism 2;设置并行备份注意执行的备份命令中要指定filesperset,否则无效
CONFIGURE ENCRYPTION ALGORITHM 'AES128';配置默认的加密算法
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE;配置归档文件删除策略
两个选项:设置成applied on standby时当通过附加的delete input子句删除standby数据库任需要的日志时会报错,不过用户任然可以手动通过delete archivelog方式删除
设置成none,则不启用归档文件的删除策略
通过set命令进行会话级配置
set dbid n 指定数据库标识符 n 10为数字组成 只能在nomount模式下执行
给数据文件指定新的路径和名称
set newname for datafile 4 to 'd:\users01.dbf';
设置恢复到的时间点或scn
set until time "to_date('2009-4-18 14:23:54','yyyy-mm-dd hh24:mi:ss')";
定义备份片段的冗余数
set backup copies 3;
指定归档日志存储路径
set archivelog destination to 'd:\archive\';
差异备份和增量备份区别:
差异备份是同级别间是认可的,增量备份同级别间是不认可的,增量备份恢复效率要高些
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/22253646/viewspace-667004/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/22253646/viewspace-667004/