oracle 19c 主备切换

主库:

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

Database altered.

SQL> startup
ORACLE instance started.

Total System Global Area 2466250400 bytes
Fixed Size                  9137824 bytes
Variable Size             536870912 bytes
Database Buffers         1912602624 bytes
Redo Buffers                7639040 bytes
Database mounted.
Database opened.
SQL> select open_mode from v$database;

OPEN_MODE
------------------------------------------------------------
READ ONLY

SQL>  select name,database_role,switchover_status from v$database;

NAME                        DATABASE_ROLE                                    SWITCHOVER_STATUS
--------------------------- ------------------------------------------------ ------------------------------------------------------------
MTXDB                       PHYSICAL STANDBY                                 RECOVERY NEEDED

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

Database altered.

SQL> select name,database_role,switchover_status from v$database;

NAME                        DATABASE_ROLE                                    SWITCHOVER_STATUS
--------------------------- ------------------------------------------------ ------------------------------------------------------------
MTXDB                       PHYSICAL STANDBY                                 NOT ALLOWED


SQL> SELECT UNIQUE THREAD#, MAX(SEQUENCE#) OVER(PARTITION BY THREAD#) LAST FROM v$archived_log;

   THREAD#       LAST
---------- ----------
         1         39

 

备库:

SQL> alter database commit to switchover to primary;

Database altered.

SQL> alter database open;

Database altered.

SQL> select open_mode from v$database;

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

SQL> select name,database_role,switchover_status from v$database;

NAME                        DATABASE_ROLE                                    SWITCHOVER_STATUS
--------------------------- ------------------------------------------------ ------------------------------------------------------------
MTXDB                       PRIMARY                                          TO STANDBY

SQL> SELECT UNIQUE THREAD#, MAX(SEQUENCE#) OVER(PARTITION BY THREAD#) LAST FROM v$archived_log;

   THREAD#       LAST
---------- ----------
         1         39

 

posted on 2020-06-27 23:21  InnoLeo  阅读(805)  评论(2编辑  收藏  举报