oracle 11g dataguard主备切换

简介:

1.检查主备的环境

dg1节点:

SQL> archive log list;

Database log mode            Archive Mode

Automatic archival            Enabled

Archive destination           /u01/oradata/tong/archive

Oldest online log sequence      59

Next log sequence to archive     61

Current log sequence           61

SQL> 


dg2节点:

SQL> archive log list;

Database log mode            Archive Mode

Automatic archival            Enabled

Archive destination           /u01/oradata/tong/archive

Oldest online log sequence      60

Next log sequence to archive     0

Current log sequence          61

SQL> 


2.查看主备的角色

dg1节点(primary角色):

SQL> select switchover_status,database_role from v$database;

SWITCHOVER_STATUS    DATABASE_ROLE

-------------------- ----------------

TO STANDBY           PRIMARY

SQL> 


dg2节点(standby角色):

SQL> select switchover_status,database_role from v$database;

SWITCHOVER_STATUS    DATABASE_ROLE

-------------------- ----------------

NOT ALLOWED          PHYSICAL STANDBY

SQL> 


3.在主库上执行切换命令(primary节点)

SQL> alter database commit to switchover to physical standby; --将primary角色转换为standby角色

Database altered.

SQL> shutdown immediate              --关闭数据库,启动到mount状态

ORA-01507: database not mounted


ORACLE instance shut down.

SQL> startup mount


Total System Global Area  830930944 bytes

Fixed Size                  2217912 bytes

Variable Size             545261640 bytes

Database Buffers          281018368 bytes

Redo Buffers                2433024 bytes

Database mounted.

SQL> select switchover_status,database_role from v$database;     --查看目前primary角色的状态

SWITCHOVER_STATUS    DATABASE_ROLE

-------------------- ----------------

TO PRIMARY           PHYSICAL STANDBY

SQL> 


4.在备库上执行(standby节点)

SQL> select switchover_status,database_role from v$database;     --查看standby备库角色的状态

SWITCHOVER_STATUS    DATABASE_ROLE

-------------------- ----------------

TO PRIMARY           PHYSICAL STANDBY

SQL> alter database commit to switchover to primary;       --将备库的角色修改为primary

Database altered.

SQL> select switchover_status,database_role from v$database;

SWITCHOVER_STATUS    DATABASE_ROLE

-------------------- ----------------

NOT ALLOWED          PRIMARY

SQL> alter database open;          --打开数据库

Database altered.

SQL> 


5.在备库上执行(standby节点)

SQL> select switchover_status,database_role from v$database;

SWITCHOVER_STATUS    DATABASE_ROLE

-------------------- ----------------

RECOVERY NEEDED      PHYSICAL STANDBY

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION;      --修改以前主库为日志应用

Database altered. 

SQL> 


6.测试主备节点是否切换成功

dg2节点(primary角色):

SQL> select * from tt;

  A

----------

  1

  3

  4

  5

  6

  7

6 rows selected.

SQL> insert into tt values(8);

1 row created.

SQL> commit;

Commit complete.

SQL> select * from tt where a=8;

  A

----------

  8

SQL> alter system switch logfile;

System altered.

SQL> /

System altered.

SQL> archive log list;

Database log mode         Archive Mode

Automatic archival         Enabled

Archive destination        /u01/oradata/tong/archive

Oldest online log sequence    78

Next log sequence to archive   80

Current log sequence         80

SQL> 


dg1节点(standby角色):

SQL> archive log list;

Database log mode         Archive Mode

Automatic archival         Enabled

Archive destination        /u01/oradata/tong/archive

Oldest online log sequence    79

Next log sequence to archive   0

Current log sequence         80

SQL> alter database  recover managed standby database cancel;  

Database altered.

SQL> alter database open read only;

Database altered.

SQL> select * from tt;

   A

----------

    1

    3

    4

    5

    6

    7

    8

7 rows selected.

SQL> 











本文转自 z597011036 51CTO博客,原文链接:http://blog.51cto.com/tongcheng/1874292,如需转载请自行联系原作者
目录
相关文章
|
7月前
|
Oracle 关系型数据库 数据库
使用docker安装配置oracle 11g
使用docker安装配置oracle 11g
|
4月前
|
Oracle 关系型数据库 数据库
手把手教你Oracle DataGuard主备切换(switchover)
手把手教你Oracle DataGuard主备切换(switchover)
586 4
|
7月前
|
运维 Oracle 容灾
Oracle dataguard 容灾技术实战(笔记),教你一种更清晰的Linux运维架构
Oracle dataguard 容灾技术实战(笔记),教你一种更清晰的Linux运维架构
|
4月前
|
Oracle 网络协议 安全
Oracle 11g DataGuard搭建保姆级教程
Oracle 11g DataGuard搭建保姆级教程
247 4
|
4月前
|
Oracle 网络协议 关系型数据库
Oracle DataGuard主备切换之自动切换
Oracle DataGuard主备切换之自动切换
182 2
|
6月前
|
Oracle 关系型数据库 数据库
Oracle 11G数据库安装步骤及截图操作2
Oracle 11G数据库安装步骤及截图操作
68 0
|
6月前
|
Oracle 安全 关系型数据库
Oracle 11G数据库安装步骤及截图操作1
Oracle 11G数据库安装步骤及截图操作
109 0
|
7月前
|
存储 Oracle 关系型数据库
手把手教你安装Oracle——以oracle 11g为例
手把手教你安装Oracle——以oracle 11g为例
手把手教你安装Oracle——以oracle 11g为例
|
7月前
|
Oracle 关系型数据库
oracle 19c 搭建dataguard 简要命令
通过service 完成dg 搭建。
174 0
|
7月前
|
SQL Oracle 关系型数据库
docker 方式安装ORACLE 11g
docker 方式安装ORACLE 11g
571 5