开启镜像备库后为读写模式为应用提供测试,利用还原点恢复后可继续DG同步,PS:主库需保存归档日志
以下举例结构为单库- RAC node1 的DG同步,node2 为关闭状态。
#############################################
-- make snapshot
-- open standby db and do operation on node 1
#############################################
SQL> select flashback_on from v$database;
SQL> alter database flashback on;
SQL> select flashback_on from v$database;
SQL> CREATE RESTORE POINT data_0421 GUARANTEE FLASHBACK DATABASE;
SQL> drop restore point data_0421; --仅记录删除还原点命令/无须执行
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL; --关闭DG
SQL> shutdown immediate
启动到wr状态
SQL> startup mount
SQL> alter database activate standby database;
SQL> alter database open;
查询状态
SQL> select name,open_mode from v$database;
SQL> select instance_name,status from gv$instance;
#############################################
如果RAC仅有一个节点/并且是手工构建的/未加入到CRS
#############################################
-- 关闭node1数据库
shutdown immediate
-- 注册数据库及参数文件
srvctl remove database -d orcl
srvctl add database -d orcl -o D:\app\Administrator\product\11.2.0\dbhome_1 -p +DATA/orcl/spfileorcl.ora
-- 注册实例
srvctl add instance -d orcl -i orcl1 -n WIN-K1DC31C15I4
srvctl add instance -d orcl -i orcl1 -n WIN-1L7945L81UC
-- add undo on node1
SQL> create undo tablespace undotbs2 datafile '+DATA/orcl/undotbs2_001.dbf' size 2048m autoextend on;
-- add redo on node1
SQL> alter database add logfile thread 2 group 14('+DATA/orcl/redo014.log') size 2048m;
SQL> alter database add logfile thread 2 group 15('+DATA/orcl/redo015.log') size 2048m;
SQL> alter database add logfile thread 2 group 16('+DATA/orcl/redo016.log') size 2048m;
SQL> alter database add logfile thread 2 group 17('+DATA/orcl/redo017.log') size 2048m;
SQL> alter database add logfile thread 2 group 18('+DATA/orcl/redo018.log') size 2048m;
SQL> alter database add logfile thread 2 group 19('+DATA/orcl/redo019.log') size 2048m;
SQL> alter database add logfile member '+DATA/orcl/redo0144.log' to group 14;
SQL> alter database add logfile member '+DATA/orcl/redo0155.log' to group 15;
SQL> alter database add logfile member '+DATA/orcl/redo0166.log' to group 16;
SQL> alter database add logfile member '+DATA/orcl/redo0177.log' to group 17;
SQL> alter database add logfile member '+DATA/orcl/redo0188.log' to group 18;
SQL> alter database add logfile member '+DATA/orcl/redo0199.log' to group 19;
SQL> alter database enable public thread 2;
********* 如果RAC各节点均已加入到CRS *********
-- add undo on node1
SQL> create undo tablespace undotbs2 datafile '+DATA/orcl/undotbs2_001.dbf' size 2048m autoextend on;
*/
-- startup db on node 2
SQL> startup
-- every instance switch logfile
SQL> alter system switch logfile;
1. 进入到RAC的每个实例切换下归档日志,并做一下远程连接(scan ip)。没问题再给客户开放环境。
2. 生成库、RAC(目标库) 的数据库、磁盘空间、ASM空间、FRA空间、归档空状态定期检查(建议早上,晚上个进来看一眼)
sqlplus system/oracle@192.168.3.2 :1521/orcl
#############################################
-- restore standby db
** shutdown instance on node 2 **
-- do operation on node 1
#############################################
还原DG状态
SQL> select scn,name,guarantee_flashback_database,time from v$restore_point;
SQL> shutdown immediate;
SQL> startup mount;
SQL> FLASHBACK DATABASE TO RESTORE POINT data_0421;
SQL> alter database convert to physical standby ;
SQL> shutdown immediate;
SQL> startup mount;
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE disconnect from session; ---启动DG
SQL> select flashback_on from v$database;
SQL> alter database flashback off;
SQL> select flashback_on from v$database;
SQL> drop restore point data_0421;
-- dg 实时同步命令
alter database recover managed standby database cancel;
alter database recover managed standby database using current logfile disconnect from session;
--dg 进程
select process,status,thread#,sequence# from v$managed_standby;
--序列应用
select first_time,sequence#,applied from v$archived_log order by sequence#;
--dg延迟
set pagesize 20;
column name format a13;
column value format a20;
column unit format a30;
column TIME_COMPUTED format a30;
select name,value,unit,time_computed from v$dataguard_stats where name in ('transport lag','apply lag');