About Backup of Oracle database _oracle

Source: Internet
Author: User
Tags prev valid
The Oracle tutorial you are looking at is about backup of Oracle databases. One, meaning:
When we use a database, we always want the contents of the database to be reliable and correct, but due to computer system failure (hardware failure, network failure, process
Fault and system fault) affect the operation of database system, affect the correctness of the data in the database, and even destroy the database, so that all or part of the data in the database is lost
Lost. Therefore, when the above fault occurs, we hope to re-establish a complete database, which is called database recovery. Recovery subsystem is a database management system
An important part of it. Recovery processing varies with the structure that is affected by the type of failure that occurs.
Second, the method of backup
There are three standard backups of Oracle databases. Export/import (Export/import), cold backup, hot backup.
Exporting a backup is a logical backup, which involves reading a series of database logs and writing to the file, where the read is independent of the location of the log.
Cold and hot backups are physical backups (also called low-level backups) that involve the files that make up the database, but do not consider logical content.
Here are a few of the three backup methods and their features:
(i), export/import (Export/import)
Export/import is used to move data out/move into the database in Oracle.
1. Export database data back into a binary system file called Export dump file, and the database will be rebuilt to write
into the file.
It has three different modes:
A. User mode: Export all user objects and data in the object;
B. Table mode: Export all the user tables or specified tables;
C. Entire database: Export all objects in the database.
It has three types of backups:
A. Complete type (COMPLETE EXPORT): Back up the entire database;
B. Accumulation type (comulative erport): Back up the data that was changed by the last cumulative backup;
C. Incremental (Increamental EXPORT): Backs up data that has changed since the last backup.
EXPORT commands can be interactive, the specific meaning of each parameter see appendix.
One thing to consider when exporting a backup is the consistency of the export, which, when exported, reads a table every time it is read, so that although the export
It starts at one feature, but different tables read differently, so when the export begins to read a table, the data in the table is the number of exports.
As a result, when most tables are interconnected by internal keywords and external keywords, changes in these associated tables during the export process can lead to inconsistent export
, to avoid this, we can schedule the export process to take place when the table is not being manipulated. In addition, when Oracle restrictep consistent option
You can guarantee that data consistency is exported.

2, Import imports:
The import process is the inverse of the export process, which reads the exported dump binaries and runs the files to recover the object users and data.
The import command executes a method related to the export scheme.
1, if the implementation of export is a complete scheme (full) in the import of all the data objects, including table space, data files, users will be in the import of the creation
Built, but given the physical layout of the database, it is useful to create a table space and users in advance.
2, if export use is incremental/cumulative mode, you need to set up a table space, users, data files.
(ii): Cold backup
Cold backup occurs when the database has been shut down properly and provides us with a complete database when it shuts down properly.
Each file that is used by the database is backed up, and these files include:
☆ All data files
☆ All Control Documents
☆ All online Redo LOG files
☆init.ora file (optional)
It is noteworthy that the cold backup must be done in the case of database shutdown, when the database is open, the execution of the database file system backup is invalid.
General steps for cold backup are:
1: Normal shutdown to back up the instance (instance);
2: Back up the entire database to a directory
3: Start the database
1:sqldba>connect Internal
Sqldba>shutdown Normal
2:sqldba>! CP <file> <backup directory>
Or
Sqldba>!tar cvf/dev/rmt/0/wwwdg/oracle
3:sqldba>startup

(iii) Hot backup (Achirelog)
The database takes 24 hours to run and new data is added at any time. Data loss will affect the entire company. Use Archivelog mode physical backup.
? Set the database to Automatic archivelog mode,
#su-oracle
%svrmgrl
Svrmgrl>connect Internal
Svrmgrl>startup Mount
Svrmgrl>alter Database Archivelog
Svrmgrl>shutdown
Svrmgrl>exit
%vi Initoracle7.ora
Join Log_archive_start = true # If you want automatic archiving
Log_archive_dest = $ORACLE _home/dbs/arch
Log_archive_format = Log%s.arc
%dbstart
%ps-ef|grep Arch
Oracle 1743 1 0 15:20:20? 0:00 Ora_arch_oracle7
Note: Oracle database is in automatic archivelog mode

