ITPub博客

首页 > 数据库 > Oracle > dataguard之物理standby 日志切换

dataguard之物理standby 日志切换

原创 Oracle 作者:sxitsxit 时间:2014-03-10 17:42:08 0 删除 编辑
物理standby 日常管理

对于最大性能模式(max performance)下,primary、standby库的启动顺序无先后

1:dataguard启动顺序:先standby,后primary
2:dataguard关闭顺序:先primary,后 standby


在standby库上将实例启动到mount状态

[oracle@rac2 admin]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Mon Mar 10 17:09:27 2014

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

Connected to an idle instance.

SQL> startup nomount;
ORACLE instance started.

Total System Global Area  218103808 bytes
Fixed Size            1218604 bytes
Variable Size           71305172 bytes
Database Buffers      142606336 bytes
Redo Buffers            2973696 bytes
SQL>
SQL> alter database mount standby database;

Database altered.

SQL> alter database recover managed standby database disconnect from session;//启动redo apply

Database altered.


启动standby库的监听

SQL> !lsnrctl start

LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 10-MAR-2014 17:12:55

Copyright (c) 1991, 2005, Oracle.  All rights reserved.

Starting /home/oracle/10.2.0/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 10.2.0.1.0 - Production
System parameter file is /home/oracle/10.2.0/network/admin/listener.ora
Log messages written to /home/oracle/10.2.0/network/log/listener.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=rac2)(PORT=1521)))

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date                10-MAR-2014 17:12:56
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /home/oracle/10.2.0/network/admin/listener.ora
Listener Log File         /home/oracle/10.2.0/network/log/listener.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=rac2)(PORT=1521)))
The listener supports no services
The command completed successfully

SQL>
SQL> select open_mode from v$database;

OPEN_MODE
--------------------
READ WRITE

SQL>


在primary库上启动实例

[oracle@rac1 admin]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Mon Mar 10 17:15:18 2014

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

Connected to an idle instance.

SQL> startup;
ORACLE instance started.

Total System Global Area  218103808 bytes
Fixed Size            1218604 bytes
Variable Size           75499476 bytes
Database Buffers      138412032 bytes
Redo Buffers            2973696 bytes
Database mounted.
Database opened.
SQL>

SQL> select open_mode from v$database;

OPEN_MODE
--------------------
MOUNTED


在primary 库上启动监听

[oracle@rac1 admin]$ lsnrctl start

LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 10-MAR-2014 17:14:58

Copyright (c) 1991, 2005, Oracle.  All rights reserved.

Starting /home/oracle/10.2.0/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 10.2.0.1.0 - Production
System parameter file is /home/oracle/10.2.0/network/admin/listener.ora
Log messages written to /home/oracle/10.2.0/network/log/listener.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=rac1)(PORT=1521)))

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date                10-MAR-2014 17:14:58
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /home/oracle/10.2.0/network/admin/listener.ora
Listener Log File         /home/oracle/10.2.0/network/log/listener.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=rac1)(PORT=1521)))
The listener supports no services
The command completed successfully



验证primary库上的归档日志是否正常传输到standby库

在primary库上执行

oracle@rac1 archivelog]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Mon Mar 10 17:25:55 2014

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


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

SQL> SELECT SEQUENCE#, FIRST_TIME, NEXT_TIME FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;

 SEQUENCE# FIRST_TIME    NEXT_TIME
---------- ------------ ------------
     2 05-MAR-14    05-MAR-14
     2 05-MAR-14    05-MAR-14
     3 05-MAR-14    05-MAR-14
     3 05-MAR-14    05-MAR-14
     4 05-MAR-14    05-MAR-14
     4 05-MAR-14    05-MAR-14
     5 05-MAR-14    06-MAR-14
     5 05-MAR-14    06-MAR-14
     6 06-MAR-14    06-MAR-14
     6 06-MAR-14    06-MAR-14
     7 06-MAR-14    06-MAR-14

 SEQUENCE# FIRST_TIME    NEXT_TIME
---------- ------------ ------------
     7 06-MAR-14    06-MAR-14
     8 06-MAR-14    06-MAR-14
     8 06-MAR-14    06-MAR-14
     9 06-MAR-14    06-MAR-14
     9 06-MAR-14    06-MAR-14
    10 06-MAR-14    06-MAR-14
    10 06-MAR-14    06-MAR-14
    11 06-MAR-14    06-MAR-14
    11 06-MAR-14    06-MAR-14
    12 06-MAR-14    06-MAR-14
    12 06-MAR-14    06-MAR-14

 SEQUENCE# FIRST_TIME    NEXT_TIME
