Oracle Database Backup and Recovery

xiaoxiao2021-03-06  115

Oracle Database Backup and Recovery

When we use a database, always hope that the content of the database is reliable, correct, but due to the fault of the computer system (including machine fault, media failure, misoperation, etc.), the database may sometimes be destroyed, how to make it as soon as possible Recovery data becomes a top priority. If you make a backup of the database, you will be easy to recover data at this time. It can be seen that how important the backup of the database is, and the author takes Oracle7 as an example to tell the database backup and recovery. The Oracle database has three standard backup methods that are export / import (export / import), cold backup, hot backup. Export backup is a logical backup, a cold backup and a hot backup is a physical backup.

First, export / import (export / import)

Using EXPORT to extract data from the database, you can send the extracted data back into the Oracle database using Import.

1. Simple export data (Export) and import data (import)

Oracle supports three types of output:

(1) Table mode (T method) export the data of the specified table.

(2) User mode (U mode), export all objects and data of the specified user.

(3) The full warehouse (FULL mode), export all objects in the database.

The process of data derivation is the inverse process of the data import (export), and their data flows are different.

2. Incremental Export / Import

Incremental export is a commonly used data backup method, which can only be implemented throughout the database and must be used as system. When performing such export, the system does not request an answer any questions. Export file name defaults to export.dmp, if you do not want your own output file to be named Export.dmp, you must point out the file name you want to use in the command line.

Incremental export includes three types:

(1) "Complete" incremental export (Complete)

That is, back up the entire database, such as:

$ Exp system / manager incy = complete file = 990702.dmp

(2) "incremental" incremental export

Back up the data changed after the last backup. such as:

$ Exp system / manager incy = incremental file = 990702.dmp

(3) "Cumulative" incremental export (cumulative)

The cumulative export method is just the information that changes in the database after the last "complete" export. such as:

$ Exp system / manager incy = cumulative file = 990702.dmp

Database administrators can schedule a backup schedule that is completely efficient and efficiently completed by three different ways of data.

For example, the backup task of the database can be arranged as follows:

Monday: Export (a)

Tuesday: Increment Export (B)

Wednesday: Increment Export (C)

Thursday: Incremental Export (D)

Friday: Accumulated Export (E)

Saturday: Increment Export (F)

Sunday: Incremental Export (G) If on Sunday, the database is accidentally destroyed, the database administrator can restore the database as follows:

The first step: regenerate the database structure with the command Create Database;

Step 2: Create a sufficiently big additional reflection.

Step 3: Full incremental import A:

$ IMP System./Manager Inctype = Rectore Full = Y File = a

Step 4: Accumulated incremental import E:

$ IMP System / Manager Inctype = Rector Full = Y File = E

Step 5: Recent incremental import f:

$ IMP System / Manager InctYpe = Restore Full = Y File = f

Second, cold backup

The cold backup occurs in the case where the database has been properly closed, and it will be given to us a complete database when properly turned off. Cold backup is a statement that copies a key file to an additional location. For backup Oracle information, cold backup is the fastest and safest way. The advantage of the cold backup is:

1. Is a very fast backup method (only copy file)

2. Easy to archive (simple copy)

3. Easy to recover to a point in time (just copy the file back)

4. Can be combined with the archive method to make the database "Latest Status" recovery.

5. Low level maintenance, high security.

But the cold backup also has the following deficiencies:

1. You can only provide recovery to "a certain point in time" alone.

2. In implementing the full process of the backup, the database must be a backup without making it. That is, during the cold backup process, the database must be closed.

3. If the disk space is limited, only the other external storage devices such as tape can be copied, and the speed will be very slow.

4. Can't be restored in form or by user.

If possible (mainly efficient), the information should be backed up to the disk, then start the database (user can work) and copy the backed up to the tape (copy, the database can also work). Documents that must be copied in the cold backup include:

1. All data files

2. All control files

3. All online redo log files

4. INIT.ORA file (optional).

It is worth noting that the cold backup must be performed in the case where the database is closed. When the database is open, the execution database file system backup is invalid.

Here is a complete example of making cold backup:

(1) Turn off the database $ sqldba lmode = y

Sqldba> Connect Internal;

Sqldba> shutdown normal;

(2) Back up all of the time files, redo log files, control files, and initialize parameter files

SQLDBA>! CP

(3) Restart Oracle Database

$ SQLDBA LMODE = Y

Sqldba> Connect Internal;

Sqldba> Startup;

Third, hot spare

Thermal backup is a method of backing up data using ArchiveLog MODE mode in the case of a database operation. So, if you have a cold backup yesterday and today's hot backup documents, you can use this information to restore more information when there is a problem. The hot backup requires the database to operate in the ArchiveLog mode and require a lot of file space. Once the database is running in ArchiveLog, you can make a backup. The command file of the hot spare is consisting of three parts: 1. Data file A tablespace backup backup.

(1) Set the table space to back up status

(2) Data file of backup table space

(3) Recovery table space is normal

2. Backup archive log file.

(1) Temporary stop archiving process

(2) Log under the file in the Archive Redo Log Target Directory

(3) Restart the Archive process

(4) Backup archived redo log file

3. Use the alter database backup controlfile command to back up the copy file

The advantage of hot backup is:

1. The backup time is short in the table space or data file level backup.

2. The database can still be used when backed up.

3. Can reach second level recovery (restored to a point in time).

4. Almost all database entities can be recovered.

5. Recovery is fast, and in most cases, it is restored when the database is still working.

The lack of hot spare is:

1. Can't go wrong, otherwise the consequences are serious.

2. If the hot backup is unsuccessful, the result is not available for time point recovery.

3. Because it is difficult to maintain, it is necessary to carefully carefully, and "endlessly end" is allowed. "

转载请注明原文地址:https://www.9cbs.com/read-125353.html

New Post(0)