【Dataguard】Switchover切换

主备库切换操作验证 ( switchover )

1.   主库执行切换(A机)

( 1 )   查看 主库状态

临翔网站建设公司创新互联建站,临翔网站设计制作,有大型网站制作公司丰富经验。已为临翔上千余家提供企业网站建设服务。企业网站搭建\成都外贸网站制作要多少钱,请找那个售后服务好的临翔做网站的公司定做!

SQL> select db_unique_name,open_mode,database_role,switchover_status from v$database;

 

DB_UNIQUE_NAME  OPEN_MODE    DATABASE_ROLE    SWITCHOVER_STATUS

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

bhtc db               READ WRITE             PRIMARY             TO STANDBY

 

( 2 )主库执行切换命令

SQL> alter database commit to switchover to physical standby with session shutdown wait;

Database altered.


( 2 )重启主库角色变为备库( mount 状态 )

 

SQL> startup mount;

ORACLE instance started.

 

Total System Global Area 1.3429E+10 bytes

Fixed Size                  2265944 bytes

Variable Size            6878661800 bytes

Database Buffers         6543114240 bytes

Redo Buffers                4612096 bytes

Database mounted.

 

( 4 )查看 主库状态

SQL> select db_unique_name,open_mode,database_role,switchover_status from v$database;

 

DB_UNIQUE_NAME  OPEN_MODE    DATABASE_ROLE    SWITCHOVER_STATUS

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

Bhtc db                MOUNTED     PHYSICAL STANDBY      RECOVERY NEEDED  

 

2.   备库切换成主库 ( B 机)

 

( 1 )查看备库状态

 

SQL> select db_unique_name,open_mode,database_role,switchover_status from v$database;

 

DB_UNIQUE_NAME   OPEN_MODE   DATABASE_ROLE    SWITCHOVER_STATUS

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

bhtcdg              MOUNTED          PHYSICAL STANDBY      TO PRIMARY

 

( 2 )将备库切换成主库

 

SQL> alter database commit to switchover to primary with session shutdown  wait ;

Database altered.


( 3 )查看备库状态

 

SQL> select db_unique_name,open_mode,database_role,switchover_status from v$database;

 

DB_UNIQUE_NAME  OPEN_MODE     DATABASE_ROLE   SWITCHOVER_STATUS

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

bhtcdg             MOUNTED           PRIMARY            NOT ALLOWED


( 4 )开启

 

SQL> alter database open;

Database altered.

 

SQL>  select db_unique_name,open_mode,database_role,switchover_status from v$database;

 

DB_UNIQUE_NAME  OPEN_MODE  DATABASE_ROLE    SWITCHOVER_STAT

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

bhtcdg         READ WRITE    PRIMARY          RESOLVABLE GAP

 

3.  打开数据库( A 机)

 

SQL> alter database open read only;

 

4.  应用日志( A 机)

SQL> alter database recover managed standby database using current logfile disconnect from session;

 

3. 验证数据

( 1 )在新主库创建用户( B 机)

 

SQL> create user test1 identified by test1;

SQL> commit;

 

SQL> alter system switch logfile;

System altered.


( 2 )在新备库查看( A 机)

SQL> select username from dba_users where username='TEST1';

 

USERNAME

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

TEST1

 

 

4. 切换回 最初的状态

 

(1) 新 主库操作( B 机 )

SQL> alter database commit to switchover to physical standby with session shutdown;

Database altered.

 

SQL> startup mount;

ORACLE instance started.

 

Total System Global Area 1.3429E+10 bytes

Fixed Size                  2265944 bytes

Variable Size            6878661800 bytes

Database Buffers         6543114240 bytes

Redo Buffers                4612096 bytes

Database mounted.

 

 

(2) 新 备库 操作( A 机)

 

SQL> alter database commit to switchover to primary with session shutdown;

Database altered.

 

SQL> alter database open;

Database altered.

 

SQL> select db_unique_name,open_mode,database_role,switchover_status from v$database;

 

DB_UNIQUE_NAME  OPEN_MODE    DATABASE_ROLE    SWITCHOVER_STATUS

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

bhtcdb               READ WRITE            PRIMARY            RESOLVABLE GAP

 

( 3 ) B 机 操作

 

SQL> select db_unique_name,open_mode,database_role,switchover_status from v$database;

 

DB_UNIQUE_NAME   OPEN_MODE   DATABASE_ROLE    SWITCHOVER_STATUS

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

bhtcdg                MOUNTED      PHYSICAL STANDBY  NOT ALLOWED

 

( 4 )打开备库开启实时同步

 

SQL> alter database open read only;

Database altered.

 

SQL> alter database recover managed standby database using current logfile disconnect;

Database altered.

 

SQL> select db_unique_name,open_mode,database_role,switchover_status from v$database;

 

DB_UNIQUE_NAME  OPEN_MODE  DATABASE_ROLE    SWITCHOVER_STAT

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

bhtcdg          READ ONLY  PHYSICAL STANDBY NOT ALLOWED

                WITH APPLY

 

( 5 )再次查看 A 机

 

SQL> select db_unique_name,open_mode,database_role,switchover_status from v$database;

 

DB_UNIQUE_NAME  OPEN_MODE    DATABASE_ROLE    SWITCHOVER_STATUS

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

bhtc db             READ WRITE            PRIMARY           TO STANDBY

 

此时 ,已经切换回最初的状态

 

( 6 )备库查看日志应用情况

 

SQL> select sequence#,applied from v$archived_log;

 

 SEQUENCE# APPLIED

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

         8 YES

         7 YES

         9 YES

        10 YES

        11 YES

        12 YES

        13 YES

        13 YES

        14 YES

        14 YES

        15 YES

 

 SEQUENCE# APPLIED

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

        15 YES

        16 YES

        16 YES

        17 YES

        17 NO

        18 YES

        19 YES

        20 YES

        21 IN-MEMORY

 

---------- end ----------


分享标题:【Dataguard】Switchover切换
转载源于:http://bzwzjz.com/article/jhpsco.html

其他资讯

Copyright © 2007-2020 广东宝晨空调科技有限公司 All Rights Reserved 粤ICP备2022107769号
友情链接: 高端网站设计 重庆网站制作 成都网站设计 专业网站设计 高端品牌网站建设 四川成都网站设计 成都网站设计公司 定制网站建设多少钱 外贸网站设计方案 专业网站建设 成都网站建设 成都网站建设公司 商城网站建设 手机网站设计 成都网站制作 成都网站建设 网站建设 网站建设方案 网站设计制作报价 品牌网站建设 成都网站设计 网站设计