标签:base tin 进程 spfile timestamp hang change param standby
Oracle Dataguard管理命令(logical standby)
#################
## 管理命令:
#################
1、注册日志的命令standby
SQL> ALTER DATABASE REGISTER LOGICAL LOGFILE
‘/usr2/u01/app/oracle/oracle9201/oradata/scpdb/standby_archive/1_15.dbf‘;
2、设置初始化参数的一些命令
备库:
SQL> alter system set standby_archive_dest=‘/usr2/u01/app/oracle/oracle9201/oradata/scpdb/standby_archive‘ scope=both;
主库:
3、pfile spfile
startup mount pfile=/usr2/u01/app/oracle/oracle9201/admin/scpdb/pfile/initscpdb.ora
create spfile from pfile=‘/usr2/u01/app/oracle/oracle9201/admin/scpdb/pfile/initscpdb.ora‘
create pfile=‘/usr2/u01/app/oracle/oracle9201/admin/scpdb/pfile/initscpdb.ora‘ from spfile;
4、设置主库为archive log
SQL> STARTUP MOUNT;
SQL> ALTER DATABASE ARCHIVELOG;
SQL> ALTER DATABASE OPEN;
SQL> ARCHIVE LOG LIST;
5、 在primary上做archive操作
SQL> ALTER SYSTEM ARCHIVE LOG CURRENT;
6、备库的日志应用服务的错误
SQL> EXECUTE DBMS_LOGSTDBY.SKIP_ERROR(‘DML‘, ‘LY‘, ‘T3‘, null);
SQL> EXECUTE DBMS_LOGSTDBY.UNSKIP_ERROR(‘DML‘,‘LY‘, ‘T3‘, null);
############################
# 备库如何监控日志应用
############################
1、 启动和停止日志应用服务
SQL> ALTER DATABASE START LOGICAL STANDBY APPLY INITIAL;
### SQL> ALTER DATABASE STOP LOGICAL STANDBY APPLY;
### SQL> ALTER DATABASE START LOGICAL STANDBY APPLY;
2、 V$LOGSTDBY
显示正在读取redo log和应用archived redo log的进程
SQL> COLUMN STATUS FORMAT A50
SQL> COLUMN TYPE FORMAT A12
SQL> SELECT TYPE, HIGH_SCN, STATUS FROM V$LOGSTDBY;
3、 DBA_LOGSTDBY_PROGRESS
### 显示LSP的状态和在standby上应用的sql的信息
### 快速判断是否所有的日志信息都被应用,两个值一样的话说明状态正常
SQL> SELECT APPLIED_SCN, NEWEST_SCN FROM DBA_LOGSTDBY_PROGRESS;
### 判断日志是否被应用
SQL> ALTER SESSION SET NLS_DATE_FORMAT = ‘DD-MON-YY HH24:MI:SS‘;
SQL> SELECT L.SEQUENCE#, L.FIRST_TIME,
(CASE WHEN L.NEXT_CHANGE# < P.READ_SCN THEN ‘YES‘
WHEN L.FIRST_CHANGE# < P.APPLIED_SCN THEN ‘CURRENT‘
ELSE ‘NO‘ END) APPLIED
FROM DBA_LOGSTDBY_LOG L, DBA_LOGSTDBY_PROGRESS P
ORDER BY SEQUENCE#;
4、 DBA_LOGSTDBY_EVENTS
### 此视图可以监控日志应用服务发生的事件
### 如果日志应用服务异常中止,那么错误信息将会显示在这个view中
SQL> ALTER SESSION SET NLS_DATE_FORMAT = ‘DD-MON-YY HH24:MI:SS‘;
SQL> COLUMN STATUS FORMAT A60
SQL> SELECT EVENT_TIME, STATUS, EVENT FROM DBA_LOGSTDBY_EVENTS
ORDER BY EVENT_TIME, COMMIT_SCN;
5、 DBA_LOGSTDBY_LOG
### 提供日志应用服务的动态信息。
### DICT_BEGIN为yes的项表名词典build的begining在此redo log中,
### DICT_END为yes的项表名词典build的END在此redo log中,
SQL> SELECT FILE_NAME, SEQUENCE#, FIRST_CHANGE#, NEXT_CHANGE#,
TIMESTAMP, DICT_BEGIN, DICT_END, THREAD# FROM DBA_LOGSTDBY_LOG
ORDER BY SEQUENCE#;
6、 V$LOGSTDBY_STATS
### 提供日志应用服务的状态和统计信息,可以看出备库的日志应用是否正常
SQL> COLUMN NAME FORMAT A35
SQL> COLUMN VALUE FORMAT A35
SQL> SELECT NAME, VALUE FROM V$LOGSTDBY_STATS
WHERE NAME LIKE ‘coordinator%‘ or NAME LIKE ‘transactions%‘;
7、 V$DATAGUARD_STATUS
显示dataguard的状态
SQL> SELECT * FROM V$DATAGUARD_STATUS;
###############################
# 主库的一些命令
###############################
1、监控主库的archive是否正常
SQL> ARCHIVE LOG LIST; ### 看自动归档是否开启
SQL> SHOW PARAMETER LOG_ARCHIVE; ### 看归档的目的的,状态
SQL> SHOW PARAMETER REMOTE; ### 看remote归档是否开启
2、 查看当前的重做日志号
SQL> SELECT THREAD#, SEQUENCE#, ARCHIVED, STATUS FROM V$LOG;
3、 查看最近归档的重做日志号
SQL> SELECT MAX(SEQUENCE#) FROM V$ARCHIVED_LOG;
4、 查看最近归档的重做日志文件(包括所有的目的地)
SQL> SELECT DESTINATION, STATUS, ARCHIVED_THREAD#, ARCHIVED_SEQ#
FROM V$ARCHIVE_DEST_STATUS
WHERE STATUS <> ‘DEFERRED‘ AND STATUS <> ‘INACTIVE‘;
5、 查看日志是否在特定的站点被接收
SQL> SELECT LOCAL.THREAD#, LOCAL.SEQUENCE# FROM
(SELECT THREAD#, SEQUENCE# FROM V$ARCHIVED_LOG WHERE DEST_ID=1)
LOCAL WHERE
LOCAL.SEQUENCE# NOT IN
(SELECT SEQUENCE# FROM V$ARCHIVED_LOG WHERE DEST_ID=3 AND
THREAD# = LOCAL.THREAD#);
6、查看是否有网络错误
SQL> SELECT DEST_ID, STATUS, ERROR FROM V$ARCHIVE_DEST WHERE DEST_ID = 3;
Oracle Dataguard管理命令(logical standby)
标签:base tin 进程 spfile timestamp hang change param standby
原文地址:https://www.cnblogs.com/yaoyangding/p/12808901.html