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

[backup recovery]} off-machine backup to restore database

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

This lab restores library An on library B, but changes the instance name.

The target library just follows until the oracle software.

Source Library (A Library): 192.168.56.12 ORACLE_SID=DBdb DBID=3282897732

Target Library (Library B): 192.168.56.28 ORACLE_SID=kill

Source database backup (A database) online complete:

Full library backup plus control files and archive backup; (hot backup)

Run

{

Backup database format'/ home/oracle/BKdbfile_%d_%U_%T'

Sql 'alter system archive log current'

# backup all archive logs

BACKUP FORMAT'/ home/oracle/BKarch_%d_%U_%T'

ARCHIVELOG ALL DELETE INPUT

BACKUP CURRENT CONTROLFILE FORMAT'/ home/oracle/conbak.%u'

}

-this time it is all covered by the database, and the automatic control file backup is not enabled, but when the database structure changes, the control file and spfile will back up automatically.

RMAN > backup database

Starting backup at 11-DEC-17

Using channel ORA_DISK_1

Channel ORA_DISK_1: starting full datafile backup set

Channel ORA_DISK_1: specifying datafile (s) in backup set

Input datafile file number=00004 name=/u01/app/oracle/oradata/DBdb/users01.dbf

Input datafile file number=00003 name=/u01/app/oracle/oradata/DBdb/undotbs01.dbf

Input datafile file number=00001 name=/u01/app/oracle/oradata/DBdb/system01.dbf

Input datafile file number=00002 name=/u01/app/oracle/oradata/DBdb/sysaux01.dbf

Input datafile file number=00005 name=/u01/app/oracle/oradata/DBdb/example01.dbf

Channel ORA_DISK_1: starting piece 1 at 11-DEC-17

Channel ORA_DISK_1: finished piece 1 at 11-DEC-17

Piece handle=/u01/app/oracle/fast_recovery_area/DBDB/newback/DBDB/backupset/2017_12_11/o1_mf_nnndf_TAG20171211T070728_f2vhkjlf_.bkp tag=TAG20171211T070728 comment=NONE

Channel ORA_DISK_1: backup set complete, elapsed time: 00:00:55

Channel ORA_DISK_1: starting full datafile backup set

Channel ORA_DISK_1: specifying datafile (s) in backup set

Including current control file in backup set

Including current SPFILE in backup set

Channel ORA_DISK_1: starting piece 1 at 11-DEC-17

Channel ORA_DISK_1: finished piece 1 at 11-DEC-17

Piece handle=/u01/app/oracle/fast_recovery_area/DBDB/newback/DBDB/backupset/2017_12_11/o1_mf_ncsnf_TAG20171211T070728_f2vhm8nz_.bkp tag=TAG20171211T070728 comment=NONE

Channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01

Finished backup at 11-DEC-17

Target library (B library operation):

[oracle@testdb ~] $cat .bash _ profile

Export ORACLE_SID=kill

Export ORACLE_BASE=/u01/app/oracle

Export ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1

Export NLS_LANG= "american_america.ZHS16GBK"

Export NLS_DATE_FORMAT= "YYYY-MM-DD HH24:Mi:SS"

Export LD_LIBRARY_PATH=$ORACLE_HOME/lib

Export PATH=$ORACLE_HOME/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin

[oracle@testdb ~] $

Note: when the ORACLE_BASE/ORACLE_HOME directory is inconsistent, you can not set the environment variable file first and wait until it is restored.

1. Copy the RMAN backup file:

Create the same directory and copy the source library RMAN backup file to the target library because it is restored with the backup control file, and the backup location of the control file record is as above.

[oracle@testdb] $mkdir-p / u01/app/oracle/fast_recovery_area/DBDB/newback/DBDB/backupset/2017_12_11/

[oracle@testdb ~] $cd / u01/app/oracle/fast_recovery_area/DBDB/newback/DBDB/backupset/2017_12_11/

[oracle@testdb 2017 / 12 / 11] $

[oracle@testdb 2017 / 12 / 11] $scp oracle@192.168.56.12:/u01/app/oracle/fast_recovery_area/DBDB/newback/DBDB/backupset/2017_12_11/o1_mf_nnndf_TAG20171211T070728_f2vhkjlf_.bkp.

Oracle@192.168.56.12's password:

O1_mf_nnndf_TAG20171211T070728_f2vhkjlf_.bkp 100% 1351MB 28.1MB/s 00:48

[oracle@testdb 2017 / 12 / 11] $

