1、查看备库状态
SQL> select open_mode,database_role,db_unique_name from v$database;
2、将备库置与应用日志模式状态
SQL> alter database recover managed standby database using current logfile disconnect from session;
3、取消备库的自动恢复
SQL> alter database recover managed standby database cancel;
4、打开实时应用状态模式
SQL> alter database recover managed standby database using current logfile disconnect;
4、查看日志应用到哪个组
SQL> select max(SEQUENCE#) from v$archived_log where applied='YES'
5.主库和备库之间角色切换
5.1 主库切换为备库
alter database commit to switchover to physical standby;
alter database commit to switchover to physical standby with session shutdown;-- 主库有会话连接的时候
shutdown immediate
startup nomount;
alter database mount standby database;
alter database recover managed standby database disconnect from session;
5.2 从库切换为主库
alter database commit to switchover to primary;
shutdown immediate;
startup
alter system switch logfile;
6.备库自动使用主库传过来的日志进行恢复
alter database recover automatic standby database;
7.更改保护模式
alter database set standby database to maximize protection;
alter database set standby database to maximize availability;
alter database set standby database to maximize performancen;
恢复进度相关的 v$视图应用示例
1、查看进程的活动状况---v$managed_standby
SQL> select process,client_process,sequence#,status from v$managed_standby;
2、确认 redo 应用进度---v$archive_dest_status
SQL> select dest_name,archived_thread#,archived_seq#,applied_thread#,applied_seq#,db_unique_name from v$archive_dest_status where status='VALID';
3、检查归档文件路径及创建信息---v$archived_log
SQL> select name,creator,sequence#,applied,completion_time from v$archived_log;
4、查询归档历史---v$log_history
SQL> select first_time,first_change#,next_change#,sequence# from v$log_history;
6、查询 failover 后快速启动的信息
SQL> select fs_failover_status,fs_failover_current_target,fs_failover_threshold,fs_failover_observer_present from v$database;
7、检查应用模式(是否启用了实时应用)---v$archive_dest_status
SQL> select recovery_mode from v$archive_dest_status where dest_id=2;
12、Data guard 事件---v$dataguard_status
SQL> select message from v$dataguard_status;
8、删除和添加standby log
alter database drop standby logfile group 1; ----------添加日志组
alter database add standby logfile thread 1 group 1 ('/u02/oradata/center/standbylog/standby_log1_1','/u02/oradata/center/standbylog/standby_log1_2') size 4096M; ----------删除日志组
alter database drop logfile member '/u02/oradata/center/standbylog/standby_log1_2'; ----------删除日志组的一个成员
ALTER DATABASE ADD standby LOGFILE MEMBER '/u02/oradata/center/standbylog/standby_log1_2' TO GROUP 1; ---------添加日志组成员