Database principles-Data recovery

Source: Internet
Author: User

1. How to set up redundant data
    1. Data dump (Backup)
    2. Log in log file (logging)
1. Data dumps

Characteristics:

      1. The backup copy can be re-loaded after the database has been compromised
      2. Reloading a backup copy only restores the database to the state at the time of the dump

Method:

      1. Static dumps and dynamic dumps
      2. Mass dumps and incremental dumps

Static dumps

No access to the database, modification activity benefits during staging: Simple drawbacks:
      • Reduced availability of the database
      • Dump must wait for the end of a user transaction that is running
      • The new transaction must wait for the dump to end

Dynamic dumps

      • Dump operations are performed concurrently with user transactions
      • Allow access to or modification of the database during a dump
Advantages:
      • Do not wait for a running user transaction to end
      • Does not affect the operation of new transactions
Disadvantages:

There is no guarantee that the data in the replica will work correctly

[ example ] at some point during the dump TC, the system puts the data a =100 is dumped onto tape, and at the next moment TD, a transaction changes a to 200. After the dump is over, a on the backup copy is obsolete data.

Recovery method:

Using a copy of a dynamic dump to recover from a replica, it is necessary to register the changes in the database during the dynamic dump, create a log file, and a backup copy plus a log file to restore the database to the correct state at a certain point in time.

Mass dump: Dump all database incremental dumps at a time: dumps only the data that has been updated since the last dump 2. Register log file

Log file contents in record units

      1. Start tag for each transaction (begin TRANSACTION)
      2. End tag for each transaction (commit or rollback)
      3. All update operations for each transaction

Log files in records, contents of each log record

      1. Transaction ID (which transaction is indicated)
      2. Type of operation (insert, delete, or modify)
      3. Manipulating objects (recording internal identities)
      4. Old value of pre-update data (this is a null value for insert operations)
      5. The new value of the updated data (this is a null value for the delete operation)

Log files in blocks of data, the contents of each log record

      1. Transaction ID (indicates that transaction)
      2. Data blocks that are updated

The order of registrations is strictly in the order in which the parallel transactions are executed, and the log file must be written before the database

2. How to use these redundant data to implement database recovery

Transaction failure Recovery

The recovery subsystem should take advantage of the log file undo (undo) The transaction has been made to the database for modification of a transaction failure is automatically completed by the system, is transparent to the user and does not require user intervention

System failure Recovery

Undo failure occurs when an incomplete transaction redo the recovery of a completed transaction system failure by the system inwhen restartingAutomatic completion, no user intervention required for media failure

Reload Database

Redo a completed transaction

Database principles-Data recovery

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.