1、单实例到单实例的切换
先将主库切换成备库,然后将原主库启动到物理库的状态
SQL> select switchover_status from v$database;
SWITCHOVER_STATUS
--------------------
TO STANDBY
SQL> Alter database commit to switchover to physical standby with session shutdown;
Database altered.
SQL> shut immediate
ORA-01507: database not mounted
ORACLE instance shut down.
SQL> startup nomount;
ORACLE instance started.
Total System Global Area 304807936 bytes
Fixed Size 2212856 bytes
Variable Size 176163848 bytes
Database Buffers 121634816 bytes
Redo Buffers 4796416 bytes
SQL> alter database mount standby database;
Database altered.
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION;
Database altered.
然后将备库切换成主库
SQL> select switchover_status from v$database;
SWITCHOVER_STATUS
--------------------
TO PRIMARY
SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY;
Database altered.
SQL> ALTER DATABASE open;
Database altered.
RAC到单实例的切换
现有RAC(12C)到单实例的物理DATAGUARD,需要SWITCHOVER主库到单实例上 ,使原来的
RAC成为备库,单实例备库成为主库.
在rac和单实例备库上检查DG的相关参数,确认无误.
在RAC上,手动实现switch logfile,然后检查备库是已经应用了相用的logfile,以确保事务
完全在备库上应用。
SQL> alter system switch logfile;
System altered.
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /u01/app/oracle/product/12.1.0.0/db_1/dbs/arch
Oldest online log sequence 69
Next log sequence to archive 70
Current log sequence 70
SQL> select database_role from v$database;
DATABASE_ROLE
----------------
PRIMARY
DG备库上检查
SQL> select database_role from v$database;
DATABASE_ROLE
----------------
PHYSICAL STANDBY
SQL> select process,client_process,thread#,sequence# from v$managed_standby;
PROCESS CLIENT_P THREAD# SEQUENCE#
--------- -------- ---------- ----------
ARCH ARCH 1 68
ARCH ARCH 1 64
ARCH ARCH 0 0
ARCH ARCH 1 69
RFS UNKNOWN 0 0
RFS ARCH 0 0
RFS LGWR 2 30
RFS UNKNOWN 0 0
RFS LGWR 1 70
RFS ARCH 0 0
RFS UNKNOWN 0 0
PROCESS CLIENT_P THREAD# SEQUENCE#
--------- -------- ---------- ----------
RFS UNKNOWN 0 0
MRP0 N/A 1 70
13 rows selected.
在rac主库上执行
SQL> alter database commit to switchover to physical standby;
Database altered.
SQL> select database_role from v$database;
DATABASE_ROLE
----------------
PHYSICAL STANDBY
在dg备库提升为主库.
SQL> alter database commit to switchover to primary;
Database altered.
SQL> select database_role from v$database;
DATABASE_ROLE
----------------
PRIMARY
打开单实例数据库
SQL> alter database open;
Database altered.
在11.2的版本中在SWITCHOVER时,不需要再更改cluster_database参数重启数据库了,这一点
比原来方便很多.
在rac节点上启动日志应用.
SQL> alter database recover managed standby database disconnect from session;
Database altered.
SQL> select open_mode from v$database;
OPEN_MODE
--------------------
READ ONLY WITH APPLY --default已经使用active dataguard了.
在单实例主库上手动切换日志,检查在rac备库上应用情况,确认DATAGUARD工作正常.
生产库DG的切换演练
最新推荐文章于 2024-06-21 19:22:47 发布