Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the rman-based recovery operations?

2025-01-16 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 the recovery operations based on rman, which may not be well understood by many people. in order to make you understand better, the editor has summarized the following for you. I hope you can get something from this article.

For the backup of RMAN, here are some recovery operations using RMAN from several aspects.

Restore

1. Full media recovery of the database

1.1 enter the rman command line

Rman target /

1.2 start backup

Backup database format=' / oracle/u01/app/oracle/backup/%U'

1.3 consistency stops the database

Shutdown immediate

1.4 Delete all data files

Rm-rf / oracle/u01/app/oracle/oradata/orcl/*.dbf

Start recovery:

1.5 Boot Database to mount status using rman

RMAN > startup mount

1.6 Database repair

RMAN > restore database

1.7 Database recovery

RMAN > recover database

You can add additional parameters:

Recover database delete archivelog; is used to delete archive log files generated during recovery

Recover database skip tablespace temp; specifies that temporary tablespaces are skipped during recovery, and temporary tablespaces are not restored by default.

Recover database delete archivelog maxsize 100m; used to specify that the size of automatically generated archives is limited to 100m during recovery. If this size is exceeded, it will be deleted in the loop to continue to use for recovery.

1.8 Boot the database to open status

RMAN > alter database open

two。 Recovery of tablespace

On the basis of backup, we first simulate the destruction of the tablespace, and then restore it.

2.1 destroy users tablespace

Echo "" > / oracle/u01/app/oracle/oradata/orcl/users01.dbf

2.2 switch Log

At this point, we query the table in the tablespace users and do not necessarily report an error, because there are still records in memory.

It's the information in memory, so we need to switch logs manually.

SQL > alter system switch logfile

Execute several more times to ensure the completion of the handover.

2.3 check that tablespaces are available

SQL > select * from test

ERROR at line 1:

ORA-00376:file 4 cannot be read at this time

ORA-01110: data file 4:'/ oracle/u01/app/oracle/oradata/orcl/users01.dbf'

At this time, it is found that the users tablespace can no longer be used.

Start recovery

2.4Tablespace offline

RMAN > SQL 'alter tablespace users offline'

2.5 repair

RMAN > restore tablespace users

2.6 recovery

RMAN > recover tablespace users

2.7Tablespace online

RMAN > SQL 'alter tablespace users online'

2.8 verify whether it is restored

SQL > select * from test

Data can be queried, indicating that the tablespace has been restored

3. Recovery of data files

3.1 offline the data file

RMAN > SQL 'alter database datafile 4 offline'

3.2 repair

RMAN > restore datafile 4

3.3 recovery

RMAN > recover datafile 4

3.4 online the data file

RMAN > SQL 'alter database datafile 4 online'

RMAN > SQL 'alter database datafile 4 offline'

RMAN > run {

RMAN > SQL 'alter database datafile 4 online'

4.1 enter the rman command line

SQL > rman target /

4.2 backup Archive

RMAN > backup archivelog all delete input

4.3 check backup

RMAN > List backup of archivelog all

BS Key Size Device Type Elapsed Time Completion Time

--

91 59.54M DISK 00:00:02 28-FEB-13

BP Key: 95 Status: AVAILABLE Compressed: NO Tag: TAG20130228T162106

Piece Name: / oracle/u01/app/oracle/flash_recovery_area/ORCL/backupset/2013_02_28/o1_mf_annnn_TAG20130228T162106_8ly4vmt4_.bkp

List of Archived Logs in backup set 91

Thrd Seq Low SCN Low Time Next SCN Next Time

-

1 311 5582914 27-FEB-13 5583269 27-FEB-13

1 312 5583269 27-FEB-13 5601615 28-FEB-13

1 313 5601615 28-FEB-13 5623126 28-FEB-13

1 314 5623126 28-FEB-13 5625133 28-FEB-13

1 315 5625133 28-FEB-13 5625135 28-FEB-13

1 316 5625135 28-FEB-13 5625138 28-FEB-13

1 317 5625138 28-FEB-13 5628235 28-FEB-13

1 318 5628235 28-FEB-13 5628281 28-FEB-13

Through viewing, the archivelog from 311-318 is backed up and saved in the backup set, and the archive log files under the / oracle/u01/app/oracle/ path are deleted.

4.4 resume archiving

RMAN > restore archivelog sequence between 311 and 315

Check the log_archive_dest_1 path and find that 311-315 archived files have been recovered

4.4 specify the archive recovery path

Set the path for recovery by setting the path in the run script

RMAN > run {

Set archivelog destination to''

Restore archivelog sequence between 311 and 315

Set archivelog destination to''

Restore archivelog sequence between 316 and 317

}

You can specify multiple paths.

5. Control the recovery of files

5.1 enable automatic backup of control files

RMAN > CONFIGURE CONTROLFILE AUTOBACKUP ON

5.2 backup control files

RMAN > backup current controlfile

5.3Setting DBID

Without the control file, the database can only be started to nomount state. You need to set DBID before starting.

RMAN > set dbid=1324770912

How to get DBID:

A) backup files that were not renamed when creating automatic backups contain

B) when connecting with rman

C) Rman backup log

D) Database v$database view

5.4 restore control files

RMAN > restore controlfile from autobackup

If no path is specified, it will be restored to the path of the parameter file control_files

Specify the path:

RMAN > restore controlfile to'/ home/oracle/control01.ctl' from autobackup

5.5 unable to find a solution to the recovery path

Change the backup path before automatically backing up the control files, such as / oracle/u01/app/oracle/backup

RMAN > CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK

TO'/ oracle/u01/app/oracle/backup/%F'

Backup tablespace

RMAN > backup tablespace users

Because automatic backup control files are enabled, backup tablespaces also back up control files and query

RMAN > list backup of controlfile

At this point, there is a backup of the control file.

Record the dbid=1324770912 at this time

SQL > shutdown immediate

SQL > startup nomount

SQL > rman target /

RMAN > set dbid=1324770912

RMAN > restore controlfile from autobackup

Prompt to report error:

Starting restore at 28-FEB-13

Using target database control file instead of recovery catalog

Allocated channel: ORA_DISK_1

Channel ORA_DISK_1: sid=540 devtype=DISK

Recovery area destination: / oracle/u01/app/oracle/flash_recovery_area

Database name (or database unique name) used for search: ORCL

Channel ORA_DISK_1: no autobackups found in the recovery area

Channel ORA_DISK_1: looking for autobackup on day: 20130228

Channel ORA_DISK_1: looking for autobackup on day: 20130227

Channel ORA_DISK_1: looking for autobackup on day: 20130226

Channel ORA_DISK_1: looking for autobackup on day: 20130225

Channel ORA_DISK_1: looking for autobackup on day: 20130224

Channel ORA_DISK_1: looking for autobackup on day: 20130223

Channel ORA_DISK_1: looking for autobackup on day: 20130222

Channel ORA_DISK_1: no autobackup in 7 days found

RMAN-00571: =

RMAN-00569: = ERROR MESSAGE STACK FOLLOWS =

RMAN-00571: =

RMAN-03002: failure of restore command at 02/28/2013 17:12:17

RMAN-06172: no autobackup found or specified handle is not a valid copy or piece

Because: the automatic backup control file cannot be found in the default path to further produce rman parameters.

RMAN > show all

Found that the path to the automatic backup control file is not / oracle/u01/app/oracle/backup, but the default path

The default path for windows is: $ORACLE_HOME/database

On linux, the default path is $ORACLE_HOME/dbs.

So why did we set the rman parameter before, and it will change here? because we use the parameter set by configure, this change is saved in the control file, so we can't find the path.

There are two ways to deal with this situation:

A) copy the backed up files to the required default path: $ORACLE_HOME/dbs

B) reset the automatic backup control file path

Set CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO'/ oracle/u01/app/oracle/backup/%F'

Why set is used to set it up here, because now the database is in nomount state and cannot be set with configure.

5.6 if the database is a non-archive database

Do not use configure when modifying the automatic backup control file path, because this command is permanent and the default is saved to the control file, which results in the control file cannot be found during the restore. Use the set command to set the modify automatic backup control file path.

Restore from a backup set

5.7 restore control files through backup in the backup set

Need to set dbid

Start the database to nomount state

Restore control file

Restore controlfile from

'/ oracle/u01/app/oracle/backup/c-1324770912-20130301-08'

In this way, even if you change the default parameters, you can restore as long as the specified backup set is correct.

Note:

Start the database after restoring the control file:

A) start the database to mount

SQL > alter database mount

B) restore the database

SQL > recover database using backup controlfile

Auto

Additional information: 3

After auto, archiving is automatically applied, but the current log file has not been archived yet, so you need to specify redo.log to apply the rest of the logs to restore the database

SQL > recover database using backup controlfile

/ oracle/u01/app/oracle/oradata/orcl/redo01.log

Media recovery complete.

Hint: Media recovery complete. Recovery complete

C) redo log files

SQL > alter database open resetlogs

Parameter files will be backed up automatically even if they are not backed up manually. Generally, they are not backed up manually.

Recovery is similar to the recovery of control files.

6.1 restore with automatic backup

A) set dbid

B) Boot to nomount state

C) recovery

RMAN > restore spfile from autobackup

6.2 specify recovery files

It can also be restored through manually specified backup control files.

RMAN > restore spfile from'/ oracle/u01/app/oracle/backup/ cmur1324770912-20130301-0a'

6.3 restore to the specified destination address

RMAN > restore spfile to'/ home/oracle/spfiletmp.ora' from'/ oracle/u01/app/oracle/backup/ CML 1324770912-20130301-0a. After reading the above, do you have any further understanding of rman-based recovery operations? 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: 0

*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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report