重庆思庄Oracle、Redhat认证学习论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 3074|回复: 1
打印 上一主题 下一主题

[认证考试] 使用dgmgrl手工进行dg switchover

[复制链接]
跳转到指定楼层
楼主
发表于 2019-3-26 19:57:48 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
1.当前情况:
prod1 主库
sbdb1 备库

DGMGRL> show configuration;
Configuration - cfgocm1
  Protection Mode: MaxPerformance
  Databases:
    prod1 - Primary database
    sbdb1 - Physical standby database
Fast-Start Failover: DISABLED
Configuration Status:
SUCCESS

2.直接使用 switchover进行切换到备库

DGMGRL>  SWITCHOVER TO sbdb1;
Performing switchover NOW, please wait...
New primary database "sbdb1" is opening...
Operation requires shutdown of instance "prod1" on database "prod1"
Shutting down instance "prod1"...
ORACLE instance shut down.
Operation requires startup of instance "prod1" on database "prod1"
Starting instance "prod1"...
ORACLE instance started.
Database mounted.
Database opened.
Switchover succeeded, new primary is "sbdb1"

--如果我们这个时候去看报警日志文件,就会发现以前在sqlplus 中执行的 Completed: ALTER DATABASE COMMIT TO SWITCHOVER TO PHYSICAL STANDBY WITH SESSION SHUTDOWN,会自动执行。

3.确认已经主库已经切换为备库,备库已经切换为主库:


DGMGRL> show configuration;
Configuration - cfgocm1
  Protection Mode: MaxPerformance
  Databases:
    sbdb1 - Primary database
    prod1 - Physical standby database
Fast-Start Failover: DISABLED
Configuration Status:
SUCCESS


4.再次回切,把 prod1切换为主库:

DGMGRL> SWITCHOVER TO prod1
Performing switchover NOW, please wait...
New primary database "prod1" is opening...
Operation requires shutdown of instance "sbdb1" on database "sbdb1"
Shutting down instance "sbdb1"...
ORACLE instance shut down.
Operation requires startup of instance "sbdb1" on database "sbdb1"
Starting instance "sbdb1"...
ORACLE instance started.
Database mounted.
Database opened.
Switchover succeeded, new primary is "prod1"


5.再次确认:

DGMGRL> show configuration;
Configuration - cfgocm1
  Protection Mode: MaxPerformance
  Databases:
    prod1 - Primary database
    sbdb1 - Physical standby database
Fast-Start Failover: DISABLED
Configuration Status:

是不是又回来了

这个操作和手工使用sql命令进行切换是不是要简单很多,而且至始至终都在一台机器上操作,不需要来回在多台机器上操作。



下面附相关配置文件及监听信息:
1.备库:
[oracle@ocm2 admin]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 26-MAR-2019 19:39:22
Copyright (c) 1991, 2011, Oracle.  All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=ocm2.sztech.com)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date                26-MAR-2019 16:47:53
Uptime                    0 days 2 hr. 51 min. 28 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/ocm2/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ocm2.sztech.com)(PORT=1521)))
Services Summary...

Service "sbdb1.example.com" has 2 instance(s).
  Instance "sbdb1", status UNKNOWN, has 1 handler(s) for this service...
  Instance "sbdb1", status READY, has 1 handler(s) for this service...
Service "sbdb1_DGB.example.com" has 1 instance(s).
  Instance "sbdb1", status READY, has 1 handler(s) for this service...
Service "sbdb1_DGMGRL.example.com" has 1 instance(s).
  Instance "sbdb1", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully

[oracle@ocm2 admin]$ cat listener.ora
# listener3996222964392981269.ora Network Configuration File: /tmp/listener3996222964392981269.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = sbdb1.example.com)
      (ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)
      (SID_NAME = sbdb1)
    )
    (SID_DESC =
      (GLOBAL_DBNAME = sbdb1_DGMGRL.example.com)     --这部分要手工加的
      (ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)
      (SID_NAME = sbdb1)
    )
  )
LISTENER =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = ocm2.sztech.com)(PORT = 1521))
  )
ADR_BASE_LISTENER = /u01/app/oracle
[oracle@ocm2 admin]$
[oracle@ocm2 admin]$
[oracle@ocm2 admin]$ cat tnsnames.ora
# tnsnames4598767396086864223.ora Network Configuration File: /tmp/tnsnames4598767396086864223.ora
# Generated by Oracle configuration tools.
SBDB1 =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = ocm2.sztech.com)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = sbdb1.example.com)
    )
  )
PROD1 =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = ocm1.sztech.com)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = prod1.example.com)
    )
  )
SBDB1_DGMGRL =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = ocm2.sztech.com)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = sbdb1_DGMGRL)
    )
  )


2.主库prod1:

[oracle@ocm1 ~]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 26-MAR-2019 19:46:22
Copyright (c) 1991, 2011, Oracle.  All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=ocm1.sztech.com)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date                26-MAR-2019 11:49:01
Uptime                    0 days 7 hr. 57 min. 20 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/ocm1/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ocm1.sztech.com)(PORT=1521)))
Services Summary...
Service "prod1.example.com" has 2 instance(s).
  Instance "prod1", status UNKNOWN, has 1 handler(s) for this service...
  Instance "prod1", status READY, has 1 handler(s) for this service...
Service "prod1XDB.example.com" has 1 instance(s).
  Instance "prod1", status READY, has 1 handler(s) for this service...
Service "prod1_DGB.example.com" has 1 instance(s).
  Instance "prod1", status READY, has 1 handler(s) for this service...
Service "prod1_DGMGRL.example.com" has 1 instance(s).
  Instance "prod1", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
[oracle@ocm1 ~]$

[oracle@ocm1 admin]$ cat listener.ora
# listener7430401327825906778.ora Network Configuration File: /tmp/listener7430401327825906778.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = prod1.example.com)
      (ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
      (SID_NAME = prod1)
    )
    (SID_DESC =
      (GLOBAL_DBNAME = prod1_DGMGRL.example.com)
      (ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
      (SID_NAME = prod1)
    )
  )
LISTENER =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = ocm1.sztech.com)(PORT = 1521))
  )
ADR_BASE_LISTENER = /u01/app/oracle
[oracle@ocm1 admin]$
[oracle@ocm1 admin]$ cat tnsnames.ora
# tnsnames6882316049089510493.ora Network Configuration File: /tmp/tnsnames6882316049089510493.ora
# Generated by Oracle configuration tools.
SBDB1 =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = ocm2.sztech.com)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = sbdb1.example.com)
    )
  )
PROD1 =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = ocm1.sztech.com)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = prod1.example.com)
    )
  )







分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 支持支持 反对反对
回复

使用道具 举报

沙发
 楼主| 发表于 2019-3-26 19:59:47 | 只看该作者
是不是很  easy,不需要 em grid control 哈。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|手机版|小黑屋|重庆思庄Oracle、Redhat认证学习论坛 ( 渝ICP备12004239号-4 )

GMT+8, 2024-11-27 07:29 , Processed in 0.081787 second(s), 19 queries .

重庆思庄学习中心论坛-重庆思庄科技有限公司论坛

© 2001-2020

快速回复 返回顶部 返回列表