---------- ------------ ------------
    13 06-MAR-14    06-MAR-14
    13 06-MAR-14    06-MAR-14
    14 06-MAR-14    06-MAR-14
    14 06-MAR-14    06-MAR-14
    15 06-MAR-14    06-MAR-14
    15 06-MAR-14    06-MAR-14
    16 06-MAR-14    06-MAR-14
    16 06-MAR-14    06-MAR-14
    17 06-MAR-14    06-MAR-14
    17 06-MAR-14    06-MAR-14
    18 06-MAR-14    06-MAR-14

 SEQUENCE# FIRST_TIME    NEXT_TIME
---------- ------------ ------------
    18 06-MAR-14    06-MAR-14
    19 06-MAR-14    06-MAR-14
    19 06-MAR-14    06-MAR-14
    20 06-MAR-14    06-MAR-14
    20 06-MAR-14    06-MAR-14
    21 06-MAR-14    10-MAR-14
    21 06-MAR-14    10-MAR-14
    22 10-MAR-14    10-MAR-14
    22 10-MAR-14    10-MAR-14
    23 10-MAR-14    10-MAR-14
    23 10-MAR-14    10-MAR-14

 SEQUENCE# FIRST_TIME    NEXT_TIME
---------- ------------ ------------
    24 10-MAR-14    10-MAR-14
    24 10-MAR-14    10-MAR-14
    25 10-MAR-14    10-MAR-14
    25 10-MAR-14    10-MAR-14

48 rows selected.

SQL>

然后在primary库上切换日志

SQL> alter system switch logfile;

System altered.

SQL> /

System altered.

SQL>



在standby库上执行如下


SQL>  SELECT SEQUENCE#, FIRST_TIME, NEXT_TIME FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;

 SEQUENCE# FIRST_TIME    NEXT_TIME
---------- ------------ ------------
     2 05-MAR-14    05-MAR-14
     3 05-MAR-14    05-MAR-14
     4 05-MAR-14    05-MAR-14
     5 05-MAR-14    06-MAR-14
     6 06-MAR-14    06-MAR-14
     7 06-MAR-14    06-MAR-14
     8 06-MAR-14    06-MAR-14
     9 06-MAR-14    06-MAR-14
    10 06-MAR-14    06-MAR-14
    11 06-MAR-14    06-MAR-14
    12 06-MAR-14    06-MAR-14

 SEQUENCE# FIRST_TIME    NEXT_TIME
---------- ------------ ------------
    13 06-MAR-14    06-MAR-14
    14 06-MAR-14    06-MAR-14
    15 06-MAR-14    06-MAR-14
    16 06-MAR-14    06-MAR-14
    17 06-MAR-14    06-MAR-14
    18 06-MAR-14    06-MAR-14
    19 06-MAR-14    06-MAR-14
    20 06-MAR-14    06-MAR-14
    21 06-MAR-14    10-MAR-14
    22 10-MAR-14    10-MAR-14
    23 10-MAR-14    10-MAR-14

 SEQUENCE# FIRST_TIME    NEXT_TIME
---------- ------------ ------------
    24 10-MAR-14    10-MAR-14
    25 10-MAR-14    10-MAR-14
    26 10-MAR-14    10-MAR-14
    27 10-MAR-14    10-MAR-14
    28 10-MAR-14    10-MAR-14

27 rows selected.

可以看到primary库上切换新的三组日志已经传到standby库上了
[oracle@rac2 archivelog]$ ls -l
total 924
-rw-r-----  1 oracle dba 918528 Mar 10 17:32 log1_26_841430327.arc
-rw-r-----  1 oracle dba   1024 Mar 10 17:32 log1_27_841430327.arc
-rw-r-----  1 oracle dba  14848 Mar 10 17:32 log1_28_841430327.arc
[oracle@rac2 archivelog]$ pwd
/home/oracle/archivelog
[oracle@rac2 archivelog]$

如果碰到归档日志无法传输到standby库的情况,首先检查alert.log

然后在 standby库上先取消 redo apply,然后重新启动redo apply

SQL>  alter database recover managed standby database cancel;

Database altered.

SQL>  alter database recover managed standby database disconnect from session;

Database altered.

SQL> select max(sequence#) from v$archived_log;

MAX(SEQUENCE#)
--------------
        29
        









来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/24862808/viewspace-1104834/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2011-04-14

  • 博文量
    98
  • 访问量
    301460