数据库概论与技术数据恢复技术学习教案.pptx
《数据库概论与技术数据恢复技术学习教案.pptx》由会员分享,可在线阅读,更多相关《数据库概论与技术数据恢复技术学习教案.pptx(119页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、会计学1数据库概论数据库概论(giln)与技术数据恢复技术与技术数据恢复技术第一页,共119页。1 1 数据库恢复概述数据库恢复概述2 2 故障的种类故障的种类3 3 数据存储结构数据存储结构4 4 恢复的实现技术恢复的实现技术(jsh)(jsh)5 5 恢复策略恢复策略6 6 具有检查点的恢复技术具有检查点的恢复技术(jsh)(jsh)7 7 数据库镜像数据库镜像8 8 小结小结数据库恢复数据库恢复(huf)技术技术第1页/共119页第二页,共119页。数据库恢复数据库恢复(huf)概述概述第2页/共119页第三页,共119页。事务事务(shw)n n事务事务(Transaction)(Tr
2、ansaction)是用户定义的一个数据库操作序列,这些操作要么全做,要么全不做,是用户定义的一个数据库操作序列,这些操作要么全做,要么全不做,是一个不可分割的工作单位是一个不可分割的工作单位(dnwi)(dnwi)n n事务的事务的ACIDACID特性:特性:n n原子性(原子性(AtomicityAtomicity)n n一致性(一致性(ConsistencyConsistency)n n隔离性(隔离性(IsolationIsolation)n n持续性(持续性(Durability Durability)第3页/共119页第四页,共119页。数据库恢复数据库恢复(huf)概述概述n n故
3、障是不可避免故障是不可避免(b k b mi(b k b mi n)n)的的n n计算机硬件故障计算机硬件故障n n系统软件和应用软件的错误系统软件和应用软件的错误n n操作员的失误操作员的失误n n恶意的破坏恶意的破坏n n故障的影响故障的影响n n运行事务非正常中断,但不会破坏数据库运行事务非正常中断,但不会破坏数据库n n破坏数据库破坏数据库第4页/共119页第五页,共119页。数据库恢复数据库恢复(huf)概述(续)概述(续)n n数据库管理系统对故障的对策数据库管理系统对故障的对策n n保证故障发生后,能把数据库中的数据从错误状态恢复到某种逻辑一致的状态保证故障发生后,能把数据库中的
4、数据从错误状态恢复到某种逻辑一致的状态n n保证事务保证事务ACID ACID n nDBMSDBMS提供恢复子系统提供恢复子系统n n恢复技术是衡量系统优劣的重要指标恢复技术是衡量系统优劣的重要指标(zh(zh bio)bio)n n恢复算法恢复算法n n正常事务处理时,采取措施保证有足够的数据用于故障恢复正常事务处理时,采取措施保证有足够的数据用于故障恢复n n故障发生后,将数据库内容恢复到某个保证数据库一致性、原子性及持久性的状态故障发生后,将数据库内容恢复到某个保证数据库一致性、原子性及持久性的状态第5页/共119页第六页,共119页。故障故障(gzhng)的种类的种类第6页/共119
5、页第七页,共119页。3 故障故障(gzhng)的种类的种类n n事务故障事务故障n n系统故障系统故障n n介质介质(jizh)(jizh)故障故障第7页/共119页第八页,共119页。一、事务故障一、事务故障n n什么是事务故障n n某个事务在运行过程中由于种种原因未运行至正常终止点就夭折了n n事务故障的常见原因n n输入数据有误n n运算溢出n n违反了某些完整性限制n n某些应用程序出错(ch cu)n n并行事务发生死锁n n。第8页/共119页第九页,共119页。事务故障的恢复事务故障的恢复(huf)n n发生事务故障时,夭折的事务可能已把对数据库的部分修改写回磁盘发生事务故障时
6、,夭折的事务可能已把对数据库的部分修改写回磁盘n n处理方法处理方法n n预期故障:预期故障:n n 通过通过(tnggu)(tnggu)在程序中加判断条件来实现。执行回滚(在程序中加判断条件来实现。执行回滚(ROLLBACKROLLBACK)语句来撤销事务。)语句来撤销事务。n n非预期的故障:非预期的故障:n n 如由于死锁、运算溢出而被迫撤销的事务等,由系统来撤销事务如由于死锁、运算溢出而被迫撤销的事务等,由系统来撤销事务n n事务故障的恢复的本质:撤消事务(事务故障的恢复的本质:撤消事务(UNDOUNDO)第9页/共119页第十页,共119页。3 故障故障(gzhng)的种类的种类n
7、n事务故障事务故障n n系统故障系统故障n n介质介质(jizh)(jizh)故障故障第10页/共119页第十一页,共119页。二、系统故障二、系统故障n n什么是系统故障什么是系统故障n n整个系统的正常运行突然被破坏整个系统的正常运行突然被破坏n n所有正在运行的事务所有正在运行的事务(shw)(shw)都非正常终止都非正常终止n n内存中数据库缓冲区的信息全部丢失内存中数据库缓冲区的信息全部丢失n n外部存储设备上的数据未受影响外部存储设备上的数据未受影响第11页/共119页第十二页,共119页。系统故障的常见系统故障的常见(chn jin)原因原因n n操作系统或DBMS代码错误n n
8、操作员操作失误n n特定类型的硬件(yn jin)错误(如CPU故障)n n突然停电第12页/共119页第十三页,共119页。系统故障的恢复系统故障的恢复(huf)n n 清除尚未完成的事务对数据库的所有修改清除尚未完成的事务对数据库的所有修改n n系统重新启动时,恢复程序要强行系统重新启动时,恢复程序要强行(qingxng)(qingxng)撤消(撤消(UNDOUNDO)所有未完成事务)所有未完成事务n n将缓冲区中已完成事务提交的结果写入数据库将缓冲区中已完成事务提交的结果写入数据库n n系统重新启动时,恢复程序需要重做(系统重新启动时,恢复程序需要重做(REDOREDO)所有已提交的事务
9、)所有已提交的事务第13页/共119页第十四页,共119页。3 故障故障(gzhng)的种类的种类n n事务故障事务故障n n系统故障系统故障n n介质介质(jizh)(jizh)故障故障第14页/共119页第十五页,共119页。三、介质三、介质(jizh)故障故障n n硬件故障使存储在外存中的数据(shj)部分丢失或全部丢失n n介质故障比前两类故障的可能性小得多,但破坏性大得多第15页/共119页第十六页,共119页。介质故障介质故障(gzhng)的常见原因的常见原因n n硬件(yn jin)故障n n磁盘损坏n n磁头碰撞n n操作系统的某种潜在错误n n瞬时强磁场干扰第16页/共119
10、页第十七页,共119页。介质故障介质故障(gzhng)的恢复的恢复n n装入数据库发生介质故障前某个时刻的数据副本n n重做自此时始的所有成功事务(shw),将这些事务(shw)已提交的结果重新记入数据库第17页/共119页第十八页,共119页。数据存储数据存储(cn ch)结构结构第18页/共119页第十九页,共119页。Storage Structuren nVolatile storage:n ndoes not survive system crashesn nexamples:main memory,cache memoryn nNonvolatile storage:n nsurv
11、ives system crashesn nexamples:disk,tape,flash memory,non-volatile(battery backed up)RAM n nStable storage:n na mythical form of storage that survives all failuresn napproximated by maintaining multiple copies on distinct nonvolatile media第19页/共119页第二十页,共119页。Stable-Storage Implementationn nMaintain
12、 multiple copies of each block on separate disksMaintain multiple copies of each block on separate disksn nraidraidn n远程远程(yu(yu nchng)nchng)灾备灾备copies can be at remote sites copies can be at remote sites toto protect protect against disasters such as fire or flooding.against disasters such as fire
13、or flooding.n nFailure during data transfer can still result in inconsistent copies:Failure during data transfer can still result in inconsistent copies:Block transfer can result inBlock transfer can result inn nSuccessful completionSuccessful completionn nPartial failure:destination block has incor
14、rect informationPartial failure:destination block has incorrect informationn nTotal failure:destination block was never updatedTotal failure:destination block was never updated第20页/共119页第二十一页,共119页。Stable-Storage Implementationn nProtecting storage media from failure during data transfer(one solutio
15、n):Protecting storage media from failure during data transfer(one solution):n nExecute output operation as follows(assuming two copies of each block):Execute output operation as follows(assuming two copies of each block):Write the information onto the first physical block.Write the information onto
16、the first physical block.When the first write successfully completes,write the When the first write successfully completes,write the same information onto the second physical block.same information onto the second physical block.The output is completed only after the second write The output is compl
17、eted only after the second write successfully completes.successfully completes.第21页/共119页第二十二页,共119页。Stable-Storage Implementation(Cont.)n nProtecting storage media from failure during data transfer(cont.):Protecting storage media from failure during data transfer(cont.):n nCopies of a block may dif
18、fer due to failure during output operation.To Copies of a block may differ due to failure during output operation.To recover from failure:recover from failure:1.1.First find inconsistent blocksFirst find inconsistent blocks:1.1.Expensive solutionExpensive solution:Compare the two copies of every dis
19、k block.:Compare the two copies of every disk block.2.2.Better solutionBetter solution:l lRecord in-progress disk writes on non-volatile storage(Non-volatile RAM or Record in-progress disk writes on non-volatile storage(Non-volatile RAM or special area of disk).special area of disk).l l Use this inf
20、ormation during recovery to find blocks that may be inconsistent,and Use this information during recovery to find blocks that may be inconsistent,and only compare copies of these.only compare copies of these.l lUsed in hardware RAID systemsUsed in hardware RAID systems2.2.If either copy of an incons
21、istent block is detected to have an error(bad If either copy of an inconsistent block is detected to have an error(bad checksum),overwrite it by the other copy.If both have no error,but are different,checksum),overwrite it by the other copy.If both have no error,but are different,overwrite the secon
22、d block by the first block.overwrite the second block by the first block.第22页/共119页第二十三页,共119页。Data Accessn nPhysical blocks are those blocks residing on the disk.n nBuffer blocks are the blocks residing temporarily in main memory.n nBlock movements between disk and main memory are initiated through
23、 the following two operations:n ninput(B)transfers the physical block B to main memory.n noutput(B)transfers the buffer block B to the disk,and replaces the appropriate physical block there.第23页/共119页第二十四页,共119页。Data Accessn nEach transaction Each transaction T Ti i has its private work-area in whic
24、h local copies of all data items accessed and has its private work-area in which local copies of all data items accessed and updated by it are kept.updated by it are kept.n n T Ti is local copy of a data item s local copy of a data item X X is called is called x xi i.n nWe assume,for simplicity,that
25、 each data item fits in,and is stored inside,a single block.We assume,for simplicity,that each data item fits in,and is stored inside,a single block.第24页/共119页第二十五页,共119页。Data Access(Cont.)n nTransaction transfers data items between system buffer blocks and its private work-area Transaction transfer
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 数据库 概论 技术 数据 恢复 学习 教案
限制150内