[oracle@testdb 2017 / 12 / 11] $scp oracle@192.168.56.12:/u01/app/oracle/fast_recovery_area/DBDB/newback/DBDB/backupset/2017_12_11/o1_mf_ncsnf_TAG20171211T070728_f2vhm8nz_.bkp.

Oracle@192.168.56.12's password:

O1_mf_ncsnf_TAG20171211T070728_f2vhm8nz_.bkp 100% 10MB 9.9MB/s 00:00

[oracle@testdb 2017 / 12 / 11] $

two。 Configure the target database:

The target library sets the environment variable, starts rman to nomount status, and sets dbid (that is, source library dbid)

[oracle@testdb 2017 / 12 / 25] $echo $ORACLE_SID

Kill

[oracle@testdb 2017 / 12 / 25] $

[oracle@testdb 2017 / 12 / 25] $rman target /

Recovery Manager: Release 11.2.0.4.0-Production on Mon Dec 25 16:29:37 2017

Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.

Connected to target database (not started)

RMAN > set dbid 3282897732

Executing command: SET DBID

RMAN >

Set dbid, literally, is the ID of the specified database, which is the same as the DBID in controlfile.

If you start the database to the NOMOUNT state with the following command

RMAN > startup nomount

At this point, RMAN can use a dummy parameter file to launch the instance to the NOMOUNT state.

That is, a virtual DB whose dbname is DUMMY. This dbname is not available in the backup.

So you need to set up dbid,RMAN to determine which backup to use.

3. The target library starts to nomount mode:

An error will be reported at this time because the target library does not have a parameter file, but it can also boot to nomount mode, allocate memory and start background processes

RMAN > startup nomount

Startup failed: ORA-01078: failure in processing system parameters

LRM-00109: could not open parameter file'/ u01amp appActionoracleUniverse produce 11.2.0 Universe dbhomeowners 1anddbsAccording to initkill.ora'

Starting Oracle instance without parameter file for retrieval of spfile

Oracle instance started

Total System Global Area 1068937216 bytes

Fixed Size 2260088 bytes

Variable Size 281019272 bytes

Database Buffers 780140544 bytes

Redo Buffers 5517312 bytes

RMAN >

4. Restore the parameter file:

RMAN > restore spfile to pfile'? / dbs/initkill.ora' from'/ u01 dictionary applicationoracleUniverse fastrecoveryrecoveryAccordBDBDB; newbackDBDB; DBDB backupsets2017; 12; 11; 2017; 12; 11; 11; 20171211T070728; 2vhm8nz.bkp'

Starting restore at 2017-12-25 18:13:44

Using target database control file instead of recovery catalog

Allocated channel: ORA_DISK_1

Channel ORA_DISK_1: SID=19 device type=DISK

Channel ORA_DISK_1: restoring spfile from AUTOBACKUP / u01/app/oracle/fast_recovery_area/DBDB/newback/DBDB/backupset/2017_12_11/o1_mf_ncsnf_TAG20171211T070728_f2vhm8nz_.bkp

Channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete

Finished restore at 2017-12-25 18:13:46

-- View the recovered pfile file

[oracle@testdb ~] $cd $ORACLE_HOME/dbs

[oracle@testdb dbs] $ls

Hc_kill.dat initkill.ora init.ora

[oracle@testdb dbs] $

5. Edit the pfile parameter file:

Edit the pfile parameter file and create relevant directories in the target library, because only database software is installed in the target library, so many directories are not created, or the source library directory is different from the target library directory

[oracle@testdb dbs] $vi initkill.ora

Kill.__db_cache_size=394264576

Kill.__java_pool_size=4194304

Kill.__large_pool_size=8388608

Kill.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment

Kill.__pga_aggregate_target=293601280

Kill.__sga_target=545259520

Kill.__shared_io_pool_size=0

Kill.__shared_pool_size=130023424

Kill.__streams_pool_size=0

*. _ optimizer_adaptive_cursor_sharing=FALSE

*. _ optimizer_extended_cursor_sharing='NONE'

*. _ optimizer_extended_cursor_sharing_rel='NONE'

* .audit_file_dest='/u01/app/oracle/admin/kill/adump'

* .audit_trail='DB'

* .compatible='11.2.0.4.0'

* .control_files='/u01/app/oracle/oradata/kill/control01.ctl','/u01/app/oracle/fast_recovery_area/kill/control02.ctl'#Restore Controlfile

* .db_block_size=8192

* .db_domain=''

* .db_name='DBdb'

* .db_recovery_file_dest='/u01/app/oracle/fast_recovery_area/kill/newback'

