Using rman to create standby is quite simple and the master database does not need to be stopped. This experiment demonstrates the process of using Rman for Hot Backup and then restore to create the standby database.
1. Demo Environment
[Oracle @ gaojf orcl] $ sqlplus "/as sysdba"
SQL * Plus: Release 10.2.0.1.0-Production on Wed Dec 6 08:54:45 2006
Copyright (c) 1982,200 5, Oracle. All rights reserved.
Connected:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0-Production
With the Partitioning, OLAP and Data Mining options
SQL> select * from v $ version;
BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0-Prod
PL/SQL Release 10.2.0.1.0-Production
CORE 10.2.0.1.0 Production
TNS for Linux: Version 10.2.0.1.0-Production
NLSRTL Version 10.2.0.1.0-Production
SQL>
2. confirm that the master database is in archive Mode
SQL> archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination/free/oracle/orabak
Oldest online log sequence 275
Next log sequence to archive 277
Current log sequence 277
SQL>
3: Create a slave database instance
On windows, use oradim to create a new instance. On unix/linux, set the new ORACLE_SID. on linux, set ORACLE_SID.
4: Prepare the parameter file of the slave database.
In this experiment, the master and slave databases are created on both systems. In addition, if both the master and slave databases are located together, db_name is set as the master database name, lock_name_space is set as the slave database name, And the db_file_convert and LOG_FILE_NAME_CONVERT Parameters.
The main parameters of the standby database are as follows:
*. Log_archive_config = 'dg _ CONFIG = (PRIMARY, STANDBY )'
*. LOG_ARCHIVE_DEST_1 = 'location =/free/oracle/orabak VALID_FOR = (ALL_LOGFILES, ALL_ROLES) DB_UNIQUE_NAME = standby'
*. LOG_ARCHIVE_DEST_2 = 'service = primary VALID_FOR = (ONLINE_LOGFILES, PRIMARY_ROLE) DB_UNIQUE_NAME = primary lgwr sync affir'
*. Db_unique_name = 'standby'
*. FAL_CLIENT = 'standby'
*. FAL_SERVER = 'primary'
*. Log_archive_dest_state_1 = 'enable'
*. Log_archive_dest_state_2 = 'enable'
*. STANDBY_ARCHIVE_DEST = '/free/oracle/orabak'
*. STANDBY_FILE_MANAGEMENT = 'auto'
The main parameters of the master database are as follows:
*. Log_archive_config = 'dg _ CONFIG = (PRIMAYR, STANDBY )'
*. DB_UNIQUE_NAME = 'primary'
*. LOG_ARCHIVE_DEST_1 = 'location =/free/oracle/orabak'
# *. LOG_ARCHIVE_DEST_2 = 'service = STANDBYVALID_FOR = (ONLINE_LOGFILES, PRIMARY_ROLE) DB_UNIQUE_NAME = standby lgwr sync affm' # LGWR Mode
*. LOG_ARCHIVE_DEST_2 = 'service = STANDBY DB_UNIQUE_NAME = standby arch sync reopen = 10' # arch Method
*. LOG_ARCHIVE_DEST_STATE_1 = ENABLE
*. LOG_ARCHIVE_DEST_STATE_2 = ENABLE
*. LOG_ARCHIVE_FORMAT = 'arc % s % t % r. arc'
*. FAL_SERVER = 'standby'
*. FAL_CLIENT = 'primary'
*. STANDBY_FILE_MANAGEMENT = 'auto'
*. Standby_archive_dest = '/free/oracle/orabak'
5. Generate password file in the slave Database
[Oracle @ gaojfdbs] $ Orapwd file =/free/oracle/product/10.2.0/db_1/orapworcl. ora password = orcl entries = 5
Alternatively, you can directly copy the password file of the master database to the corresponding location of the slave database.
6. Configure the network
Configure listener. ora and tnsnames. ora of the master and slave databases. After you modify lisner. ora, restart the listener.
Main Library Listener. ora
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME =/free/oracle/product/10.2.0/db_1)
(PROGRAM = extproc)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC) (KEY = EXTPROC1 ))
(ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.60.144) (PORT = 1521 ))
)
)
Standby library Listener. ora
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME =/free/oracle/product/10.2.0/db_1)
(PROGRAM = extproc)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC) (KEY = EXTPROC1 ))
(ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.60.253) (PORT = 1521 ))
)
)
Tnsnames. ora (same as the Master/Slave database configuration)
PRIMARY =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.60.144) (PORT = 1521 ))
)
(CONNECT_DATA =
(SERVICE_NAME = primary)
)
)
STANDBY =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.60.253) (PORT = 1521 ))
)
(CONNECT_DATA =
(SERVICE_NAME = standby)
)
)
7. Use rman to back up the master database
C:/> rman target/
Recovery Manager: Release 9.2.0.1.0-Production
Copyright (c) 1995,200 2, Oracle Corporation. All rights reserved.
Connected to target database: NING (DBID = 1192138470)
RMAN> backup database
2> format '/free/oracle/full _ % d _ % T _ % s ';
Starting backup at 06-DEC-06
Using channel ORA_DISK_1
Channel ORA_DISK_1: starting full datafile backupset
Channel ORA_DISK_1: specifying datafile (s) in backupset
Input datafile fno = 00001 name =/free/oracle/oradata/orcl/system01.dbf
Input datafile fno = 00003 name =/free/oracle/oradata/orcl/sysaux01.dbf
Input datafile fno = 00006 name =/free/oracle/oradata/orcl/gaojf1db. dbf
Input datafile fno = 00007 name =/free/oracle/oradata/orcl/gaojf2db. dbf
Input datafile fno = 00008 name =/free/oracle/oradata/orcl/gaojf3db. dbf
Input datafile fno = 00010 name =/free/oracle/oradata/orcl/cicrodb1.dbf
Input datafile fno = 00011 name =/free/oracle/oradata/orcl/cicrodb11.dbf
Input datafile fno = 00009 name =/free/oracle/oradata/orcl/gaojf4db. dbf
Input datafile fno = 00002 name =/free/oracle/oradata/orcl/undotbs01.dbf
Input datafile fno = 00005 name =/free/oracle/oradata/orcl/gaojfdb. dbf
Input datafile fno = 00004 name =/free/oracle/oradata/orcl/users01.dbf
Channel ORA_DISK_1: starting piece 1 at 06-DEC-06
Channel ORA_DISK_1: finished piece 1 at 06-DEC-06
Piece handle =/free/oracle/full_ORCL_20061206_37 tag = TAG20061206T101027 comment = NONE
Channel ORA_DISK_1: backup set complete, elapsed time: 00:03:15
Finished backup at 06-DEC-06
8. Generate the slave Database Control File
SQL>
Alter database create standby controlfile as '/free/oracle/oradata/orcl/standby. ctl ';
9: Copy all rman backups to the slave Database
Use the command scp of the operating system or ftp bin to copy all rman backups to the slave database.
Since I set the backup file location to/free/oracle during the backup of the rman master database, the backup file must also be placed in the same location of the backup database.
At the same time, the scp Control File standby. ctl is directed to the corresponding location of the slave database.
10. Start the slave database to the nomount status.
SQL> conn/as sysdba
Connected to an idle instance.
SQL> startup nomount
ORACLE instance started.
Total System Global Area 135338868 bytes
Fixed Size 453492 bytes
Variable Size 109051904 bytes
Database Buffers 25165824 bytes
Redo Buffers 667648 bytes
11. Change the standby database to the mount status.
SQL> alter database mount standby database;
Database altered.
If no password file exists, an error is returned:
ORA-01990: error opening password file '/free/oracle/product/10.2.0/db_1/orapworcl. ora'
12. Restore the slave database using rman
Oracle @ linux: ~> Rman target/
Recovery Manager: Release 10.2.0.1.0-Production on Thursday December 7 06:39:56 2006
Copyright (c) 1982,200 5, Oracle. All rights reserved.
Connected to target database: ORCL (DBID = 1132959697, not open)
RMAN>
RMAN> restore database;
Starting backup at 06-DEC-06
Using channel ORA_DISK_1
Channel ORA_DISK_1: starting datafile backupset restore
Channel ORA_DISK_1: specifying datafile (s) to restore from backup set
Restoringdatafile fno = 00001 name =/free/oracle/oradata/orcl/system01.dbf
Restoringdatafile fno = 00003 name =/free/oracle/oradata/orcl/sysaux01.dbf
Restoring datafile fno = 00006 name =/free/oracle/oradata/orcl/gaojf1db. dbf
Restoring datafile fno = 00007 name =/free/oracle/oradata/orcl/gaojf2db. dbf
Restoring datafile fno = 00008 name =/free/oracle/oradata/orcl/gaojf3db. dbf
Restoring datafile fno = 00010 name =/free/oracle/oradata/orcl/cicrodb1.dbf
Restoringdatafile fno = 00011 name =/free/oracle/oradata/orcl/cicrodb11.dbf
Restoring datafile fno = 00009 name =/free/oracle/oradata/orcl/gaojf4db. dbf
Restoringdatafilefno = 00002 name =/free/oracle/oradata/orcl/undotbs01.dbf
Restoring datafile fno = 00005 name =/free/oracle/oradata/orcl/gaojfdb. dbf
Restoring datafile fno = 00004 name =/free/oracle/oradata/orcl/users01.dbf
Channel ORA_DISK_1: starting piece 1 at 06-DEC-06
Channel ORA_DISK_1: finished piece 1 at 06-DEC-06
Piecehandle =/free/oracle/full_ORCL_20061206_37tag = TAG20061206T101027 comment = NONE
Channel ORA_DISK_1: restore complete, elapsed time: 00:03:15
Finished restore at 06-DEC-06
13. Place the standby database in the Automatic Recovery status
SQL> alter database recover managed standby database disconnect from session;
Database altered.
14. Check the master database
SQL> conn/as sysdba
Connected.
SQL> select dest_name, status, error from v $ archive_dest;
DEST_NAME STATUS ERROR
------------------------------------------------
LOG_ARCHIVE_DEST_1 VALID
LOG_ARCHIVE_DEST_2 VALID
LOG_ARCHIVE_DEST_3 INACTIVE
LOG_ARCHIVE_DEST_4 INACTIVE
LOG_ARCHIVE_DEST_5 INACTIVE
LOG_ARCHIVE_DEST_6 INACTIVE
LOG_ARCHIVE_DEST_7 INACTIVE
LOG_ARCHIVE_DEST_8 INACTIVE
LOG_ARCHIVE_DEST_9 INACTIVE
LOG_ARCHIVE_DEST_10 INACTIVE
10 rows selected.
SQL> select * from v $ archive_gap;
No rows selected
SQL> select sequence # from v $ log_history;
SEQUENCE #
----------
1
2
...
303
15. Check the slave Database
SQL> conn/as sysdba
Connected.
SQL> select * from v $ archive_gap;
No rows selected
SQL> select sequence # from v $ log_history;
SEQUENCE #
----------
1
2
...
303
SQL> select sequence #, applied from v $ archived_log;
SEQUENCE # APPLIE
----------------
295 YES
296 YES
297 YES
298 YES
299 YES
300 YES
301 YES
302 YES
303 YES
SQL> select process, status from v $ managed_standby;
PROCESS STATUS
------------------------------------------
ARCH CLOSING
ARCH CLOSING
RFS IDLE
MRP0 WAIT_FOR_LOG
This article is from the "Technical Achievement dream" blog