dataguard 常规运维操作

时间:2022-03-22 02:34:32

1.standby database 正常的打开与关闭

1.1 针对 physical standby
打开:
--打开数据库
SQL>startup; 
-- 开启 mgr 进程 
SQL>ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE disconnect from session; ( physical standby )

关闭:
-- 关闭 mgr 进程
SQL>ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
-- 正常关闭数据库
SQL> shutdown immediate;

1.2 针对 logical standby
-- 开启 mgr 进程
SQL>ALTER DATABASE START LOGICAL STANDBY APPLY IMMEDIATE; 
-- 关闭 mgr 进程
SQL>ALTER DATABASE STOP LOGICAL STANDBY APPLY;

2. 查看数据库角色与保护模式

SQL> select protection_mode, protection_level, database_role role, switchover_status from v$database;

3.查询每个standby 的状态:
-- 主库执行
SQL> SELECT DEST_ID, STATUS,APPLIED_SCN FROM V$ARCHIVE_DEST WHERE TARGET='STANDBY';

DEST_ID STATUS APPLIED_SCN
---------- --------- -----------
2 VALID 1818069

4. 检查redo 传送情况

-- 备库查看当前 log sequence 
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 41
Next log sequence to archive 0
Current log sequence 41
-- 主库日志切换
SQL> alter system switch logfile;
System altered.
-- 备库查看当前 log sequence ,如果 log sequence 有变化说明传输没有问题。
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 41
Next log sequence to archive 0
Current log sequence 42

5. 检查 mrp 应用情况
--备库执行
SQL> SELECT THREAD#, SEQUENCE#, FIRST_CHANGE#,NEXT_CHANGE#,APPLIED FROM V$ARCHIVED_LOG;


THREAD# SEQUENCE# FIRST_CHANGE# NEXT_CHANGE# APPLIED
---------- ---------- ------------- ------------ ---------
1 24 1449716 1451135 YES
1 26 1476706 1481494 YES
1 25 1451135 1476706 YES
1 27 1481494 1491422 YES
1 29 1524315 1547524 YES

6. 查询archived log 的历史信息:(主备都执行,对比是否相同)
SQL> SELECT THREAD#, SEQUENCE#, FIRST_CHANGE#, NEXT_CHANGE# FROM V$LOG_HISTORY;

7. 查询DG的日志信息,这些日志信息可以写入alert log 或者进程的trace 文件
SQL> set pagesize 200
SQL> SELECT MESSAGE FROM V$DATAGUARD_STATUS;
MESSAGE
------------------------------------------
ARC0: Archival started
ARC1: Archival started
ARC2: Archival started
ARC2: Becoming the 'no FAL' ARCH
ARC1: Becoming the heartbeat ARCH
ARC1: Becoming the active heartbeat ARCH
ARC3: Archival started