* .db_recovery_file_dest_size=9663676416

* .diagnostic_dest='/u01/app/oracle'

* .dispatchers=' (PROTOCOL=TCP) (SERVICE=DBdbXDB)'

* .filesystemio_options='ASYNCH'

* .memory_target=838860800

* .nls_language='SIMPLIFIED CHINESE'

* .nls_territory='CHINA'

* .open_cursors=300

* .processes=300

* .remote_login_passwordfile='EXCLUSIVE'

* .service_names='service1,service2,service3'

* .undo_tablespace='UNDOTBS1'

[oracle@testdb dbs] $

-- create the corresponding directory according to the pfile parameter file

[oracle@testdb dbs] $mkdir-p / u01/app/oracle/admin/kill/adump

[oracle@testdb dbs] $mkdir-p / u01/app/oracle/oradata/kill

[oracle@testdb dbs] $mkdir-p / u01/app/oracle/fast_recovery_area/kill

[oracle@testdb dbs] $mkdir-p / u01/app/oracle/fast_recovery_area/kill/newback

[oracle@testdb dbs] $

6. Start the database to nomount mode through pfile and test whether pfile has modified parameters

[oracle@testdb dbs] $echo $ORACLE_SID

Kill

[oracle@testdb dbs] $sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Mon Dec 25 18:18:57 2017

Copyright (c) 1982, 2013, Oracle. All rights reserved.

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.4.0-64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL > show parameter spfile

NAME TYPE VALUE

-

Spfile string

SQL >

SQL > create spfile from pfile

File created.

SQL > shutdown immediate

ORA-01507: database not mounted

ORACLE instance shut down.

SQL >

SQL > startup nomount

ORACLE instance started.

Total System Global Area 835104768 bytes

Fixed Size 2257840 bytes

Variable Size 549456976 bytes

Database Buffers 281018368 bytes

Redo Buffers 2371584 bytes

SQL >

SQL > show parameter spfile

NAME TYPE VALUE

-

Spfile string / u01/app/oracle/product/11.2.0

/ dbhome_1/dbs/spfilekill.ora

6.。 Restore the control file:

Restore the control file and boot to mount mode

[oracle@testdb ~] $rman target /

Recovery Manager: Release 11.2.0.4.0-Production on Mon Dec 25 18:21:51 2017

Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.

Connected to target database: DBDB (not mounted)

RMAN > restore controlfile from'/ u01ActionActionActionoracleUniverse fastfastfastened recoveryCharacter DBDBOnBackBackBackBackset and2017 December 11 orchard ncsnfTAG20171211T070728 recovery f2vhm8nzwith.bkp'

Starting restore at 2017-12-25 18:22:13

Using target database control file instead of recovery catalog

Allocated channel: ORA_DISK_1

Channel ORA_DISK_1: SID=20 device type=DISK

Channel ORA_DISK_1: restoring control file

Channel ORA_DISK_1: restore complete, elapsed time: 00:00:01

Output file name=/u01/app/oracle/oradata/kill/control01.ctl

Output file name=/u01/app/oracle/fast_recovery_area/kill/control02.ctl

Finished restore at 2017-12-25 18:22:15

RMAN >

-- launch the library to mount:

RMAN > alter database mount

Database mounted

Released channel: ORA_DISK_1

7. Restore the data file (i.e. set newname):

RMAN > run {

Set newname for datafile 1 to'/ u01qqapp.oracle.oradataActionSystem01.dbf'

Set newname for datafile 2 to'/ u01qqappActionoradata 'sysaux01.dbf'

Set newname for datafile 3 to'/ u01qqappActionoradata 'KILLTABS01.dbf'

Set newname for datafile 4 to'/ u01qqapp.oracle.oradatausers01.dbf'

Set newname for datafile 5 to'/ u01qqapp.oracle.oradata.oradata

Restore database

Switch datafile all

Recover database

}

Executing command: SET NEWNAME

Executing command: SET NEWNAME

Executing command: SET NEWNAME

Executing command: SET NEWNAME

Executing command: SET NEWNAME

Starting restore at 2017-12-25 17:12:18

Starting implicit crosscheck backup at 2017-12-25 17:12:18

Allocated channel: ORA_DISK_1

Channel ORA_DISK_1: SID=1 device type=DISK

Crosschecked 1 objects

Finished implicit crosscheck backup at 2017-12-25 17:12:19

Starting implicit crosscheck copy at 2017-12-25 17:12:19

Using channel ORA_DISK_1

