DG相关操作
2022-03-31 15:06 abce 阅读(550) 评论(0) 编辑 收藏 举报
alter database recover managed standby database;
#后台应用redo日志
alter database recover managed standby database disconnect from session;
2.取消apply进程
alter database recover managed standby database cancel;
3.延迟应用redo日志
alter database recover managed standby database cancel;
alter database recover managed standby database delay 30 disconnect from session;
alter database recover managed standby database cancel;
alter database recover managed standby database nodelay disconnect from session;
4.开启实时应用redo日志
alter database recover managed standby database using current logfile;
5.检查日志应用进度
alter session set nls_date_format='dd-mon-yyyy hh24:mi:ss';
select sequence#, first_time, next_time, applied
from v$archived_log
order by sequence#;
6.dg的模式切换
-- maximum availability.
alter system set log_archive_dest_2='service=db11g_stby affirm sync valid_for=(online_logfiles,primary_role) db_unique_name=db11g_stby';
alter database set standby database to maximize availability;
-- maximum performance.
alter system set log_archive_dest_2='service=db11g_stby noaffirm async valid_for=(online_logfiles,primary_role) db_unique_name=db11g_stby';
alter database set standby database to maximize performance;
-- maximum protection.
alter system set log_archive_dest_2='service=db11g_stby affirm sync valid_for=(online_logfiles,primary_role) db_unique_name=db11g_stby';
shutdown immediate;
startup mount;
alter database set standby database to maximize protection;
alter database open;
7.switchover的过程 在primary端: #将primary转换成standby
connect /as sysdba
alter database commit to switchover to standby;
#关闭primary
shutdown immediate
#将老的primary以standby的角色mount起来
startup nomount;
alter database mount standby database;
alter database recover managed standby database disconnect from session;
在standby端: #将standby转换成primary
connect /as sysdba
alter database commit to switchover to primary;
#关闭standby
shutdown immediate;
#开启老的stanby成为primary
startup;
8.failover的过程
alter database recover managed standby database finish;
alter database activate standby database;
9.将standby置为只读的
shutdown immediate;
startup mount;
alter database open read only;
10.将standby置为recover模式
shutdown immediate;
startup mount;
alter database recover managed standby database disconnect from session;
11.开启ADG(11g)
shutdown immediate;
startup mount;
alter database open read only;
alter database recover managed standby database disconnect from session;
12.快照standby #如果是rac,留下一个实例,其它全部关闭
shutdown immediate;
startup mount;
#关闭recovery
alter database recover managed standby database cancel;
#切换成快照standby
select flashback_on from v$database;
flashback_on
------------------
no
alter database convert to snapshot standby;
alter database open;
select flashback_on from v$database;
flashback_on
------------------
restore point only
sql>
现在就是读写模式了
#切换成standby模式
shutdown immediate;
startup mount;
alter database convert to physical standby;
shutdown immediate;
startup nomount;
alter database mount standby database;
alter database recover managed standby database disconnect;
select flashback_on from v$database;
flashback_on
------------------
no
sql>