ITPub博客

首页 > Linux操作系统 > Linux操作系统 > oracle备份

oracle备份

原创 Linux操作系统 作者:lelepapa 时间:2011-11-09 19:09:54 0 删除 编辑

备份

1 冷备份
完全脱机备份(achivelog|noarchivelog)
shutdown
copy


2部分脱机备份(归档模式)表空间
offline
os copy


3部分联机备份
alter tablespace users begin backup;

oracle10g支持alter database begin backup;
select * from v$backup(里面就是恢复的起点);
比change#小得都已经记录在数据文件里面

备份也需要copy数据
这个我觉得只是记录一个点。。就是从哪里开始恢复

alter tablespace users end backup;
copy完需要给这个命令来结束备份

这种备份有风险

看看oracle的解释

Detection of Fractured Blocks During Open Backups

One danger in making online backups is the possibility of inconsistent data within a block. For example, assume that you are backing up block 100 in datafile users.dbf. Also, assume that the copy utility reads the entire block while DBWR is in the middle of updating the block. In this case, the copy utility may read the old data in the top half of the block and the new data in the bottom top half of the block. The result is called a fractured block, meaning that the data contained in this block is not consistent. at a given SCN.

When performing backups of an open tablespace without using RMAN, you must put tablespaces in backup mode to prevent the creation of fractured blocks in your backup. When not in backup mode, the database records only changed bytes in the redo stream. When a tablespace is in backup mode, each time a block is changed the database writes the before-image of the entire block to the redo stream before modifying the block. Then, the database also records the changes to the block in the redo log. During user-managed recovery using SQL*Plus, the database applies both the captured block images and the recorded block changes from the redo logs. Applying the block images repairs any possible fractured blocks in the backup being restored and recovered.

RMAN does not require that you put datafiles into backup mode. During an RMAN backup, a database server session reads each block of the datafile and checks whether each block is fractured by comparing the block header and footer. If a block is fractured, the session re-reads the block. If the same fracture is found, then the block is considered permanently corrupt. If MAXCORRUPT is exceeded, the backup stops.

 

 

4,rman

run{

allocate channel  c1 device type disk;

allocate channel  c2 device type disk;

backup as compressed backupset database

}

 

list backup;

crosscheck backupset;

delete expired backupset;

list backup of database;

 

restore preview database;预览oracle使用哪个来恢复

from tag= 或者空格

还可以备份tablespace  datafile
backup current controlfile;备份当前控制文件;
在oracle高级技术里面v$database里面的controlfile_type也可能是standby
backup spfile;
临时文件和redo不能备份;必须要求open以及archivelog模式;
 
用rman非归档模式必须在mount的时候备份,也就是冷备份;
还可以备份archivelog
 
backup archivelog all
backup archivelog all not backed up备份新的归档日志。备份archivelog的时候需要切换日志;
backup archivelog all delete input;备份完删除磁盘上的归档日志;
 
手动维护rman备份
delete  noprompt  backup;
删除所有backup;
 
delete backupset  19;
删除一个备份级别;
 
list backupset 17可以列出单独的备份片;
 
 
crosscheck archivelog all ;
delete expired archivelog all;
 
 
rman的有个设置show all可以看到。
retention policy redundance 1;默认保留一份完整的有效备份,其他均废弃;
可修改为7天
configure retention policy to recovery window 7 days;
report obsolete 查看废弃的备份
delete obsolete 删除废弃备份;
 
 
report schema;在rman里看数据库的物理结构;
 
backup database;
delete noprompt obsolete;
backup archivelog all;
 
configure backup optimiztion on;则备份过的archivelog就不备份了。
configure controlfile autobackup off;如果打开,不管你备份什么,控制文件都自动备份;
 
list backup of archivelog sequece 71;查看日志文件71号;
 
配置缺省就最后加上clear;
只要我们备份system表空间包含的数据文件。则自动备份controlfile以及spfile;
 
 
完全脱机备份缺点
1shutdown
2copy
部分脱机备份(tablespace offline)
copy
online
事物之后 offline 损坏
online
 
rman读取的保留策略的时间是从哪里得到的?
configure controlfile autobackup format for device type disk to '%F'
backup database format 'c:\temp\%d_%T_%U.bak';
rman target sys/sys@1 catalog rman/rman@2
connect ,resouce,recovery_catalog_owner;角色;授予catalog里面的rman用户;
create catalog:创建一堆的对象到catalog数据库;
现在还没关联上
register database;读取target的控制文件内容放到catalog表里。
resync catalog;
catalog 命令。如果控制文件损坏,重建控制文件丢失备份信息,可以把以前的备份文件重新注册到catalog里面。
coverting column overflows integer datatype;
waiting for snapshot cotorlfile enquence;

在rman里面可以创建脚本。必须在catalog模式;
create script. scr1
{backup as compressed backupset database;
 delete noprompt obsolete;
 backup archivelog all;
}
list script. names;
输出脚本内容print script. scr1;
脚本必须在run里面执行
run{
execute script. scr1; }
修改脚本方法;
print script. scr1 to file 'c:\1.txt';
replace script. scr1 from file 'c:\1.txt';
也可以创建global script. 所有的target数据库都能看到;

增量备份
backup incremental level=0 database;
bakkup incremental level=1 database;增量1;
backup incremental level=1 cumulative database;累计增量备份;
list backup of database summary;查看汇总

dbv检查坏块
backup validate database;rman 检查;
也可以对单独的数据文件检查;
rman可以单独恢复坏块。
blockrecover datafile 4 block 730;
set maxcorrupt for datafile 4 to 1;有1个折断块也可以备份了;
记录视图到 v$database_block_corruption;
 
不完全恢复:
drop表了。要恢复到drop之前
recover database until change 87989798;在rman里面叫scn;
recover database until timestamp to_timestamp('')
resetlogs;
打开数据库
必要条件v$datafile 和v$datafile_header;
在线联机日志损坏就不行了。做不完全恢复。
recover database;=完全恢复;
until sequence 就是恢复到比这个小的;
 
 
 
 
 
 
 
 
alter database backup controlfile to trace as 'c:\a.txt' restlogs;
只要resetlog那一段;
并且保存在c盘下a.txt;
 
noresetlog就表示当前日志没损坏的时候使用;
 

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/22374393/viewspace-710514/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: oracle,metric,awr
请登录后发表评论 登录
全部评论

注册时间:2011-10-26

  • 博文量
    11
  • 访问量
    14001