O documento discute backups e recuperação de bancos de dados, mencionando três tipos de falhas (instância, aplicação, mídia), métodos de cópia de dados e logs em Oracle como RMAN, e tipos de backups como totais, incrementais diferenciais e cumulativos.
Revisão do Desenho da Base de Dados - Design Review
Salvaguarda e Recuperação da Base de Dados | Oracle
1. Salvaguarda e Recuperação
Database Backup & Recovery
Carlos Pampulim Caldeira
http://www.di.uevora.pt/~ccaldeira
Administração de Bases de Dados
2. Falhas numa base de dados
• Instância (usual/ não danificam os dados)
• Aplicação/Transação (tempo, input, ordem)
• Media (hardware, dados apagados)
3. Cópias (backups) dos dados
• “COPY” | RMAN (Oracle)
• Imagem dos dados
• Registos de logs
5. SELECT log_mode FROM V$DATABASE;
ALTER DATABASE archivelog;
Ver/Alterar métodos dos logs
SQL Error: ORA-01126: database must be mounted in this
instance and not open in any instance
01126. 00000 - "database must be mounted in this instance
and not open in any instance"
*Cause: Obvious
12. Oracle | redundancy set
• Ficheiro com dados (datafile)
• Ficheiro de controlo (control file)
• Ficheiro(s) de registo (online redo log)
13. Oracle | primary files
O {discos | outro media} que contém o
{redundância} DEVE SER DISTINTO
do {discos | outro media} que contém
• Ficheiro com dados (datafile) |
• Ficheiro de controlo (control file) |
• Ficheiros de log (online redo log) |
15. Oracle | Utilitário backup
Recovery Manager (RMAN)
Consistentes: quando a BD está num estado
consistente:
- SHUTDOWN NORMAL
- SHUTDOWN IMMEDIATE
- SHUTDOWN TRANSACTIONAL
Inconsistentes
16. Oracle | RMAN
RMAN: em NOARCHIVELOG inconsistentes
ARCHIVELOG:
- datafiles
- redo logs
Então um backup inconsistente pode ser uma
boa estratégia:
- SHUTDOWN ……
17. Oracle | RMAN
Backups INCREMENTAIS
Dois níveis: 0 e 1
Um backup incremental de nível 0 é uma cópia
total da BD que por acaso é o pai de um proces-
so incremental.
18. Oracle | RMAN
O incremental de nível 1 tem dois tipos:
• Incr. diferencial que salva os dados alte-
rados após a salvaguarda mais recente de
nível 1 ou 0
• Incr. cumulativo que salva todos os dados
alterados desde a salvaguarada mais recente
de nível 0
Instance Failure
Instance failure occurs when an instance abnormally terminates. An instance failure can occur because:
A power outage causes the server to crash.
The server becomes unavailable because of hardware problems.
The operating system crashes.
One of the Oracle background processes fails.
You issue a SHUTDOWN ABORT statement.
Fortunately, Oracle performs instance recovery automatically: all you need to do is restart the database.
Favor full image copies for small databases objects. The definition of “small” will vary from site to site and DBMS to DBMS. Far large/medium mainframe | Unix a “small” object is probably within the 150GB to 200GB range.
A consistent shutdown guarantees that all redo has been applied to the datafiles. If you mount the database and make a backup at this point, then you can restore the database backup later and open it without performing media recovery.
____________________________
Shutdown Immediate
Perhaps the best way to initially shutdown the database is the shutdown immediate command. This command will prevent any new logins, then rollback any uncommitted transactions, and then bring down the database. In the process of bringing down the database, Oracle will flush all the changes in memory out to the database datafiles too, just like a regular shutdown does. This makes database startup quicker. Here is an example of shutting down a database with the shutdown immediate command:
__________________________________
Shutdown Abort
The shutdown abort command is pretty much a guaranteed way to get your database to shutdown. It’s a “hard crash” of the database, and this can result in a longer time to start the database back up. Still, you can’t really hurt the database using the shutdown abort command, and during your DBA years you will find more than a few occasions to use the shutdown abort command.
A shutdown abort can be your first shutdown method of choice, since there may be times when you must force the database down. Here is an example using the shutdown abort command:
A consistent shutdown guarantees that all redo has been applied to the datafiles. If you mount the database and make a backup at this point, then you can restore the database backup later and open it without performing media recovery.
If the database runs in ARCHIVELOG mode, and you back up the archived redo logs and datafiles, inconsistent backups can be the foundation for a sound backup and recovery strategy. Inconsistent backups offer superior availability because you do not have to shut down the database to make backups that fully protect the database.
In contrast to a full backup, an incremental backup copies only those data blocks that have changed since a previous backup. You can use RMAN to create incremental backups of datafiles, tablespaces, or the whole database. A full backup cannot be part of an incremental backup strategy; that is, it cannot be the parent for a subsequent incremental backup.
Incremental backups are differential by default.
In the example shown in Figure 8-2, the following activity occurs each week:
Sunday
An incremental level 0 backup backs up all blocks that have ever been in use in this database.
Monday through Saturday
On each day from Monday through Saturday, a differential incremental level 1 backup backs up all blocks that have changed since the most recent incremental backup at level 1 or 0. The Monday backup copies blocks changed since Sunday level 0 backup, the Tuesday backup copies blocks changed since the Monday level 1 backup, and so forth.
In a cumulative level 1 backup, RMAN backs up all blocks used since the most recent level 0 incremental backup in either the current or parent incarnation. Cumulative incremental backups reduce the work needed for a restore operation by ensuring that you only need one incremental backup from any particular level. Cumulative backups require more space and time than differential backups because they duplicate the work done by previous backups at the same level.
In the example shown in Figure 8-3, the following occurs each week:
Sunday
An incremental level 0 backup backs up all blocks that have ever been in use in this database.
Monday - Saturday
A cumulative incremental level 1 backup copies all blocks changed since the most recent level 0 backup. Because the most recent level 0 backup was created on Sunday, the level 1 backup on each day Monday through Saturday backs up all blocks changed since the Sunday backup.