DataGuard构建完成后常用命令(zt)

本文提供了一系列Oracle Data Guard环境中实用的SQL命令,包括启动、停止归档日志应用、查询归档日志状态、监控日志传送及切换主备库等操作。适用于Oracle数据库管理员进行日常维护和故障排查。
摘要由CSDN通过智能技术生成
--备库启动归档日志应用
alter database recover managed standby database disconnect from session;

--备库停止归档日志应用
alter database recover managed standby database cancel;

--查询归档日志是否被应用,查询V$archived_log视图的applied列
select sequence#,dest_id,first_time,next_time,archvied,applied from v$archived_log;

--查看备库是否和主库同步,查询V$archive_dest_status视图
select archived_thread#,archived_seq#,applied_thread#,applied_seq#from v$archive_dest_status;

--监控日志传送状态,V$archive_gap记录当前备库mrp进程恢复需要的但是还没有传到备库的日志更简单的是查看主备库的归档日志的序列号相差多少
select * from v$archive_gap;

--查看当前主机的运行状态(主库/备库/保护模式)
select switchover_status,database_role,protection_mode from v$database

--查看备库接收、应用redo数据的过程
select message from v$dataguard_status

--备库端查看RFS(Remote File Service)接收日志情况和MRP应用日志同步主数据库的情况(Physical Standby Database Only)   记录当前备库的一些进程情况和进程ID
select process,status,thread#,sequence#,block#,blocks from v$managed_standby;

--V$STANDBY_LOG备用数据库的备用日志的数量与当前状态等信息
SELECT * FROM V$STANDBY_LOG;

-- From eygle  http://www.eygle.com/archives/2009/03/oracle_dataguard_manual.html

Start Standby Database

startup nomount
alter database mount standby database;
alter database recover managed standby database disconnect;


Disable/Enable archive log destinations

alter system set log_archive_dest_state_2 = 'defer';
alter system set log_archive_dest_state_2 = 'enable';

To remove a delay from a standby

alter database recover managed standby database cancel;

alter database recover managed standby database nodelay disconnect;

Stop and Start of Logical standby apply

alter database stop logical standby apply;
alter database start logical standby apply;

Physical Standby switchover:
In Primary Database:

ALTER DATABASE COMMIT TO SWITCHOVER TO PHYSICAL STANDBY;
SHUTDOWN IMMEDIATE;
STARTUP NOMOUNT;
ALTER DATABASE MOUNT STANDBY DATABASE;

In standby Database:

ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY;
SHUTDOWN IMMEDIATE;
STARTUP;

In Primary Database:

ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;

If the primary Database is down,we can use fllowing step to active standby database:

Alter DATABASE RECOVER MANAGED STANDBY DATABASE FINISH;
Alter DATABASE COMMIT TO SWITCHOVER TO PRIMARY;
SHUTDOWN IMMEDIATE;
STARTUP;


Register missing archive log file
Find archive log gap by query:

SELECT THREAD#, LOW_SEQUENCE#, HIGH_SEQUENCE# FROM V$ARCHIVE_GAP;

register using:
ALTER DATABASE REGISTER PHYSICAL LOGFILE 'filespec1';



来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/317003/viewspace-591830/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/317003/viewspace-591830/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值