一、dg的搭建、计划切换、故障切换:
https://blog.csdn.net/shiyu1157758655/article/details/72878249
其中搭建有如下两点需要注意:
1)备库密码文件跟实例名一样,而不是跟db_unique_name一样,如下(而不是orapwdgstd):
2)主库和备份的tns文件都需要加上(UR = A)参数:
二、switchover
主库:
备库:
新备库(原主库):
三、failover(必须确保主库备库的flashback是打开的,可查看v$database(flashback_on))
第一阶段(故障):
主库:
备库:
第二阶段(恢复):
新主库:
新备库:
四、dg的启动和关闭:
1、启动:先启动standby库在启动primary库
备库:
主库:
2、关闭:先关闭primary库再关闭standby库
主库:
备库:
3、验证是否正常:
五、dg相关知识点:
http://lib.csdn.net/article/oracle/29298
https://blog.csdn.net/shiyu1157758655/article/details/72878249
其中搭建有如下两点需要注意:
1)备库密码文件跟实例名一样,而不是跟db_unique_name一样,如下(而不是orapwdgstd):
点击(此处)折叠或打开
- [oracle@dg2 dbs]$ ll
- -rw-r----- 1 oracle oinstall 1536 Dec 11 15:56 orapwdg
点击(此处)折叠或打开
- DGSTD =
- (DESCRIPTION =
- (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
- (CONNECT_DATA =
- (SERVER = DEDICATED)
- (SERVICE_NAME = dgstd)
- (UR = A)
- )
- )
主库:
点击(此处)折叠或打开
- SQL> select switchover_status,database_role from v$database;
- SWITCHOVER_STATUS DATABASE_ROLE
- -------------------- ----------------
- TO STANDBY PRIMARY
- SQL> alter database commit to switchover to physical standby;
- SQL> startup mount
- SQL> select database_role from v$database;
- DATABASE_ROLE
- ----------------
- PHYSICAL STANDBY
点击(此处)折叠或打开
- SQL>select switchover_status,database_role from v$database;
- SWITCHOVER_STATUS DATABASE_ROLE
- -------------------- ----------------
- TO PRIMARY PHYSICAL STANDBY
- SQL>alter database commit to switchover to primary with session shutdown;
- SQL>alter database open;
- SQL>select switchover_status,database_role,open_mode from v$database;
- SWITCHOVER_STATUS DATABASE_ROLE OPEN_MODE
- -------------------- ---------------- --------------------
- RESOLVABLE GAP PRIMARY READ WRITE
点击(此处)折叠或打开
- SQL> alter database open;
- SQL> alter database recover managed standby database using current logfile disconnect from session;
第一阶段(故障):
主库:
点击(此处)折叠或打开
- SQL> select switchover_status,database_role,open_mode from v$database;
- SWITCHOVER_STATUS DATABASE_ROLE OPEN_MODE
- -------------------- ---------------- --------------------
- TO STANDBY PRIMARY READ WRITE
- SQL> shutdown abort
点击(此处)折叠或打开
- SQL> alter database recover managed standby database cancel;
- SQL> alter database recover managed standby database finish force;
- SQL> select switchover_status,database_role,open_mode from v$database;
- SWITCHOVER_STATUS DATABASE_ROLE OPEN_MODE
- -------------------- ---------------- --------------------
- TO PRIMARY PHYSICAL STANDBY READ ONLY
- SQL> alter database commit to switchover to primary;
- SQL> alter database open;
- SQL> select switchover_status,database_role,open_mode from v$database;
- SWITCHOVER_STATUS DATABASE_ROLE OPEN_MODE
- -------------------- ---------------- --------------------
- FAILED DESTINATION PRIMARY READ WRITE
新主库:
点击(此处)折叠或打开
- SQL> select to_char(standby_became_primary_scn) from v$database;
- TO_CHAR(STANDBY_BECAME_PRIMARY_SCN)
- ----------------------------------------
- 1022901
点击(此处)折叠或打开
- SQL> startup mount
- SQL> flashback database to scn 1022901;
- SQL> alter database convert to physical standby;
- SQL> shutdown immediate
- SQL> startup
- SQL> alter database recover managed standby database using current logfile disconnect from session;
- SQL> select open_mode from v$database;
- OPEN_MODE
- --------------------
- READ ONLY WITH APPLY
1、启动:先启动standby库在启动primary库
备库:
点击(此处)折叠或打开
- [oracle@dg2 ~]$ lsnrctl start
- SQL> startup #此时会自动启动成READ ONLY模式,可以查看v$database(OPEN_MODE)
- SQL> alter database recover managed standby database using current logfile disconnect from session;
点击(此处)折叠或打开
- [oracle@dg1 ~]$ lsnrctl start
- SQL> startup
主库:
点击(此处)折叠或打开
- SQL> shutdown immediate
点击(此处)折叠或打开
- SQL> alter database recover managed standby database cancel;
- SQL> shutdown immediate
点击(此处)折叠或打开
- SQL> col dest_name format a30
- SQL> col error format a20
- SQL> select dest_name,error from v$archive_dest; #查看是否有报错
http://lib.csdn.net/article/oracle/29298
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/31441616/viewspace-2152992/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/31441616/viewspace-2152992/