回到主备上面。
在前面我们修改了两个参数(db/log_file_name_convertt)到spfile文件中,还没有重启数据库,这里我们重启一下主数据库
3.1
- [Oracle@11g admin]$ sqlplus / as sysdba
- SQL*Plus: Release 11.2.0.2.0 Production on Fri Sep 7 05:50:13 2012
- Copyright (c) 1982, 2010, Oracle. All rights reserved.
- Connected to:
- Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
- With the Partitioning, OLAP, Data Mining and Real Application Testing options
- SQL> shutdown immediate;
- Database closed.
- Database dismounted.
- ORACLE instance shut down.
- SQL> startup
- ORACLE instance started.
- Total System Global Area 313159680 bytes
- Fixed Size 2226072 bytes
- Variable Size 247466088 bytes
- Database Buffers 58720256 bytes
- Redo Buffers 4747264 bytes
- Database mounted.
- Database opened.
- SQL> exit
- Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
- With the Partitioning, OLAP, Data Mining and Real Application Testing options
3.2 duplicate开始
- [oracle@11g admin]$ rman target sys/oracle@htz auxiliary sys/oracle@htzb
- Recovery Manager: Release 11.2.0.2.0 - Production on Fri Sep 7 05:50:46 2012
- Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
- connected to target database: HTZ (DBID=1848107928)
- connected to auxiliary database: HTZ (not mounted)
- RMAN> run {
- 2> allocate channel prmy1 type disk;
- 3> allocate channel prmy2 type disk;
- 4> allocate channel prmy3 type disk;
- 5> allocate channel prmy4 type disk;
- 6> allocate auxiliary channel stby type disk;
- 7> duplicate target database for standby from active database nofilenamecheck
- 8> ;
- 9> }
- using target database control file instead of recovery catalog
- allocated channel: prmy1
- channel prmy1: SID=36 device type=DISK
- allocated channel: prmy2
- channel prmy2: SID=37 device type=DISK
- allocated channel: prmy3
- channel prmy3: SID=38 device type=DISK
- allocated channel: prmy4
- channel prmy4: SID=39 device type=DISK
- allocated channel: stby
- channel stby: SID=21 device type=DISK
- Starting Duplicate Db at 07-SEP-12
- contents of Memory Script:
- {
- backup as copy reuse
- targetfile '/u01/app/oracle/product/11.2.0/db_1/dbs/orapwhtz' auxiliary format
- '/u01/app/oracle/product/11.2.0/db_1/dbs/orapwhtz' ;
- }
- executing Memory Script
- Starting backup at 07-SEP-12
- Finished backup at 07-SEP-12
- contents of Memory Script:
- {
- backup as copy current controlfile for standby auxiliary format '/u01/app/oracle/oradata/htz/control01.ctl';
- restore clone controlfile to '/u01/app/oracle/oradata/htz/control02.ctl' from
- '/u01/app/oracle/oradata/htz/control01.ctl';
- }
- executing Memory Script
- Starting backup at 07-SEP-12
- channel prmy1: starting datafile copy
- copying standby control file
- output file name=/u01/app/oracle/product/11.2.0/db_1/dbs/snapcf_htz.f tag=TAG20120907T055127 RECID=1 STAMP=793345887
- channel prmy1: datafile copy complete, elapsed time: 00:00:01
- Finished backup at 07-SEP-12
- Starting restore at 07-SEP-12
- channel stby: copied control file copy
- Finished restore at 07-SEP-12
- 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/htz/temp01.dbf";
- switch clone tempfile all;
- set newname for datafile 1 to
- "/u01/app/oracle/oradata/htz/system01.dbf";
- set newname for datafile 2 to
- "/u01/app/oracle/oradata/htz/sysaux01.dbf";
- set newname for datafile 3 to
- "/u01/app/oracle/oradata/htz/undotbs01.dbf";
- set newname for datafile 4 to
- "/u01/app/oracle/oradata/htz/users01.dbf";
- backup as copy reuse
- datafile 1 auxiliary format
- "/u01/app/oracle/oradata/htz/system01.dbf" datafile
- 2 auxiliary format
- "/u01/app/oracle/oradata/htz/sysaux01.dbf" datafile
- 3 auxiliary format
- "/u01/app/oracle/oradata/htz/undotbs01.dbf" datafile
- 4 auxiliary format
- "/u01/app/oracle/oradata/htz/users01.dbf" ;
- sql 'alter system archive log current';
- }
- executing Memory Script
- executing command: SET NEWNAME
- renamed tempfile 1 to /u01/app/oracle/oradata/htz/temp01.dbf in control file
- executing command: SET NEWNAME
- executing command: SET NEWNAME
- executing command: SET NEWNAME
- executing command: SET NEWNAME
- Starting backup at 07-SEP-12
- channel prmy1: starting datafile copy
- input datafile file number=00001 name=/u01/app/oracle/oradata/htz/system01.dbf
- channel prmy2: starting datafile copy
- input datafile file number=00002 name=/u01/app/oracle/oradata/htz/sysaux01.dbf
- channel prmy3: starting datafile copy
- input datafile file number=00003 name=/u01/app/oracle/oradata/htz/undotbs01.dbf
- channel prmy4: starting datafile copy
- input datafile file number=00004 name=/u01/app/oracle/oradata/htz/users01.dbf
- output file name=/u01/app/oracle/oradata/htz/undotbs01.dbf tag=TAG20120907T055135
- channel prmy3: datafile copy complete, elapsed time: 00:00:08
- output file name=/u01/app/oracle/oradata/htz/users01.dbf tag=TAG20120907T055135
- channel prmy4: datafile copy complete, elapsed time: 00:00:08
- output file name=/u01/app/oracle/oradata/htz/sysaux01.dbf tag=TAG20120907T055135
- channel prmy2: datafile copy complete, elapsed time: 00:00:56
- output file name=/u01/app/oracle/oradata/htz/system01.dbf tag=TAG20120907T055135
- channel prmy1: datafile copy complete, elapsed time: 00:01:06
- Finished backup at 07-SEP-12
- sql statement: alter system archive log current
- contents of Memory Script:
- {
- switch clone datafile all;
- }
- executing Memory Script
- datafile 1 switched to datafile copy
- input datafile copy RECID=1 STAMP=793304890 file name=/u01/app/oracle/oradata/htz/system01.dbf
- datafile 2 switched to datafile copy
- input datafile copy RECID=2 STAMP=793304890 file name=/u01/app/oracle/oradata/htz/sysaux01.dbf
- datafile 3 switched to datafile copy
- input datafile copy RECID=3 STAMP=793304890 file name=/u01/app/oracle/oradata/htz/undotbs01.dbf
- datafile 4 switched to datafile copy
- input datafile copy RECID=4 STAMP=793304890 file name=/u01/app/oracle/oradata/htz/users01.dbf
- Finished Duplicate Db at 07-SEP-12
- released channel: prmy1
- released channel: prmy2
- released channel: prmy3
- released channel: prmy4
- released channel: stby
- RMAN> exit
- Recovery Manager complete.
下面把备库启动到open only下面。并recover。
- SQL> alter database open read only;
- Database altered.
- SQL> alter database recover managed standby database using current logfile disconnect from session;
- Database altered.
- 在alert日志中可以看到下面的内容:
- Waiting for all non-current ORLs to be archived...
- All non-current ORLs have been archived.
- Media Recovery Log /u01/app/oracle/arch/htz/1_6_793343515.dbf
- Media Recovery Log /u01/app/oracle/arch/htz/1_7_793343515.dbf
- Media Recovery Log /u01/app/oracle/arch/htz/1_8_793343515.dbf
- Media Recovery Log /u01/app/oracle/arch/htz/1_9_793343515.dbf
- Completed: ALTER DATABASE RECOVER managed standby database using current logfile disconnect
- Media Recovery Waiting for thread 1 sequence 10 (in transit)
- Recovery of Online Redo Log: Thread 1 Group 4 Seq 10 Reading mem 0
- Mem# 0: /u01/app/oracle/oradata/htz/standby01.log
下面就是开始测试了。这里我们是用的SCOTT这个用户来做测试,在SCOTT用户下面创建一个表,在备库去查询看是否创建成功,与在主库上面SWIRCH一次日志,看alert中的日志输出内容。
- 在主库上面做测试
- [oracle@11g admin]$ sqlplus / as sysdba
- SQL*Plus: Release 11.2.0.2.0 Production on Fri Sep 7 05:57:41 2012
- Copyright (c) 1982, 2010, Oracle. All rights reserved.
- Connected to:
- Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
- With the Partitioning, OLAP, Data Mining and Real Application Testing options
- SQL> alter database set standby to maximize availability;
- Database altered.
- SQL> conn scott/tiger;
- ERROR:
- ORA-28000: the account is locked
- Warning: You are no longer connected to ORACLE.
- SQL> conn / as sysdba
- Connected.
- SQL> alter user scott identified by oracle;
- User altered.
- SQL> alter user scott account unlock;
- User altered.
- SQL> create table scott.test1 as select * from dba_objects;
- Table created.
- 备库上面
- SQL> select count(*) from scott.test1;
- COUNT(*)
- ----------
- 72391
- 说明已经同步
- 主库上面刷新日志。
- SQL> conn / as sysdba
- Connected.
- SQL> alter system archive log current;
- System altered.
- 日志
- ALTER SYSTEM ARCHIVE LOG
- Fri Sep 07 06:04:45 2012
- LGWR: Standby redo logfile selected to archive thread 1 sequence 11
- LGWR: Standby redo logfile selected for thread 1 sequence 11 for destination LOG_ARCHIVE_DEST_2
- Thread 1 advanced to log sequence 11 (LGWR switch)
- Current log# 2 seq# 11 mem# 0: /u01/app/oracle/oradata/htz/redo02.log
- Fri Sep 07 06:04:48 2012
- Archived Log entry 12 added for thread 1 sequence 10 ID 0x6e285e98 dest 1:
- 备库日志
- Standby controlfile consistent with primary
- RFS[5]: Selected log 5 for thread 1 sequence 11 dbid 1848107928 branch 793343515
- Thu Sep 06 18:40:13 2012
- Media Recovery Waiting for thread 1 sequence 11 (in transit)
- Recovery of Online Redo Log: Thread 1 Group 5 Seq 11 Reading mem 0
- Mem# 0: /u01/app/oracle/oradata/htz/standby02.log
- Thu Sep 06 18:40:16 2012
- Archived Log entry 5 added for thread 1 sequence 10 ID 0x6e285e98 dest 1:
- System altered.
