Oracle 12c R1 DataGuard的主备切换

Data Guard物理备库的主备切换
1.查看状态

主库:

SQL> SELECT SWITCHOVER_STATUS FROM V$DATABASE;

SWITCHOVER_STATUS
------------------------------------------------------------
TO STANDBY            //可以转换成备库

备库:

SQL> SELECT SWITCHOVER_STATUS FROM V$DATABASE;

SWITCHOVER_STATUS
------------------------------------------------------------
NOT ALLOWED

2.主切备

SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PHYSICAL STANDBY;

数据库已更改。

SQL> startup nomount;
Oracle 例程已经启动。

Total System Global Area  751595520 bytes
Fixed Size      2292912 bytes
Variable Size    557843280 bytes
Database Buffers  188743680 bytes
Redo Buffers      2715648 bytes
SQL> alter database mount standby database;

数据库已更改。

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;

数据库已更改。

3.备切主

SQL> SELECT SWITCHOVER_STATUS FROM V$DATABASE;

SWITCHOVER_STATUS
------------------------------------------------------------
TO PRIMARY

SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY;

数据库已更改。

SQL> select status from v$instance;

STATUS
------------------------------------
MOUNTED

SQL> alter database open;

数据库已更改。

推荐阅读:

相关推荐