In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Today, I will talk to you about how to deeply analyze RMAN backup and recovery, which may not be well understood by many people. In order to make you understand better, the editor has summarized the following contents for you. I hope you can get something according to this article.
In-depth Analysis of RMAN backup and recovery
A database version
SQL > select * from v$version
BANNER
OracleDatabase 10g Enterprise Edition Release 10.2.0.4.0-64bi
PL/SQL Release10.2.0.4.0-Production
CORE 10.2.0.4.0 Production
TNS for Linux:Version 10.2.0.4.0-Production
NLSRTL Version 10.2.0.4.0-Production
Two tools
1.Rman:Oracle 8i has been using oracle professional backup and recovery tools since then, which is also the backup tool that the majority of DBA comrades have the most contact with. Not only can you back up a single instance, but you can also back up in RAC mode. As the saying goes, RMAN is not bothered at hand. Let's talk about the use and backup strategy of Rman in depth.
What can Rman do: (1) full database backup, which is inevitable, because it is the source of all recovery.
(2) incremental backup, in order to reduce the amount of data backed up, divided into difference and accumulation
(3) Fine-grained backup, tablespace, data file, control file, parameter file, archive log
(4) Clone the database and use backup to migrate the database
(5) Design backup strategy.
(6) manage backup sets
(7) Custom Rman script
(8) generate Rman report
How to learn Rman: many people do not know what rules to follow when they see Rman, because there are many parameters in Rman that need to be set, and there may be a series of problems such as backup errors, how to design backup strategy and so on. Here I would like to say that the quickest way to master a tool is to use it first. Using it well or badly is another matter. In fact, the principle of Rman is not complicated, which is to copy a series of files from the database into a package and put them on the disk or tape and copy them back when they need to be restored. Rman practices are much more important than principles, so the "hands-on family" is a favorite of Rman.
Note: when backing up and restoring the database through RMAN, you must first start the instance and load the database. This is a hint for beginner friends. If you are a hero, please automatically ignore it.
two。 Log in to RMAN and exit from RMAN
RMAN connects to the local database
[oracle@linuxdbbase] $rman target / one go at once
RecoveryManager: Release 10.2.0.4.0-Production on Tue May 7 20:57:49 2013
Copyright (c) 1982, 2007, Oracle. All rightsreserved.
Connected to target database: BASE (DBID=1845289414) this dbid should be remembered, most of the time we need it.
RMAN >
You can also log in to rman first and connect to the database after entering.
[oracle@linuxdbbase] $rman
RecoveryManager: Release 10.2.0.4.0-Production on Tue May 7 21:00:31 2013
Copyright (c) 1982, 2007, Oracle. All rightsreserved.
RMAN > connect target /
Connectedto target database: BASE (DBID=1845289414) each database has a unique dbid
RMAN >
RMAN connects to a remote database
[oracle@linuxdbbase] $rman target sys/oracle@base179 suffix connection string
RecoveryManager: Release 10.2.0.4.0-Production on Tue May 7 21:10:48 2013
Copyright (c) 1982, 2007, Oracle. All rightsreserved.
Connectedto target database: BASE (DBID=1843237732)
RMAN >
Exit RMAN
RMAN > exit
RMAN > quit
Both of these commands can be withdrawn. This is a little pilotage for beginners. Please be quiet and avoid and.
3 some preparatory work before backup and recovery
It is the mantra of DBA to be prepared. If you want to be a delightful DBA, you should do your homework well and start with the following.
1. Control_file_record_keep_time
Control_file_record_keep_time initialization parameter: the minimum number of valid days for rman metadata to remain in the control file, which defaults to 7 days.
It is described in the official document as the minimum number of days for the control file to retain the Rman metadata. If a new record is added to the control file reusable area reusable, and the oldest record has not exceeded the minimum retention days, then the record will expand this part of the control file. If this parameter is set to 0, the reusable area of the control file will never be extended.
Note: this parameter applies only to the recyclable parts of the control file, such as archived log files and various backup records. It does not apply to data files, tablespaces, redo logs, etc., which can be reused only after they are deleted from the corresponding tablespaces.
Understanding of the minimum number of days: suppose we set it to 7 days, then if I had all the datafile backup and controlfile backup+ logs from 10 days ago (or even earlier), I wouldn't be able to recover them completely? This is negative, because the rman metadata is kept in the reusable area of the control file, and if the backup record within 7 days does not fill the reusable area, even if your backup record still exists after 7 days, it can be recovered normally and completely. If the reusable area is full within 7 days, the control file will be overwritten with the oldest backup record (but will ensure that the record within the minimum number of days is valid).
Based on past experience, we set this value to 30 days.
Syntax: alter system set control_file_record_keep_time=30
Initialization parameter control_file_record_keep_time is a dynamic parameter that can be modified directly without restarting the database.
SQL > show parameter control
NAME TYPE VALUE
-
Control_file_record_keep_time integer 30
two。 Start archive mode
SYS@base > archive log list
Databaselog mode No Archive Mode
Automaticarchival Disabled
Archivedestination USE_DB_RECOVERY_FILE_DEST
Oldestonline log sequence 10
Currentlog sequence 12
First, we need to create a directory where archive log is stored.
Oracle10g&11g default archives, flashbacks, and backups are stored in flash_recovery_area, with a default size of 2G. Generally, in order to facilitate the management of these important files in the production environment, a special directory is created for them to store.
[oracle@linuxdboracle] $mkdir archdata create an archive log directory
Path: / opt/oracle/archdata
Log in to sqlplus and set the archive path
[oracle@linuxdbarchdata] $sqlplus / as sysdba
SYS@base > alter system setlog_archive_dest_1='location=/opt/oracle/archdata' scope=both; is already in effect
System altered.
SQL > selectdest_name,destination,status,error from v$archive_dest wheredest_name='LOG_ARCHIVE_DEST_1'
DEST_NAME DESTINATION STATUS ERROR
LOG_ARCHIVE_DEST_1 / opt/oracle/archdata VALID
Has come into effect.
Restart database mount status and start archiving
SYS@base > shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SYS@base > startup mount
ORACLE instance started.
Total System Global Area1610612736 bytes
Fixed Size 2084296 bytes
Variable Size 385876536 bytes
Database Buffers 1207959552 bytes
Redo Buffers 14692352 bytes
Database mounted.
SYS@base > alter databasearchivelog; enable archiving mode
Database altered.
SYS@base > alter databaseopen; Open the database
Database altered.
All alter database operations are to modify the contents of the "control file". Go there and talk about it. Hey.
[oracle@linuxdbarchdata] $ll has just started archiving and has not generated logs yet. Let's switch it manually.
Total dosage 0
Manual switching of SQL > alter systemswitch logfile; does not trigger checkpoint, while automatic switching triggers checkpoint
System altered
[oracle@linuxdbarchdata] $ll by this time, the archive log has been generated.
The total dosage is 22208
-rw-r-1 oracle oinstall 22736384 May 8 15:35 1_13_814444678.dbf
-rw-r-1 oracle oinstall 1024 May 8 15:35 1_14_814444678.dbf
SQL > selectsequence#,name,archived,applied from vault archived log; view at the database level
SEQUENCE# NAME ARCHIVED APPLIED
-
13 / opt/oracle/archdata/1_13_814444678.dbf YES NO
14 / opt/oracle/archdata/1_14_814444678.dbf YES NO
SYS@base > archivelog list
Database logmode Archive Mode archiving mode
Automaticarchival Enabled automatic archiving start
Archivedestination / opt/oracle/archdata archive log directory
Oldest online logsequence 13 old online log serial number, which has been archived
Next log sequence toarchive 15 next log sequence number to be archived
Current logsequence 15 current online log serial number
Write very clearly, from here we can judge the situation of the archived log, how many archives there are, which log is now, what date the archiving has been completed, and so on.
3. Install the rlwrap-0.37-1.el5.x8664.rpm package
You can not use the keyboard in the sqlplus around the key, the wrong even delete characters can not, there is no reason ah, as a "keyboard family" this is unbearable, ripe can not bear. Is there any magic weapon that can solve this seemingly small problem but actually a big one (Zhou Hongyi said that any reason should be based on user experience)
The rlwrap-0.37-1.el5.x86_64.rpm package can solve this problem, but you need to install 2 dependent packages before installing this package
One:readline-devel-6.0-4.el6.x86_64.rpm
Two:ncurses-devel-5.7-3.20090208.el6.x86_64.rpm
Add to the oracle user environment variable
[oracle@linuxdb~] $vim .bash _ profile
Alias sqlplus= "rlwrap sqlplus" adds an alias
[oracle@linuxdb~] $. .bash _ profile environment variable takes effect
[oracle@linuxdb~] $sqlplus / as sysdba log in to sqlplus to witness the moment of miracle
Backspace can be used from top to bottom, right? isn't it cool? nice go~.
4.RMAN environment variable
Why set the RMAN environment variable
A: this is a good question. Asking a "why" before doing anything can help you improve your brilliant image of being brainless in front of others:)
To get to the point, RMAN environment variables and OS environment variables have the meaning of isomorphism. After they are set, they will take effect globally. You don't have to specify a directory and name every time. This is the gospel of lazy people. Amen! Do not set whether or not, oracle is an open software, of course, this needs to write parameters in the command to complete at one time, next time to continue to write, more suitable for people like me who like to type the keyboard crazily. Now let's configure the configuration ~ Dong Dong Bo
Because the RMAN configuration information is placed in the database control file, we have to connect to the target library before we can display the environment variables
[oracle@linuxdb~] $rman target /
RecoveryManager: Release 10.2.0.4.0-Production on Wed May 8 16:48:50 2013
Copyright (c) 1982, 2007, Oracle. All rightsreserved.
Connected to target database: BASE (DBID=1845289414) has dbid proof that it is connected to the target library
RMAN > show all
Using target database control file instead of recovery catalog uses control files instead of recovery catalog databases to store rman information
RMANconfiguration parameters are:
CONFIGURERETENTION POLICY TO REDUNDANCY 1; # default
CONFIGUREBACKUP OPTIMIZATION OFF; # default
CONFIGUREDEFAULT DEVICE TYPE TO DISK; # default
CONFIGURECONTROLFILE AUTOBACKUP OFF; # default
CONFIGURECONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO'% favored; # default
CONFIGUREDEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGUREDATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGUREARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGUREMAXSETSIZE TO UNLIMITED; # default
CONFIGUREENCRYPTION FOR DATABASE OFF; # default
CONFIGUREENCRYPTION ALGORITHM 'AES128'; # default
CONFIGUREARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURESNAPSHOT CONTROLFILE NAME TO'/opt/oracle/product/10.2.0/db_1/dbs/snapcf_base.f'; # default
This is only part of it. If you want to learn more, please refer to Books- > Backup and Recovery Reference-> CONFIGURE.
(1) configure RMAN default backup media save directory / opt/oracle/backup
[oracle@linuxdboracle] $mkdir backup create a save directory
RMAN > configure channel device type disk format'/opt/oracle/backup/DB_%U'
Usingtarget database control file instead of recovery catalog
Use the target library "control file" instead of "restore catalog database" to store rman information
Old RMANconfiguration parameters:
CONFIGURECHANNEL DEVICE TYPE DISK FORMAT'/ opt/oracle/backup/DB_%U'
New RMANconfiguration parameters:
CONFIGURECHANNEL DEVICE TYPE DISK FORMAT'/ opt/oracle/backup/DB_%U'
New RMANconfiguration parameters are successfully stored
New RMAN configuration parameters take effect
(2) configure control files to be automatically backed up and saved to / opt/oracle/backup/control
Note: backup will be triggered automatically when the contents of the control file change.
[oracle@linuxdbbackup] $mkdir control create a save directory
RMAN > configure controlfile autobackup on; starts automatic backup of control files
New RMANconfiguration parameters:
CONFIGURECONTROLFILE AUTOBACKUP ON
New RMANconfiguration parameters are successfully stored
RMAN > configure controlfile autobackup format for device type diskto'/ opt/oracle/backup/control/cf_%F'; configuration control files automatically back up and save directories and formats
New RMANconfiguration parameters:
CONFIGURECONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO'/opt/oracle/backup/control/cf_%F'
New RMANconfiguration parameters are successfully stored
(3) configure backup media retention period of 7 days
RMAN > configure retention policy to recovery window of 7 days
New RMANconfiguration parameters:
CONFIGURERETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS
New RMANconfiguration parameters are successfully stored
Once set up, let's take a look at the rman environment variable.
RMAN > show all
RMANconfiguration parameters are:
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS; recovery window 7 days
CONFIGUREBACKUP OPTIMIZATION OFF; # default
CONFIGUREDEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON; starts automatic backup of control files, directories and formats
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO'/opt/oracle/backup/control/cf_%F'
CONFIGUREDEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGUREDATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGUREARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT'/ opt/oracle/backup/DB_%U'; backup media save directory
CONFIGUREMAXSETSIZE TO UNLIMITED; # default
CONFIGUREENCRYPTION FOR DATABASE OFF; # default
CONFIGUREENCRYPTION ALGORITHM 'AES128'; # default
CONFIGUREARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURESNAPSHOT CONTROLFILE NAME TO'/ opt/oracle/product/10.2.0/db_1/dbs/snapcf_base.f';# default
We can configure these four variables at present, and specify the other variables directly on the command line.
Four backup and restore instances
1. Use RMAN to backup database, table space and data files and restore instances after database, table space and data files are damaged.
Database-level backup and recovery
Full-library compressed backup and full-library uncompressed backup application scenarios:
If your system has a dedicated "backup array" or enough disk space for you to use as you please, you are very lucky. When you encounter a boss that is not short of money, things often go against your wishes, and the disk space at our disposal is very limited, which also proves the fine tradition of diligence and frugality of the Chinese people. How to install more backups in the limited space? here we use the compression attribute to compress the original large files as much as possible to improve the utilization of space. of course, the time window for backup and recovery is longer, which is the essence of time for space.
Come on, let's prepare a full library first.
Full library compressed backup script
You can specify compression options directly from the backup as compressed backupset full database format command line
'/ opt/oracle/backup/full_bk1_%u%p%s.rmn'include current controlfile
Plus
Archivelogformat'/ opt/oracle/backup/arch_bk1_%u%p%s.rmn' delete all input
Full library uncompressed backup script
Backupfull database format
'/ opt/oracle/backup/full_bk1_%u%p%s.rmn'include current controlfile
Plus
Archivelog format'/ opt/oracle/backup/arch_bk1_%u%p%s.rmn'delete all input
The whole library uses the default channel to configure the backup script by default, while deleting the backed-up archive logs
Backup as compressed backupset full databaseinclude current controlfile plus archivelog delete all input
There are three different backup scripts above, and we use the second one, which I think is the most commonly used by the public.
Check archive log before backup, there are three archive logs
[oracle@linuxdb archdata] $ll
The total dosage is 64644
-rw-r- 1 oracle oinstall 22736384 May 8 15:35 1_13_814444678.dbf
-rw-r- 1 oracle oinstall 1024 May 8 15:35 1_14_814444678.dbf
-rw-r- 1 oracle oinstall 43454464 May 9 12:36 1_15_814444678.dbf
[oracle@linuxdb ~] $rman target / enter rman
Connected to target database: BASE (DBID=1845289414) must connect to the database.
RMAN > backup full database format
2 >'/ opt/oracle/backup/full_bk1_%u%p%s.rmn' include current controlfile
3 > plus
4 > archivelog format'/ opt/oracle/backup/arch_bk1_%u%p%s.rmn'delete all input
Starting backup at 09-MAY-13 backup start time
Current log archived is generally backed up from archive logs
Using target database control file instead ofrecovery catalog
Allocated channel: ORA_DISK_1 assigns a default channel
Channel ORA_DISK_1: sid=145 devtype=DISK
Channel ORA_DISK_1: starting archive logbackupset
Channel ORA_DISK_1: specifying archive log (s) in backup set archive log list 13: 16
Input archive log thread=1 sequence=13recid=1 stamp=814894510
Input archive log thread=1sequence=14 recid=2 stamp=814894549
Input archive log thread=1sequence=15 recid=3 stamp=814970205
Input archive log thread=1sequence=16 recid=4 stamp=814982236
Channel ORA_DISK_1: starting piece 1 at09-MAY-13
Channel ORA_DISK_1: finished piece 1 at09-MAY-13 backup film name arch_bk1_01o9792t11.rmn
Piecehandle=/opt/oracle/backup/arch_bk1_01o9792t11.rmn tag=TAG20130509T155717comment=NONE
Channel ORA_DISK_1: backup set complete,elapsed time: 00:00:02 takes 2 seconds
Channel ORA_DISK_1: deleting archive log (s) deletes the backed up archive log 13x16
Archive logfilename=/opt/oracle/archdata/1_13_814444678.dbf recid=1 stamp=814894510
Archive logfilename=/opt/oracle/archdata/1_14_814444678.dbf recid=2 stamp=814894549
Archive logfilename=/opt/oracle/archdata/1_15_814444678.dbf recid=3 stamp=814970205
Archive logfilename=/opt/oracle/archdata/1_16_814444678.dbf recid=4 stamp=814982236
Finished backup at 09-MAY-13
Starting backup at 09-MAY-13
Using channel ORA_DISK_1
Channel ORA_DISK_1: starting full datafilebackupset backup data files
Channel ORA_DISK_1: specifying datafile (s) inbackupset data file list 1: 6
Input datafile fno=00005name=/opt/oracle/oradata/base/sinojfs_01.dbf
Input datafile fno=00006name=/opt/oracle/oradata/base/sinojfs2_01.dbf
Input datafile fno=00001 name=/opt/oracle/oradata/base/system01.dbf
Input datafile fno=00002name=/opt/oracle/oradata/base/undotbs01.dbf
Input datafile fno=00003name=/opt/oracle/oradata/base/sysaux01.dbf
Input datafile fno=00004name=/opt/oracle/oradata/base/users01.dbf
Channel ORA_DISK_1: starting piece 1 at09-MAY-13
Channel ORA_DISK_1: finished piece 1 at09-MAY-13 backup film name full_bk1_02o9793012.rmn
Piecehandle=/opt/oracle/backup/full_bk1_02o9793012.rmn tag=TAG20130509T155720comment=NONE
Channel ORA_DISK_1: backup set complete,elapsed time: 00:00:03 takes 3 seconds
Channel ORA_DISK_1: starting full datafilebackupset
Channel ORA_DISK_1: specifying datafile (s) inbackupset
Including current control file inbackupset also backs up the control files and parameter files at the same time.
Channel ORA_DISK_1: starting piece 1 at09-MAY-13
Channel ORA_DISK_1: finished piece 1 at09-MAY-13 backup film name full_bk1_03o9793313.rmn
Piecehandle=/opt/oracle/backup/full_bk1_03o9793313.rmn tag=TAG20130509T155720comment=NONE
Channel ORA_DISK_1: backup set complete,elapsed time: 00:00:02 takes 2 seconds
Finished backup at 09-MAY-13
Starting backup at 09-MAY-13
Current log archived
Using channel ORA_DISK_1
Channel ORA_DISK_1: starting archive logbackupset
Channel ORA_DISK_1: specifying archive log (s) in backup set finishes with an archive log backup
Input archive log thread=1sequence=17 recid=5 stamp=814982245 stores information about the last actions of the database.
Channel ORA_DISK_1: starting piece 1 at09-MAY-13
Channel ORA_DISK_1: finished piece 1 at09-MAY-13 backup film name arch_bk1_04o9793514.rmn
Piecehandle=/opt/oracle/backup/arch_bk1_04o9793514.rmn tag=TAG20130509T155725comment=NONE
Channel ORA_DISK_1: backup set complete,elapsed time: 00:00:02 takes 2 seconds
Channel ORA_DISK_1: deleting archive log (s) Delete Archive 17
Archive logfilename=/opt/oracle/archdata/1_17_814444678.dbf recid=5 stamp=814982245
Finished backup at 09-MAY-13
When the database structure changes, automatically trigger the backup of control files and parameter files
Starting Control File and SPFILEAutobackup at 09-MAY-13
Piece handle=/opt/oracle/backup/control/cf_c-1845289414-20130509-00comment=NONE
Finished Control File and SPFILE Autobackupat 09-MAY-13
At the operating system level, check to see if these files are available, and delete the "backed-up old archive log".
[oracle@linuxdbbackup] $ll has all four backup sets
The total dosage is 382264
-rw-r-1 oracle oinstall 72907264 May 9 15:57arch_bk1_01o9792t11.rmn
-rw-r-1 oracle oinstall 3584 May 9 15:57arch_bk1_04o9793514.rmn
Drwxr-xr-x2 oracle oinstall 4096 May 9, 15:57 control
-rw-r-1 oracle oinstall 242302976 May 9 15:57 full_bk1_02o9793012.rmn
-rw-r-1 oracle oinstall 76218368 May 9 15:57full_bk1_03o9793313.rmn
[oracle@linuxdbcontrol] $ll controls automatic backup of files
The total dosage is 74464
-rw-r-1 oracle oinstall 76251136 May 9 15:57 cf_c-1845289414-20130509-00
[oracle@linuxdbarchdata] $ll archive log has been deleted
Total dosage 0
SYS@base > archive log list the new archive log started on the 18th and was backed up and deleted before the 17th.
Databaselog mode Archive Mode
Automaticarchival Enabled
Archivedestination / opt/oracle/archdata
Oldestonline log sequence 16
Next logsequence to archive 18
Currentlog sequence 18
When everything is ready, let's start to sabotage:) rename them all
[oracle@linuxdbbase] $mv system01.dbf system01.dbf.bak
[oracle@linuxdbbase] $mv sinojfs_01.dbf sinojfs_01.dbf.bak
[oracle@linuxdbbase] $mv sinojfs2_01.dbf sinojfs2_01.dbf.bak
[oracle@linuxdbbase] $mv sysaux01.dbf sysaux01.dbf.bak
SYS@base > shutdown abort forced shutdown of the library
ORACLEinstance shut down.
SYS@base > startup startup
ORACLEinstance started.
TotalSystem Global Area 1610612736 bytes
FixedSize 2084296 bytes
VariableSize 385876536 bytes
DatabaseBuffers 1207959552 bytes
RedoBuffers 14692352 bytes
Databasemounted.
ORA-01157:cannot identify/lock data file 1-see DBWR trace file
ORA-01110:data file 1:'/ opt/oracle/oradata/base/system01.dbf
If the No.1 file cannot be found, oracle starts to access the No.1 file first.
Good destroyed, market recovery, I am using the trial project database to do the test, and this is the only backup, if something goes wrong, it will not be fun, if there are similarities is a pure coincidence.
SYS@base > select status from vault instance; start the database to mount status
STATUS
-
MOUNTED
Go to RMAN and take a look at the backup set. This information is read out from control file.
RMAN > list backupset
Usingtarget database control file instead of recovery catalog
List of Backup Sets
The first backup size saves the backup date when the device is used
BSKey Size Device Type Elapsed Time Completion Time
--
1 69.53M DISK 00:00:02 09-MAY-13
BP Key: 1 Status: AVAILABLE Compressed: NO Tag: TAG20130509T155717 if you compress it, it will be YES.
Piece Name: / opt/oracle/backup/arch_bk1_01o9792t11.rmn backup slice path and name
Files included in List of Archived Logs in backup set 1
Thrd Seq Low SCN Low Time Next SCN Next Time
-
1 13 335077 07-MAY-13 362020 08-MAY-13
1 14 362020 08-MAY-13 362034 08-MAY-13
1 15 362034 08-MAY-13 398238 09-MAY-13
1 16 398238 09-MAY-13 403789 09-MAY-13
The second backup film information, because it is a data file, obviously has a large capacity.
BSKey Type LV Size Device Type Elapsed Time Completion Time
2 Full 231.07M DISK 00:00:03 09-MAY-13
BP Key: 2 Status: AVAILABLE Compressed: NO Tag: TAG20130509T155720
Path and name of Piece Name:/opt/oracle/backup/full_bk1_02o9793012.rmn backup slice
List of Datafiles in backup set 2
List of File LV Type Ckp SCN Ckp Time Name files
1 Full 403795 09-MAY-13/opt/oracle/oradata/base/system01.dbf
2 Full 403795 09-MAY-13/opt/oracle/oradata/base/undotbs01.dbf
3 Full 403795 09-MAY-13/opt/oracle/oradata/base/sysaux01.dbf
4 Full 403795 09-MAY-13/opt/oracle/oradata/base/users01.dbf
5 Full 403795 09-MAY-13/opt/oracle/oradata/base/sinojfs_01.dbf
6 Full 403795 09-MAY-13/opt/oracle/oradata/base/sinojfs2_01.dbf
The third backup film information is the control file.
BSKey Type LV Size Device Type Elapsed Time Completion Time
3 Full 72.67M DISK 00:00:01 09-MAY-13
BP Key: 3 Status: AVAILABLE Compressed: NO Tag: TAG20130509T155720
Piece Name:/opt/oracle/backup/full_bk1_03o9793313.rmn
Control File Included: Ckp SCN: 403796 Ckp time: 09-MAY-13
The fourth backup film information is the final archive log.
BSKey Size Device Type Elapsed Time Completion Time
--
4 3.00K DISK 00:00:01 09-MAY-13
BP Key: 4 Status: AVAILABLE Compressed: NO Tag: TAG20130509T155725
Piece Name:/opt/oracle/backup/arch_bk1_04o9793514.rmn
List of Archived Logs in backup set 4
Thrd Seq Low SCN Low Time Next SCN Next Time
-
1 17 403789 09-MAY-13 403800 09-MAY-13
The fifth backup film information saves the automatic backup of control files and parameter files.
BSKey Type LV Size Device Type Elapsed Time Completion Time
5 Full 72.70M DISK 00:00:01 09-MAY-13
BP Key: 5 Status: AVAILABLE Compressed: NO Tag: TAG20130509T155728
Piece Name:/opt/oracle/backup/control/cf_c-1845289414-20130509-00
Control File Included: Ckp SCN: 403806 Ckp time: 09-MAY-13
SPFILE Included: Modification time: 08-MAY-13
Everything is ready but Dongfeng, let's recover! Please pay attention to the size of the backup set, which is an important indicator that affects the speed of recovery
RMAN > restore database
Startingrestore at 09-MAY-13
Allocatedchannel: ORA_DISK_1
ChannelORA_DISK_1: sid=155 devtype=DISK
ChannelORA_DISK_1: starting datafile backupset restore has copied back the data file using backup.
ChannelORA_DISK_1: specifying datafile (s) to restore from backup set
Restoring datafile 00001 to / opt/oracle/oradata/base/system01.dbf
Restoring datafile 00002 to / opt/oracle/oradata/base/undotbs01.dbf
Restoring datafile 00003 to / opt/oracle/oradata/base/sysaux01.dbf
Restoring datafile 00004 to / opt/oracle/oradata/base/users01.dbf
Restoring datafile 00005 to / opt/oracle/oradata/base/sinojfs_01.dbf
Restoring datafile 00006 to / opt/oracle/oradata/base/sinojfs2_01.dbf
ChannelORA_DISK_1: reading from backup piece / opt/oracle/backup/full_bk1_02o9793012.rmn
ChannelORA_DISK_1: restored backup piece 1
Piecehandle=/opt/oracle/backup/full_bk1_02o9793012.rmn tag=TAG20130509T155720
ChannelORA_DISK_1: restore complete, elapsed time: 00:01:46
Finishedrestore at 09-MAY-13
#
[oracle@linuxdbbase] $ll
-rw-r- 1 oracle oinstall 10737426432 May 9 18:11 sinojfs_01.dbf
-rw-r-1 oracle oinstall 10737426432 May 9 17:28 sinojfs_01.dbf.bak
-rw-r- 1 oracle oinstall 10737426432 May 9 18:10 sinojfs2_01.dbf
-rw-r-1 oracle oinstall 10737426432 May 9 15:57 sinojfs2_01.dbf.bak
-rw-r- 1 oracle oinstall 125837312 May 9 18:11 sysaux01.dbf
-rw-r-1 oracle oinstall 125837312 May 9 17:27 sysaux01.dbf.bak
-rw-r- 1 oracle oinstall 314580992 May 9 18:11 system01.dbf
-rw-r-1 oracle oinstall 314580992 May 9 17:28 system01.dbf.bak
You can see it at the operating system level. Is it right?
#
RMAN > recover database; requires not only restore but also archive and redo log for media recovery.
Startingrecover at 09-MAY-13
Usingchannel ORA_DISK_1
Starting media recovery
Mediarecovery complete, elapsed time: 00:00:07
Finishedrecover at 09-MAY-13
RMAN > alter database open; restore the database to the latest state in order to successfully open
Databaseopened
SYS@base > select status from v$instance
STATUS
-
OPEN
SYS@base > archive log list because we applied to the last log, so the log will continue to be extended before
Databaselog mode Archive Mode
Automaticarchival Enabled
Archivedestination / opt/oracle/archdata
Oldestonline log sequence 17
Next logsequence to archive 19
Currentlog sequence 19
#
Tablespace level backup and recovery
Save the directory using the default channel default backup media
RMAN > backup tablespace sinojfs2
Startingbackup at 09-MAY-13
Usingchannel ORA_DISK_1
ChannelORA_DISK_1: starting full datafile backupset
ChannelORA_DISK_1: specifying datafile (s) in backupset
The tablespace inputdatafile fno=00006 name=/opt/oracle/oradata/base/sinojfs2_01.dbf contains a data file.
ChannelORA_DISK_1: starting piece 1 at 09-MAY-13
ChannelORA_DISK_1: path and name of finished piece 1 at 09-MAY-13 backup slice
Piecehandle=/opt/oracle/backup/DB_06o97i9d_1_1 tag=TAG20130509T183421 comment=NONE
ChannelORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finishedbackup at 09-MAY-13
Look, automatically back up control files and parameter files again.
StartingControl File and SPFILE Autobackup at 09-MAY-13
Piecehandle= / opt/oracle/backup/control/cf_c-1845289414-20130509-01 comment=NONE
FinishedControl File and SPFILE Autobackup at 09-MAY-13
View at the operating system level
[oracle@linuxdbbackup] $ll
The total dosage is 383112
-rw-r-1 oracle oinstall 72907264 May 9 15:57arch_bk1_01o9792t11.rmn
-rw-r-1 oracle oinstall 3584 May 9 15:57arch_bk1_04o9793514.rmn
Drwxr-xr-x2 oracle oinstall 4096 May 9, 18:34 control
-backup set of DB_06o97i9d_1_1 tablespaces for rw-r- 1 oracle oinstall 868352 May 9 18:34
-rw-r-1 oracle oinstall 242302976 May 9 15:57 full_bk1_02o9793012.rmn
-rw-r-1 oracle oinstall 76218368 May 9 15:57full_bk1_03o9793313.rmn
[oracle@linuxdbcontrol] $ll
The total dosage is 148928
-rw-r-1 oracle oinstall 76251136 May 9 15:57 cf_c-1845289414-20130509-00
-rw-r- 1 oracle oinstall 76251136 May 9 18:34 cf_c-1845289414-20130509-01 this is the second automatic backup set
If no save directory is specified, save the directory / opt/oracle/backup using the default backup media in the RMAN parameter
#
Enter sqlplus to delete sinojfs2 tablespace
SYS@base > drop tablespace sinojfs2 including contents and datafiles; delete sinojfs2 tablespace
Tablespacedropped.
SYS@base > select * from vested tablespace; has been deleted
TS# NAME INC BIG FLA ENC
-
0 SYSTEM YES NO YES
1 UNDOTBS1 YES NO YES
2 SYSAUX YES NO YES
3 TEMP NO NO YES
4 USERS YES NO YES
5 SINOJFS YES NO YES
6 rowsselected.
Use tablespace backup for recovery and enter RMAN
RMAN > restore tablespace sinojfs2
Startingrestore at 09-MAY-13
Usingtarget database control file instead of recovery catalog
Allocatedchannel: ORA_DISK_1
ChannelORA_DISK_1: sid=155 devtype=DISK
RMAN-00571:===
RMAN-00569:= ERROR MESSAGE STACK FOLLOWS =
RMAN-00571:===
RMAN-03002: failure of restore command at 05/09/2013 19:14:39
RMAN-20202: tablespace not found in the recovery catalog
RMAN-06019: could not translate tablespace name "SINOJFS2"
Do you know why you can't find the sinojfs2 tablespace? Is the database structure stored in the control file? how did we destroy the table space just now? The statement drop tablespace sinojfs2 includingcontents and datafiles; is used, which deletes the tablespace and deletes the tablespace information in the control file as well, so the information can not be found later in using the control file to recover the tablespace. What are we going to do? if this doesn't work, then do it another way.
First of all, restore the database to the original state, the process is omitted, as I have just mentioned, it is estimated that we will throw bricks again!
Recreate a new sinojfs2 tablespace
SQL > createtablespace sinojfs2 datafile'/ opt/oracle/oradata/base/sinojfs2_01.dbf' size10G autoextend off
Tablespace created
SQL > selectfile#,name,status from v$datafile where file#=6
FILE# NAME STATUS
-
6/opt/oracle/oradata/base/sinojfs2_01.dbf ONLINE
Back up the tablespace once
RMAN > backup tablespace sinojfs2
Startingbackup at 09-MAY-13
Usingchannel ORA_DISK_1
ChannelORA_DISK_1: starting full datafile backupset
ChannelORA_DISK_1: specifying datafile (s) in backupset
Inputdatafile fno=00006 name=/opt/oracle/oradata/base/sinojfs2_01.dbf
ChannelORA_DISK_1: starting piece 1 at 09-MAY-13
ChannelORA_DISK_1: finished piece 1 at 09-MAY-13
Piecehandle=/opt/oracle/backup/DB_0fo97o6p_1_1 tag=TAG20130509T201521comment=NONE
ChannelORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finishedbackup at 09-MAY-13
StartingControl File and SPFILE Autobackup at 09-MAY-13
Piecehandle=/opt/oracle/backup/control/cf_c-1845289414-20130509-03 comment=NONE
FinishedControl File and SPFILE Autobackup at 09-MAY-13
This time, we directly delete the data files corresponding to the tablespaces.
[oracle@linuxdbbase] $rm-rf sinojfs2_01.dbf
SYS@base > alter tablespace sinojfs2 offline; let tablespace offline
Altertablespace sinojfs2 offline
*
ERROR atline 1:
ORA-01116:error in opening database file 6
ORA-01110:data file 6:'/ opt/oracle/oradata/base/sinojfs2_01.dbf' cannot find the corresponding data file
ORA-27041:unable to open file
Linux-x86_64Error: 2: No such file or directory
Additionalinformation: 3
SYS@base > alter database datafile 6 offline; offline data file first
Databasealtered.
At this point, the sinojfs2 tablespace can be restored in the database open state
RMAN > restore tablespace sinojfs2; copy files
Startingrestore at 09-MAY-13
Usingchannel ORA_DISK_1
ChannelORA_DISK_1: starting datafile backupset restore
ChannelORA_DISK_1: specifying datafile (s) to restore from backup set
Restoringdatafile 00006 to / opt/oracle/oradata/base/sinojfs2_01.dbf
ChannelORA_DISK_1: reading from backup piece / opt/oracle/backup/DB_0fo97o6p_1_1
ChannelORA_DISK_1: restored backup piece 1
Piecehandle=/opt/oracle/backup/DB_0fo97o6p_1_1 tag=TAG20130509T201521
ChannelORA_DISK_1: restore complete, elapsed time: 00:00:55
Finishedrestore at 09-MAY-13
RMAN > recover tablespace sinojfs2; media recovery
Startingrecover at 09-MAY-13
Usingchannel ORA_DISK_1
Startingmedia recovery
Mediarecovery complete, elapsed time: 00:00:01
Finishedrecover at 09-MAY-13
SQL > selectfile#,name,status from v$datafile where file#=6
FILE# NAME STATUS
-
6/opt/oracle/oradata/base/sinojfs2_01.dbf OFFLINE
SYS@base > alter databasedatafile 6 online; Boot offline to online
Database altered.
SQL > selectfile#,name,status from v$datafile where file#=6
FILE# NAME STATUS
-
6/opt/oracle/oradata/base/sinojfs2_01.dbf ONLINE
It is thrilling to fully recover sinojfs2 from this tablespace. The same is true of data file recovery. The following commands will not be demonstrated here.
Restore datafile 6
Recover datafile 6
Here's a tip. After backing up so many backup sets, how do we check the correspondence between rman metadata and backup sets on the operating system?
RMAN > crosscheck backupset; cross-check to see if the number of objects is the same. We have a total of 9 backup sets here, and then take a look at the operating system.
Using channel ORA_DISK_1
Crosschecked backup piece: found to be 'AVAILABLE'
Backup piece handle=/opt/oracle/backup/arch_bk1_09o97nhr19.rmn recid=7stamp=814997052
Crosschecked backup piece: found to be 'AVAILABLE'
Backup piece handle=/opt/oracle/backup/full_bk1_0ao97nhu110.rmn recid=8stamp=814997055
Crosschecked backup piece: found to be 'AVAILABLE'
Backup piece handle=/opt/oracle/backup/full_bk1_0bo97ni5111.rmn recid=9stamp=814997061
Crosschecked backup piece: found to be 'AVAILABLE'
Backup piece handle=/opt/oracle/backup/arch_bk1_0co97ni7112.rmn recid=10stamp=814997064
Crosschecked backup piece: found to be 'AVAILABLE'
Backup piece handle=/opt/oracle/backup/control/cf_c-1845289414-20130509-01recid=11 stamp=814997066
Crosschecked backup piece: found to be 'AVAILABLE'
Backup piece handle=/opt/oracle/backup/control/cf_c-1845289414-20130509-02recid=12 stamp=814997575
Crosschecked backup piece: found to be 'AVAILABLE'
Backup piece handle=/opt/oracle/backup/DB_0fo97o6p_1_1 recid=13stamp=814997721
Crosschecked backup piece: found to be 'AVAILABLE'
Backup piece handle=/opt/oracle/backup/control/cf_c-1845289414-20130509-03recid=14 stamp=814997723
Crosschecked backup piece: found to be 'AVAILABLE'
Backup piece handle=/opt/oracle/backup/control/cf_c-1845289414-20130509-04recid=15 stamp=814998546
Crosschecked 9 objects
Delete backup deletes all backups
Delete expired backup deletes all expired backups
Summary: we have successfully carried out database-level, tablespace, data file-level backup and recovery, when your database is in a stable state, you must remember to do a full "in case of future trouble". Good, that's all for today.
RMAN backupset catalog full library backup differential incremental backup cumulative incremental backup
After reading the above, do you have any further understanding of how to analyze RMAN backup and recovery in depth? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 208
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.