Finished implicit crosscheck copy at 2017-12-25 17:12:19

Searching for all files in the recovery area

Cataloging files...

Cataloging done

List of Cataloged Files

=

File Name: / u01/app/oracle/flash_recovery_area/ORCL/backupset/2017_12_25/o1_mf_ncsnf_TAG20171225T125632_f411cfmz_.bkp

Using channel ORA_DISK_1

Channel ORA_DISK_1: starting datafile backup set restore

Channel ORA_DISK_1: specifying datafile (s) to restore from backup set

Channel ORA_DISK_1: restoring datafile 00001 to / u01/app/oracle/oradata/kill/system01.dbf

Channel ORA_DISK_1: restoring datafile 00002 to / u01/app/oracle/oradata/kill/undotbs01.dbf

Channel ORA_DISK_1: restoring datafile 00003 to / u01/app/oracle/oradata/kill/sysaux01.dbf

Channel ORA_DISK_1: restoring datafile 00004 to / u01/app/oracle/oradata/kill/users01.dbf

Channel ORA_DISK_1: restoring datafile 00005 to / u01/app/oracle/oradata/kill/example01.dbf

Channel ORA_DISK_1: reading from backup piece / u01/app/oracle/flash_recovery_area/ORCL/backupset/2017_12_25/o1_mf_nnndf_TAG20171225T125632_f4118147_.bkp

Channel ORA_DISK_1: piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2017_12_25/o1_mf_nnndf_TAG20171225T125632_f4118147_.bkp tag=TAG20171225T125632

Channel ORA_DISK_1: restored backup piece 1

Channel ORA_DISK_1: restore complete, elapsed time: 00:01:45

Finished restore at 2017-12-25 17:14:05

Datafile 1 switched to datafile copy

Input datafile copy RECID=7 STAMP=963681246 file name=/u01/app/oracle/oradata/kill/system01.dbf

Datafile 2 switched to datafile copy

Input datafile copy RECID=8 STAMP=963681246 file name=/u01/app/oracle/oradata/kill/undotbs01.dbf

Datafile 3 switched to datafile copy

Input datafile copy RECID=9 STAMP=963681246 file name=/u01/app/oracle/oradata/kill/sysaux01.dbf

Datafile 4 switched to datafile copy

Input datafile copy RECID=10 STAMP=963681247 file name=/u01/app/oracle/oradata/kill/users01.dbf

Datafile 5 switched to datafile copy

Input datafile copy RECID=11 STAMP=963681247 file name=/u01/app/oracle/oradata/kill/example01.dbf

Starting recover at 2017-12-25 17:14:07

Using channel ORA_DISK_1

Starting media recovery

Unable to find archived log

Archived log thread=1 sequence=138

RMAN-00571: =

RMAN-00569: = ERROR MESSAGE STACK FOLLOWS =

RMAN-00571: =

RMAN-03002: failure of recover command at 12/25/2017 17:14:08

RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 138 and starting SCN of 5021427

RMAN >

Here we will find that in recover, since there are no archived logs, the prompt can only be restored to SCN 5021427

RMAN > run {

Set until scn 5456222

Restore database

Switch datafile all

Recover database

}

Executing command: SET until clause

Starting restore at 2017-12-25 18:29:57

Using channel ORA_DISK_1

Skipping datafile 1; already restored to file / u01/app/oracle/oradata/kill/system01.dbf

Skipping datafile 2; already restored to file / u01/app/oracle/oradata/kill/sysaux01.dbf

Skipping datafile 3; already restored to file / u01/app/oracle/oradata/kill/undotbs01.dbf

Skipping datafile 4; already restored to file / u01/app/oracle/oradata/kill/users01.dbf

Skipping datafile 5; already restored to file / u01/app/oracle/oradata/kill/example01.dbf

Restore not done; all files read only, offline, or already restored

Finished restore at 2017-12-25 18:29:58

Starting recover at 2017-12-25 18:29:58

Using channel ORA_DISK_1

Starting media recovery

Media recovery complete, elapsed time: 00:00:00

Finished recover at 2017-12-25 18:29:58

RMAN >

Open the database in 8.Resetlogs mode:

RMAN > alter database open resetlogs

RMAN-00571: =

RMAN-00569: = ERROR MESSAGE STACK FOLLOWS =

RMAN-00571: =

RMAN-03002: failure of alter db command at 12/25/2017 18:31:24

ORA-00344: unable to re-create online log' / u01Accord oradata redo01.log'

ORA-27040: file create error, unable to create file

Linux-x86_64 Error: 2: No such file or directory

