请教高手:redo里都记点啥?做什么用?

[复制链接]
查看11 | 回复9 | 2010-12-6 19:50:26 | 显示全部楼层 |阅读模式
redo里据说记录着变化前、后的镜像,变化后的镜像可以作为重做的依据,那变化前的镜像又做什么用呢?rollback吗?
还望高手指点,不胜感激。
回复

使用道具 举报

千问 | 2010-12-6 19:50:26 | 显示全部楼层
看字面意思就知道REDO是重做,每對數據庫有DML,DDL操作,先記錄到REDO日志,
比如你insert into t values(1);
你提交的時候他先在redo日志里面加一條這樣的記錄,記錄時間,SCN,還有相關的DML語句,然后對表操作
如果在REDO寫完就斷電,則下次開機時候就會對數據庫RECOVER,提交redo里面有的但是表里面沒有的操作,這個時候就是對SCN對比,
保存前鏡像是對以后的回復做準備的,回滾用到的是回滾段,redo的前鏡像不是用來做回滾的
[ 本帖最后由 gkl0818 于 2008-8-25 17:30 编辑 ]
回复

使用道具 举报

千问 | 2010-12-6 19:50:26 | 显示全部楼层
原帖由 我上面有人 于 2008-8-25 17:01 发表
redo里据说记录着变化前、后的镜像,变化后的镜像可以作为重做的依据,那变化前的镜像又做什么用呢?rollback吗?
还望高手指点,不胜感激。

据说?哪个文档?
回复

使用道具 举报

千问 | 2010-12-6 19:50:26 | 显示全部楼层
原帖由 我上面有人 于 2008-8-25 17:01 发表
redo里据说记录着变化前、后的镜像,变化后的镜像可以作为重做的依据,那变化前的镜像又做什么用呢?rollback吗?
还望高手指点,不胜感激。

二楼兄弟讲的还是比较全面,这里增加一点,REDO文件中也会记录撤消操作的记录.
回复

使用道具 举报

千问 | 2010-12-6 19:50:26 | 显示全部楼层
redo的作用就是用于实例恢复,当数据库在运行时突然下电,当数据库重起时,数据文件与控制文件的SCN号是不一致的,这时数据库的后台进程SMON会自动使用在线日志文件对数据库进行恢复,使数据库达到一致状态,并将其打开,使其可以正常工作.
回复

使用道具 举报

千问 | 2010-12-6 19:50:26 | 显示全部楼层
二楼说的 “保存前鏡像是對以后的回復做準備的”是什么意思?
不清楚。。。。
回复

使用道具 举报

千问 | 2010-12-6 19:50:26 | 显示全部楼层
Redo Log Files
Every Oracle database has a set of two or more redo log files. The set of redo log files is collectively known as the redo log for the database. A redo log is made up of redo entries (also called redo records).
The primary function of the redo log is to record all changes made to data. If a failure prevents modified data from being permanently written to the datafiles, then the changes can be obtained from the redo log, so work is never lost.
To protect against a failure involving the redo log itself, Oracle allows a multiplexed redo log so that two or more copies of the redo log can be maintained on different disks.
The information in a redo log file is used only to recover the database from a system or media failure that prevents database data from being written to the datafiles. For example, if an unexpected power outage terminates database operation, then data in memory cannot be written to the datafiles, and the data is lost. However, lost data can be recovered when the database is opened, after power is restored. By applying the information in the most recent redo log files to the database datafiles, Oracle restores the database to the time at which the power failure occurred.
The process of applying the redo log during a recovery operation is called rolling forward.
http://download.oracle.com/docs/ ... /intro.htm#sthref40
回复

使用道具 举报

千问 | 2010-12-6 19:50:26 | 显示全部楼层
原帖由 gvora 于 2008-8-25 18:41 发表
二楼说的 “保存前鏡像是對以后的回復做準備的”是什么意思?
不清楚。。。。

估计就是rollback
回复

使用道具 举报

千问 | 2010-12-6 19:50:26 | 显示全部楼层
不过,rollback用到的是undo里的数据,redo里的前镜像什么时候用到呢?
回复

使用道具 举报

千问 | 2010-12-6 19:50:26 | 显示全部楼层


你可以这样理解,当一个公司要把货发到客户那儿,车在中途抛锚了(车翻,车迷路,车上遇到鬼了。反正是不能再继续跑了)。这个时候公司本着为人民服务的综旨,是不是需要重新派车把货运到客户那儿?答案是必需,否则会被人砸场子的!redolog(重做日志)也是一样,记录着从那儿出发?需要做些什么?要到那里去?
再打个比喻,你做作业,做错了,老师让你重做一遍。当那个时候老师的脑子就是redo log,罚你做100遍,那就不是redo log.是锈斗了!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行