oracle 11g dataguard主备切换

前端之家收集整理的这篇文章主要介绍了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节点:

Oldest online log sequence 60

Next log sequence to archive 0

Current log sequence 61

2.查看主备的角色

dg1节点(primary角色):

sql> select switchover_status,database_role from v$database;

SWITCHOVER_STATUS DATABASE_ROLE

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

TO STANDBY PRIMARY

dg2节点(standby角色):

NOT ALLOWED PHYSICAL STANDBY

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.

TO PRIMARY PHYSICAL STANDBY

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

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

NOT ALLOWED PRIMARY

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

5.在备库上执行(

RECOVERY NEEDED PHYSICAL STANDBY

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

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;

8

sql> alter system switch logfile;

System altered.

sql> /

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


dg1节点(standby角色):

Oldest online log sequence 79

Next log sequence to archive 0

sql> alter database recover managed standby database cancel;

sql> alter database open read only;

1

3

4

5

6

7

8

7 rows selected.

sql>

原文链接:https://www.f2er.com/oracle/211738.html

猜你在找的Oracle相关文章