设为首页 收藏本站
查看: 1127|回复: 0

[经验分享] Common Oracle RDBMS Misconceptions-OPOPOP

[复制链接]

尚未签到

发表于 2018-9-26 12:32:50 | 显示全部楼层 |阅读模式
During an Oracle tablespace hot backup, a script that you write puts a tablespace into backup mode, then copies the datafiles to disk or tape, then takes the tablespace out of backup mode.>Oracle Unleashed, 2nd Ed. from SAMS/Macmillan, for which the backup/recovery author is Byron Pearce, and Learn Oracle8 in 21 Days by Ed Whalen and Steve Deluca, from the same publisher. Numerous websites on the topic also make the assertion that datafiles are unwritable during backup. Many people have reported that Oracle Education DBA>The erroneous descriptions have several permutations.  Most claim that while the datafiles are allegedly unwritable, changes are stored somewhere in the SGA, the redologs, the rollback segments or some combination thereof, then written back into the datafile when the tablespace is taken out of backup mode. The passage from Oracle Unleashed describing this supposed mechanism is representative.
When you place a tablespace in backup mode, the Oracle instance notes that a backup is being performed and internally compensates for it. As you know, it is impossible to make an authentic copy of a database file that is being written to. On receipt of the command to begin the backup, however, Oracle ceases to make direct changes to the database file. It uses a complex combination of rollback segments, buffers, redo logs, and archive logs to store the data until the end backup command is received and the database files are brought back in sync.
  Simplifying a hot backup in this way is tantamount to>  (Copyright SAMS/Macmillan, Inc. 1997, pages ... )
In fact, Oracle's tablespace hot backup does not work this way at all. It is instead a simple and failure-resistant mechanism. It absolutely does not stop writing the datafiles, and actually allows continued operation of the database almost exactly as during normal operation. Contrary to the characterization as "complex" in SAMS Oracle Unleashed, it can be almost completely summarized in one sentence.  The tablespace is checkpointed, the checkpoint SCN marker in the datafile headers cease to increment with checkpoints, and full images of changed DB blocks are written to the redologs.
  Those three actions are all that is required to guarantee consistency once the file is restored and recovery is applied. By freezing the checkpoint SCN in the file headers, any subsequent recovery on that backup copy of the file will know that it must commence at that SCN. Having an old SCN in the file header tells recovery that the file is an old one, and that it should look for the redolog file containing that SCN, and apply recovery starting there. Note that checkpoints to datafiles in hot backup mode are not suppressed during the backup, only the incrementing of the main checkpoint SCN flag. A "hot backup checkpoint" SCN marker in the file header continues to increment as periodic or incremental checkpoints progress normally.
  There is a confusing side effect of having the checkpoint SCN artificially frozen at an SCN earlier than the true checkpointed SCN of the datafile. In the event of a system crash or a 'shutdown abort' during hot backup of a tablespace, the automatic crash recovery routine at startup will think that the files for that tablespace are quite out of date, and will actually suggest the application of old archived redologs in order to bring them back into sync with the rest of the database. It is unnecessary, in this case, to heed Oracle's suggestion. With the database started up in mount mode, simply check v$backup and v$datafile to determine which datafiles were in backup mode at the time the database crashed. For each file in backup mode, issue an 'alter database datafile '' end backup;' This action will update the checkpoint SCN in the file headers to be the same as the hot backup checkpoint SCN (which is a true representation of the last SCN to which the datafile is truly checkpointed. Once this action is taken, it allows normal crash recovery to proceed during the 'alter database open;' command.
  By initially checkpointing the datafiles that comprise the tablespace and logging full block images to redo, Oracle guarantees that any blocks changed in the datafile while in hot backup mode will also be available in the redologs in case they are ever used for a recovery.
  It is well understood by much of the Oracle user community that during hot backup mode, a greater volume of redo is generated for changes to the tablespace being backed up than when the tablespace is not in backup mode. This is the result of the logging of full images of changed blocks in these tablespaces to the redologs. Normally, Oracle logs an entry in the redologs for every change in the database, but it does not log the whole image of the database block. By logging full images of changed DB blocks to the redologs during backup mode, Oracle eliminates the possibility of the backup containing unresolvable split blocks. To understand this reasoning, you must first understand what a split block is.

  Typically, Oracle database blocks are a multiple of O/S blocks.  For instance, most Unix filesystems have a default blocksize of 512 bytes, while Oracle's default blocksize is 2k. This means that the filesystem stores data in 512 byte chunks, while Oracle performs reads and writes in 2k chunks, or multiples thereof. While backing up a datafile, your backup script makes a copy of the datafile from the filesystem, using O/S utilities such as copy, dd, cpio, or OCOPY..  As it is making this copy, it is reading is O/S-block>  By logging the full block image of the changed block to the redologs, it guarantees that in the event of a recovery, any split blocks that might be in the backup copy of the datafile will be resolved by overlaying them with the full legitimate image of the block from the redologs. Upon completion of a recovery, any blocks that got copied in a split state into the backup will have been resolved through application of full block images from the redologs.
  It is important to remember that all of these mechanisms exist for the benefit of the backup copy of the files and the recovery process, and have very little effect on the datafiles of the database being backed up. The database files are read by server processes and written by the database writer throughout the backup, as they are when a backup is not taking place.  The only difference manifested in the open database files is the freezing of the checkpoint SCN, and the incrementing of the hot-backup scn.
  To demonstrate the principle, we can formulate a simple proof.

  • A table is created and a row of data inserted.
      SQL> create table fruit (name varchar2(32)) tablespace administrator;  Table created.
        SQL> insert into fruit values ('orange');
        1 row created.
        SQL> commit;
        Commit complete.

  • A checkpoint is forced, to flush dirty DB block buffers to the datafiles.
      SQL>>System>

  • The block number in the datafile where the data resides is determined.
      SQL> select dbms_rowid.rowid_block_number(rowid) blk, name from fruit;  BLK NAME
        ------- ----------------
        3 orange
    The DB block containing an>unixhost% dd ibs=8192 skip=11 count=1 \  > if=/raw-01/databases/toy/administrator-01.dbf | strings
      1+0 records in
      16+0 records out
      orange
The tablespace is placed into hot backup mode.
    SQL>>Tablespace>
The row is updated, commited, and a global checkpoint forced on the database.
    SQL> update fruit set name = 'plum';  1 row updated
      SQL> commit;
      Commit complete.

      SQL>>
      System>
The same block is extracted, showing that the DB block has been written on disk.
    unixhost% dd ibs=8192 skip=11 count=1 \  > if=/raw-01/databases/toy/administrator-01.dbf | strings
      1+0 records in
      16+0 records out
      orange,
      plum
The tablespace is taken out of backup mode
    SQL>>
  Regardless of the underlying theory, no backup strategy is complete unless it has been extensively practiced, tested and documented. Backups are any OLTP shop's bread and butter.  Without them, a company is at the mercy of a bunch of whirring machinery and messy hardware, which is not an enviable position.


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-602359-1-1.html 上篇帖子: ZT:Public yum with Oracle 下篇帖子: oracle执行cmd
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表