Additional information: 1

An error was reported because the database SID is kill at this time, which is caused by inconsistency.

-- check that there are three log groups in the source database, and you need to change the path:

SQL > select member from v$logfile

MEMBER

/ u01/app/oracle/oradata/DBdb/redo03.log

/ u01/app/oracle/oradata/DBdb/redo02.log

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

-- start the conversion:

Run {

Sql "alter database rename file''/ u01ActionActionoradata Universe DBDBdbredo01.log'/ u01qapplemoradata'/ sql" alter database rename file'/ u01ActionActionoradata "

Sql "alter database rename file'/ u01ActionAccord oradata" DBDBDB _ redo02.logical` to'/ u01qqapplyoradata'oradata''"

Sql "alter database rename file'/ u01ActionActionoradata Universe DBDBdbredo03.logicoradata'/ u01qapplemoradata'/ sql"

}

RMAN > run {

2 > sql "alter database rename file''/ u01qqapplash oracleandoradata'to'/ u01plaza redo01.log'/ u01qapplicable oradata''"

3 > sql "alter database rename file''/ u01qqapplash oracleandoradata'to'/ u01plaza redo02.log'/ u01qapplicaloradata'"

4 > sql "alter database rename file''/ u01qqapplash oracleandoradata'to'/ u01plaza" redo03.logax'/ u01qapplicaloradata'"

5 >}

Sql statement: alter database rename file''/ u01ActionActionoradata Universe DBDBdbredo01.log'to'/ u01qqapplemoradatanyoradatanyoradatanyoradata'

Sql statement: alter database rename file''/ u01ActionAccord oradata Universe DBDBdbredo02.logical` to'/ u01qqapplemoradatanyoradatanyoradata'

Sql statement: alter database rename file''/ u01ActionActionoradata Universe DBDBdbredo03.logicoradata'/ u01qqapplemoradatanyoradatanyoradata'

RMAN >

-- start the database in resetlogs mode again:

RMAN > alter database open resetlogs

RMAN-00571: =

RMAN-00569: = ERROR MESSAGE STACK FOLLOWS =

RMAN-00571: =

RMAN-03002: failure of alter db command at 12/25/2017 18:38:39

ORA-00392: log 1 of thread 1 is being cleared, operation not allowed

ORA-00312: online log 1 thread 1:'/ u01 Grease App Charley oracleUnix oradata Universe Killer redo 01.log'

RMAN >

Solution: manual clear and then Open resetlogs

RMAN > sql 'alter database clear logfile group 1'

Sql statement: alter database clear logfile group 1

RMAN >

RMAN > alter database open resetlogs

Database opened

RMAN >

9. Wrap-up work:

At this time, the database has been open, and the recovery seems to have been completed, but in fact, it is still very close. When we query the temporary tablespace data file, we will report the following error, which can be seen because we changed the instance name.

[oracle@testdb kill] $sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Mon Dec 25 18:42:09 2017

Copyright (c) 1982, 2013, Oracle. All rights reserved.

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.4.0-64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL > select status from v$instance

STATUS

-

OPEN

SQL >

SQL > select file_name from dba_temp_files

Select file_name from dba_temp_files

*

ERROR at line 1:

ORA-01157: cannot identify/lock data file 201-see DBWR trace file

ORA-01110: data file 201:'/ u01 * app *

SQL > show parameter name

NAME TYPE VALUE

-

Cell_offloadgroup_name string

Db_file_name_convert string

Db_name string DBdb

Db_unique_name string DBdb

Global_names boolean FALSE

Instance_name string kill

Lock_name_space string

Log_file_name_convert string

Processor_group_name string

Service_names string service1,service2,service3

-- resolve this error by doing the following:

SQL > shutdown immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL >

SQL > startup mount

ORACLE instance started.

Total System Global Area 835104768 bytes

Fixed Size 2257840 bytes

Variable Size 549456976 bytes

Database Buffers 281018368 bytes

Redo Buffers 2371584 bytes

Database mounted.

SQL >

SQL > alter database rename file'/ u01qqappActionorActionoradataPlacement DBdbUniqtemp01.dbf'to'/ u01LacleUniplicationoradataGrease oradataloradataUniplicationtemp01.dbf'

Database altered.

SQL > alter database open

Database altered.

SQL > select file_name from dba_temp_files

FILE_NAME

/ u01/app/oracle/oradata/kill/temp01.dbf

SQL >

B library alert_01.txt

B library alert_02.txt

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

Database

Wechat

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

12
Report