(3)
查看主库和备库的hosts文件,确定ip和主机名的解析:
主库:
[oracle@SZSCPDB szscpdb]$ cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
192.168.1.21 SZSCPDB
192.168.1.22 SZSCSTB
备库:
[oracle@SZSCSTB szscstb]$ cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
192.168.1.21 SZSCPDB
192.168.1.22 SZSCSTB
(4)
确定主库的监听是开启的
[oracle@SZSCPDB szscpdb]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 15-DEC-2013 15:30:42
Copyright (c) 1991, 2011, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=SZSCPDB)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date 15-DEC-2013 14:24:29
Uptime 0 days 1 hr. 6 min. 12 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/SZSCPDB/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=SZSCPDB)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "szscXDB" has 1 instance(s).
Instance "szsc", status READY, has 1 handler(s) for this service...
Service "szscpdb" has 2 instance(s).
Instance "szsc", status UNKNOWN, has 1 handler(s) for this service...
Instance "szsc", status READY, has 1 handler(s) for this service...
The command completed successfully
(5)
配置主库为归档模式:
SQL> archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /arch/szscpdb
Oldest online log sequence 3
Next log sequence to archive 5
Current log sequence 5
(6)
更改主库为force logging
SQL> alter database force logging;
Database altered.
LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 15-DEC-2013 07:42:41
Copyright (c) 1991, 2011, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=SZSCSTB)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date 15-DEC-2013 06:13:05
Uptime 0 days 1 hr. 29 min. 36 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/SZSCSTB/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=SZSCSTB)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "szscXDB" has 1 instance(s).
Instance "szsc", status READY, has 1 handler(s) for this service...
Service "szscstb" has 2 instance(s).
Instance "szsc", status UNKNOWN, has 1 handler(s) for this service...
Instance "szsc", status READY, has 1 handler(s) for this service...
The command completed successfully
(20)
主库应用备份文件到备库上,使用duplicate方式(在主库上执行)
RMAN> connect auxiliary sys/oracle@SZSCSTB
connected to auxiliary database: SZSCPDB (not mounted)
RMAN> duplicate target database for standby;
Starting Duplicate Db at 08-MAR-13
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=10 device type=DISK
contents of Memory Script.:
{
restore clone standby controlfile;
}
executing Memory Script
Starting restore at 08-MAR-13
using channel ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: reading from backup piece /BACKUP/0lo3vm4i_1_1
channel ORA_AUX_DISK_1: piece handle=/backup/0lo3vm4i_1_1 tag=TAG20130308T022752
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:02
output file name=/u01/app/oracle/oradata/szscstb/control01.ctl
output file name=/u01/app/oracle/oradata/szscstb/control02.ctl
Finished restore at 08-MAR-13
contents of Memory Script.:
{
sql clone 'alter database mount standby database';
}
executing Memory Script
sql statement: alter database mount standby database
contents of Memory Script.:
{
set newname for tempfile 1 to
"/u01/app/oracle/oradata/szscstb/temp01.dbf";
switch clone tempfile all;
set newname for datafile 1 to
"/u01/app/oracle/oradata/szscstb/system01.dbf";
set newname for datafile 2 to
"/u01/app/oracle/oradata/szscstb/sysaux01.dbf";
set newname for datafile 3 to
"/u01/app/oracle/oradata/szscstb/undotbs01.dbf";
set newname for datafile 4 to
"/u01/app/oracle/oradata/szscstb/users01.dbf";
restore
clone database
;
}
executing Memory Script
executing command: SET NEWNAME
renamed tempfile 1 to /u01/app/oracle/oradata/szscstb/temp01.dbf in control file
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting restore at 08-MAR-13
using channel ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00001 to //u01/app/oracle/oradata/szscstb/system01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00002 to /u01/app/oracle/oradata/szscstb/sysaux01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/szscstb/undotbs01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/szscstb/users01.dbf
channel ORA_AUX_DISK_1: reading from backup piece /backup/0ko3vm18_1_1
channel ORA_AUX_DISK_1: piece handle=/backup/0ko3vm18_1_1 tag=TAG20130308T022752
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:02:05
Finished restore at 08-MAR-13
contents of Memory Script.:
{
switch clone datafile all;
}
executing Memory Script
datafile 1 switched to datafile copy
input datafile copy RECID=2 STAMP=809491977 file name=/u01/app/oracle/oradata/szscstb/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=3 STAMP=809491977 file name=/u01/app/oracle/oradata/szscstb/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=4 STAMP=809491977 file name=/u01/app/oracle/oradata/szscstb/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=5 STAMP=809491977 file name=/u01/app/oracle/oradata/szscstb/users01.dbf
Finished Duplicate Db at 08-MAR-13
(21)
执行备库恢复模式。(在备库上执行)
SQL> select instance_name,status from v$instance;
INSTANCE_NAME STATUS
---------------- ------------
szsc MOUNTED
SQL> alter database recover managed standby database disconnect from session;
Database altered.