? full offline entire database backup, which is the basis for future backups when the databases are initially completed. It provides all the database-related
's copy.
%dbshut
%cp/oracle/oradata/oracle7/system.dbf
/oracle/oradata/oracle7/rbs.dbf
/oracle/oradata/oracle7/temp.dbf
/oracle/oradata/oracle7/tools.dbf
/oracle/oradata/oracle7/users.dbf
/oraclecle/app/oracle/product/7.3.2/dbs/application.dbf
/oracle/app/oracle/product/7.3.2/dbs/apptmpsp.dbf
/oracle/app/oracle/product/7.3.2/dbs/apprlbksp.dbf
/oracle/oradata/oracle7/redooracle.log
/oracle/oradata/oracle7/control1.ctl
/oracle/oradata/oracle7/control2.ctl
/oracle/oradata/oracle7/control3.ctl
<backup directory>
%dbstart
Note: The above *.dbf file is a data file, *.log file is a log file, *.ctl file is a control file
%exit
%tar uvf/dev/rmt/0 <backup files>
NOTE: If Oracle 7.2, then copy the corresponding data files,relog files,control files.

6.3. Do one partial online with archiving backups every day.
#su-oracle
%svrmgrl
%svrmgrl>connect Internal
%svrmgrl>alter tablespace BILLSP begin Backup
%svrmgrl>alter tablespace BILLTMPSP begin Backup
%svrmgrl>alter tablespace BILLRLBKSP begin Backup
%svrmgrl>alter tablespace System begin Backup
%svrmgrl>alter tablespace RBS begin backup
%svrmgrl>alter tablespace Temp Begin Backup
%svrmgrl>alter tablespace Tools Begin Backup
%svrmgrl>alter tablespace users begin Backup
%svrmgrl>host CP all datafile to the backup storage. #文件名如第一步中以 the end of DBF.
%svrmgrl>alter tablespace BILLSP End Backup
%svrmgrl>alter tablespace BILLTMPSP End Backup
%svrmgrl>alter tablespace Billrlbksp End

[1] [2] [3] Next page

The Oracle tutorial you are looking at is about backup of Oracle databases. Backup
%svrmgrl>alter tablespace System End Backup
%svrmgrl>alter tablespace RBS End Backup
%svrmgrl>alter tablespace Temp End Backup
%svrmgrl>alter tablespace Tools End Backup
%svrmgrl>alter tablespace users End Backup

Make an SQL file, as written above.

The billing system can recover to the "point of failure" when the failure occur.

