Create Standby Database using RMAN changing backuppiece location 使用备份集搭建adg
Create Standby Database using RMAN changing backuppiece location (文档 ID 753902.1)
In this Document
APPLIES TO:
Oracle Database - Enterprise Edition - Version 8.1.7.4 and later
Information in this document applies to any platform.
*** Checked for relevance on 27-NOV-2015 ***
GOAL
How to create a standby database in a different host using rman, when the backup pieces location on standby server cannot be the same than the location of the backup files on primary database server.
SOLUTION
The best way to create a physical standby database with RMAN is using the DUPLICATE DATABASE FOR STANDBY command, but for DUPLICATE is mandatory that you will copy the backup piece files to the Auxiliary host (standby) exactly in the same location. If this is not possible then DUPLICATE cannot be used.
As the DUPLICATE is not possible it's necessary to use RESTORE and RECOVER.
1.- Control file backup for standby from production database:
$ rman target sys/<password>@primaryDBrman> backup current controlfile for standby format '/tmp/%F';
2.- Backup the database that includes backup of data files, archive logs
$ rman target sys/<password>@primaryDBrman> backup database plus archivelog;
3.-Copy the standby controlfile backup and the database backup to the standby server
** FTP or CP the backup pieces.
** If the backups are on tape then restore the backuppiece files into a directory of standby server
4.- Make proper changes in the parameter files of both primary and standby database
Primary:
log_archive_dest_2 = 'SERVICE=STANDBY LGWR ASYNC NOAFFIRM'
Standby:
Copy the primary database parameter file and make necessary changes :
db_name = "PROD" -- Must match the production database.
instance_name = STANDBY -- Instance identifier
service_names = STANDBY -- Specifies the service names supported
standby_archive_dest = <DIRECTORY>
standby_file_management = auto
REMOTE_LOGIN_PASSWORDFILE = EXCLUSIVE
db_unique_name='standby' -- In 8i and 9i in-place of db_unique_name='standby' you need to use parameter: lock_name_space='standby'
** Create a password file for the standby database using orapwd command:
$ orapwd file=$ORACLE_HOME/dbs/orapwSTANDBY password=pwd entries=5
5.- Startup STANDBY instance, restore the standby controlfile and mount standby database
$ export ORACLE_SID=STANDBY $ rman target / RMAN> startup nomount RMAN> set set dbid=<your_dbid>; RMAN> restore standby controlfile from '/tmp/<standby controlfile_name>'In 8i and 9i use:
restore controlfile from '/tmp/<standby controlfile_name>'RMAN> sql 'alter database mount standby database';
5.- Catalog the backup pieces that were shipped to standby host
RMAN> catalog backuppiece '/u02/oradata/dr/<backup_piece_file_name>';
or
RMAN> catalog backuppiece start with '/u02/oradata7';
6.- Restore and Recover database
RMAN>restore database;
RMAN>recover database;
** If you want to change the data file location on standby server then you can use rman command:
SET NEWNAME FOR DATAFILE <file#> TO '<new_directory>/new_name';SET NEWNAME FOR DATAFILE <file#> TO '<new_directory>/new_name';ETCRESTORE DATABASE;SWITCH DATAFILE ALL;RECOVER DATABASE** The recovery will fail after applying last archive log available in the backups, you can ignore the errors and move to step 7
** No need to worry about the errors, you can safely ignore and move to step 7.
Oracle Error:
ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below
ORA-01152: file 1 was not restored from a sufficiently old backup
ORA-01110: data file 1: '/u01/oracle/product/ora10g/oradata/standby/data/sys01.dbf'
7.- Put standby database in recovery mode
$ export ORACLE_SID=STANDBY
$ sqlplus /nolog
SQL> connect sys/<password> as sysdbaSQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;
浙公网安备 33010602011771号