1. How to set up redundant data
- Data dump (Backup)
- Log in log file (logging)
1. Data dumps
Characteristics:
-
- The backup copy can be re-loaded after the database has been compromised
- Reloading a backup copy only restores the database to the state at the time of the dump
Method:
-
- Static dumps and dynamic dumps
- 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
-
- Start tag for each transaction (begin TRANSACTION)
- End tag for each transaction (commit or rollback)
- All update operations for each transaction
Log files in records, contents of each log record
-
- Transaction ID (which transaction is indicated)
- Type of operation (insert, delete, or modify)
- Manipulating objects (recording internal identities)
- Old value of pre-update data (this is a null value for insert operations)
- 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
-
- Transaction ID (indicates that transaction)
- 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