Vii. Recovery of Backup files:
7.1 Recovery files:
The following is a recovery of the "/etc/passwd" file
(, put the correct tape
(, run the following command to restore the "/etc/passwd" file
# rsh www mt-f/dev/rmt/0 rew
(Find the nearest tape and move forward to the nearest "/etc/passwd", such as looking for the Wednesday "/etc/passwd" file, run the following command)
#rsh www mt-f/dev/rmt/0n FSF 2
# Ufsrestore If www:/dev/rmt/0n
Ufsrestore > ls
. :
etc/
Ufsrestore > CDs etc
Ufsrestore > ls
. /ETC:
passwd
Ufsrestore > Add passwd
Warnign:. /etc:file exists
Ufsrestore > Verbose
Verbose mode on
Ufsrestore > Extract
Extract Requested Files
You are have not read any volumes yet.
Unless you know which volume your file (s) are on your should start witch the last volume and work to wards
The i.
Specify next volume #:1
Extract file. /etc/passwd
Add Links
Set directory mode, Ower,and times.
Set Owner/mode for '. '? (yn) n
Directories already exit, set mode anyway? (yn) y
Ufsrestore >quit
A hot backup can take place when the database is turned on, typically by using the ALTER command to change the state of the table space to begin the backup, after the backup is completed,
To restore its original state, otherwise redo log will be mismatch, causing the next time the database is started on the affected table space for full coverage. The requirements for hot backup are:
1. The hot back-up work must request the database to operate in the Archivelog mode, under the SQLDBA state uses ALTER DATABASE Archivelog|noarchivelog the life
Allows you to change the mode of the backup.
2. Hot backup can only happen if the database is not used or the usage rate is low.
3. Hot backup requires a large amount of file space.
In general, Oracle writes the online redo log file in a circular fashion and writes the second one after filling the first redo log file until the last one, the most
After the last one is filled, the background process LGWR the first, in Archivelog mode, the background process arch in every redo log file is overwritten before, give
It makes a copy, in general, the Redo log files of these documents are written to disk or tape. If you have enough disk space, it is recommended that you use disk, which greatly reduces
The time required to complete the backup less.
Setting the Log_archive_start in the Config.ora file to true before making a hot backup log_archive_dest
Specify the location of the archive redo log file:
Log_archive_dest=/wwwdg/oracle/arch/arch
Log_archive_start=true
Once the database is running in Archivelog state, it can be backed up. The command file for hot backup consists of three parts:
1, data file a table space to backup a space:
A. Set table space to backup state.
B. A data file that backs up the table space.
C. Restore the tablespace to a normal state.
2, Backup archive to make log file:
A. Temporary cessation of the archiving process
B.log the files in the archive redo log target directory
C. Restarting the archive process
D. Backup archived redo log files
3. Use ALTER DATABASE backup Controlfile command to back up copy files
The Log_archive_dest directory may be full before the hot backup runs, and then you need to back up the directory and then delete the files to free up space, and this process has the following steps
Sudden:
1, temporarily stop archive process.
2, recorded in the Log_archive_dest directory of documents.
3, restart the archive process.
4, Backup archive redo log file.
5, delete the files in the directory.
SQLDBA lmode=y <<eof Arch1
Archive log stop;
Exit
EOF Arch1
files= ' ls/wwwdg/oracle/arch/arch*.dbf ';
SQLDBA lmode=y<<eof ARCH2
Connect Internal
Archive log start;
Exit
EOF ARCH2
tar-rvf/dev/rmt/0 FILES
Rm-f $files

A combination of logical backups and physical backups.
The previous three methods of backup, when the database backup, should be the data of the three kinds of backup features flexible use, we first compare the three methods of
Characteristics.

Method
Type
Recovery features
Export exports
Logical type
You can restore any database object to its state when it is exported
乻 Hutdown
? Copy the most recent copyes of datafile to the $oracle_home/dbs directory.
?%svrmgrl
? svrmgrl>connect Internal
... svrmgrl>startup Mount Pfile=filename Exclusive
? svrmgrl>alter database recover;
Note: Automatically restore data to the point of failure;
? Svrmgrl>alter database open;
When there are too many archive log files, after a partial backup, you can delete the Log***.arc before the current log sequence.
#su-oracle
%svrmgrl
Svrmgrl>connect internal;
Svrmgrl>archive log list;
#此处标有current log sequence. The assumption is 360.
Svrmgrl>exit
$CD/billdg/oracle/app/oracle/product/7.3.2/dbs/arch
$ rm ... #将log360. Before the arc of the file such as Log359.arc,log358.arc ......... Delete.
Cold backup
Physical type
You can put the database to a state where it is closed
Hot backup
Physical type
You can restore a database to any point in time

When the database is relatively hours, processing business is also hours, cold backup export can be. If you are backing up exports to only one or two tables, that's enough. Generally a good, backup most
Final execution includes both logic and physics, and exporting confirms that the database is logically correct while physical backup ensures physics.
In addition, some storage media is required for backup and should be managed for these media
1: According to the contents of the backup, the date will be unified number of media, so as to avoid the backup and recovery of the wrong media, resulting in the original backup lost.
2: The media should be stored in a different location from the computer equipment, in order to avoid accidents in the room, backup and computer equipment damaged together.

Appendix:
Tar command
Tar option [arguments] filename ...
Option
C: Create a new tarfile specified by the command line
T: List the contents of the Tarfile
x: Open tarfile;
F: Use subsequent filename or/dev/rmt/0|1
V: Lists the recovered filename;
P: Recovering files
Example
#tar cvf/dev/rmt/0/oracle
Backup

prev [1] [2] [3] Next page

The Oracle tutorial you are looking at is about backup of Oracle databases. All of the content under root
#tar tvf/dev/rmt/0
List all content on tape
#tar xvf/dev/rmt/0/oracle
Restores the contents of the/oracle directory on the tape to the current directory

Export options
Keyword content
USERID the username/password of the account that ran the Export command.
Buffeer the size of the buffer used to fetch the data rows.
Name of file export dump
COMPRESS export should compress a range of fragmented Cheng, which will affect storage
Clause
Grants whether to export authorization on a database object when exporting
INDEXES whether you want to export the indexes on the table
Rows should be exported. If it is ' N ', then only the database is generated in the export file
object's DDL
Consstraints whether to export the old contract condition of the table
If full is set to ' Y ', then an entire database export operation will be performed
OWNER to export a series of database accounts, and then perform these account user export exercise
For
A series of tables to export; Perform table export operations on these tables
RecordLength dumps the length (in bytes) of the exported file log, usually using the default, except
Do not pass export files on two different operating systems
Inctype the type of export operation being performed (valid value has "COMPLETE" (default),
Cumulative "and" Ivcremental ")
Record a tag in the incremental export type that indicates whether the log is stored in the data dictionary
In the table exported in the log
Parfile the name of the parameter file to be passed to the export. This file will contain the entry of all parameters
Mouth item
ANALYZE indicates whether the statistics of the moving objects are written to the export dump file
Consistent indicates whether read-consistent replication of all exported objects is preserved.
Log export logs the name of the file that will be written
MLS indicates whether to export MLS label
Mls_label_ stipulates the format of MLS labels.

Import the selection
USERID the username/password of the account that ran the import command.
Buffeer the size of the buffer used to fetch the data rows.
Name of file Import dump
Show stipulates whether the contents of the file are displayed, not executed.
Egore indicates whether to ignore errors encountered while executing the ' CREATE ' command. If you are
This parameter should be used when an imported object already exists.
If full is set to ' Y ', then an entire database import operation will be performed
Fromuser in the case of full=n, only parameters. It is a series of database accounts, whose
Object should be read from the export dump file.
Touser a series of database accounts, the object that exports the dump file buckle will import these accounts.
Grants whether to import authorization on database objects when importing
INDEXES whether you want to import indexes on the table
Rows should be imported. If it is ' N ', then executing the database in the import file
The DDL of the Elephant
If full is set to ' Y ', then an entire database export operation will be performed
A series of tables to import
RecordLength dump the length of the import file log in bytes, usually using the default, except
Do not pass import files on two different operating systems
Inctype the type of import operation being performed (valid value has "COMPLETE" (default),
Cumulative "and" Ivcremental ")
Parfile the name of the parameter file to pass to the import. This file will contain the entry of all parameters
Mouth item
ANALYZE indicates whether the statistics of the moved objects are written to the import dump file
Log import logs the name of the file that will be written
MLS indicates whether to import MLS label

Hot backup command file:
Oracle_sid=oracle7
Oracle_home=/wwwdg/oracle
SQLDBA lmode=y<<eof Arch1
Connect Internal
Alter tablespace SYSTEM begin backup;
!tar-cvf/dev/rmt/0/wwwdg/oracle/dbms/sys01.dbf
Alter tablespace SYSTEM end backup;

Alter tablespace BWT begin backup;
!tar-cvf/dev/rmt/0/wwwdg/oracle/dbms/bwt1.dbf
Alter tablespace BWT end backup;

Archive Log Stop
Exit
EOF Arch1
files= ' ls/wwwdg/oracle/arch/arch*.dbf ';

SQLDBA lmode=y<<eof ARCH2
Connect Internal
Archive log start;
Exit
EOF ARCH2

tar-rvf/dev/rmt/0 $FILES
Rm-f $files

SQLDBA Lmode=y<<eofarch3
ALTER DATABASE backup Controlfile to
'/wwwdg/oracle/dbms/bwtcontrfile.backup ';
Exit
EOF Arch3

tar-rvf/dev/rmt/0/wwwdg/oracle/bwt/bwtcontrofile.backup

prev [1] [2] [3]

Related Article

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.