环境:RHEL 6.5 + Oracle 11.2.0.4

三、监控DG的状态

四、备库切换为snapshot standby

五、备库还原为physical standby

三、监控DG的状态

3.1 监控DG备库的状态

在备库查询v$dataguard_stats视图信息:

--format
set linesize 120
col NAME for a25
col VALUE for a18
col UNIT for a30
col TIME_COMPUTED for a20
col DATUM_TIME for a20
--select v$dataguard_stats
select * from v$dataguard_stats;

上面语句的查询结果类似下面输出:

SQL> select * from v$dataguard_stats;

NAME                      VALUE              UNIT                           TIME_COMPUTED        DATUM_TIME
------------------------- ------------------ ------------------------------ -------------------- --------------------
transport lag +00 00:00:00 day(2) to second(0) interval 11/18/2016 21:49:47 11/18/2016 21:49:47
apply lag +00 00:00:00 day(2) to second(0) interval 11/18/2016 21:49:47 11/18/2016 21:49:47
apply finish time +00 00:00:00.000 day(2) to second(3) interval 11/18/2016 21:49:47
estimated startup time 23 second 11/18/2016 21:49:47

理解v$dataguard_stats视图信息含义:

参考11.2版本的官方文档,

Name of the metric:

APPLY FINISH TIME - An estimate of the time needed to apply all received, but unapplied redo from the primary database. If there are one or more redo gaps on the standby database, an estimate of the time needed to apply all received, but unapplied redo up to the end of the last archived redo log before the beginning of the earliest redo gap.

APPLY LAG - Apply lag is a measure of the degree to which the data in a standby database lags behind the data in the primary database, due to delays in propagating and applying redo to the standby database.

TRANSPORT LAG - Transport lag is a measure of the degree to which the transport of redo to the standby database lags behind the generation of redo on the primary database. If there are one or more redo gaps on the standby database, the transport lag is calculated as if no redo has been received after the beginning of the earliest redo gap.

ESTIMATED STARTUP TIME - An estimate of the time needed to start and open the database.

如果是10.2版本的官方文档,有一些差异:

APPLY FINISH TIME: Estimated time before log apply services will finish applying the redo data available on the standby database. If there are gaps in the log files, this parameter shows the time it will take to resolve the gap with the lowest SCN.

APPLY LAG: Amount of time that the application of redo data on the standby database lags behind the primary database.

TRANSPORT LAG: How much redo data (in time units) generated by the primary database is not available or applicable on the standby database at the time of computation.

Note: This parameter includes the redo data that has not been transmitted to the standby database and redo data that is available on the standby database but has not been applied yet, such as the redo data for resolving a gap.

ESTIMATED STARTUP TIME: Estimated time the physical standby database was started. This is not displayed for logical standby databases.

STANDBY HAS BEEN OPEN: Indicates if the physical standby database was opened in read-only mode at any time since the last time the database was started. The parameter value indicates if the instance must be stopped and restarted after a failover. If the physical standby database has been opened in read-only mode since the last time it was started and it is the target of a failover, you must shut down the database and restart it in read/write mode. If the primary database must be shutdown and restarted, use the sum of APPLY FINISH TIME and ESTIMATED STARTUP TIME to obtain an estimated failover time (the estimate assumes SHUTDOWN ABORT).

3.2 监控主库传输日志链路的状态

监控主库传输日志链路的状态:

show parameter log_archive_dest_
show parameter log_archive_dest_state_
select value from v$parameter where name='log_archive_dest_state_3';
select value from v$parameter where name='log_archive_dest_3';
select error from v$archive_dest where dest_id=3;

查询结果类似下面输出:

SQL> select value from v$parameter where name='log_archive_dest_state_3';

VALUE
--------------------------------------------------------------------------------
enable SQL> select value from v$parameter where name='log_archive_dest_3'; VALUE
--------------------------------------------------------------------------------
SERVICE=jyzhao_s LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) db_unique_n
ame=jyzhao_s SQL> select error from v$archive_dest where dest_id=3; ERROR
-----------------------------------------------------------------

四、备库切换为snapshot standby后测试

4.1 备库切换为snapshot standby

查看参数值:

show parameter db_recovery_file_dest
--如果返回值为空,则设置一个合理的值:
Alter system set db_recovery_file_dest_size=1000G scope=spfile;
Alter system set db_recovery_file_dest='+DATA' scope=spfile;

核心步骤:

--取消日志应用
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
--查询当前数据库SCN
select to_char(current_scn) from v$database;
--确定job_queue_processes值为0
show parameter job_queue_processes
alter system set job_queue_processes=0;
--重启数据库到mount状态
shutdown immediate
startup mount;
select database_role, open_mode from v$database;
--切换数据库到snapshot standby
alter database convert to snapshot standby;
--重新启动数据库
shutdown immediate
startup;
select database_role, open_mode from v$database;

操作过程类似如下:

SQL> show parameter db_recovery_file_dest

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest string /u01/app/oracle/fra
db_recovery_file_dest_size big integer 4407M
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL; Database altered. SQL> SQL> select to_char(current_scn) from v$database; TO_CHAR(CURRENT_SCN)
----------------------------------------
1935528 SQL> show parameter job_queue_processes NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
job_queue_processes integer 1000
SQL> alter system set job_queue_processes=0; System altered. SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started. Total System Global Area 221331456 bytes
Fixed Size 2251856 bytes
Variable Size 163578800 bytes
Database Buffers 50331648 bytes
Redo Buffers 5169152 bytes
Database mounted.
SQL> select database_role, open_mode from v$database; DATABASE_ROLE OPEN_MODE
---------------- --------------------
PHYSICAL STANDBY MOUNTED SQL> alter database convert to snapshot standby; Database altered. SQL> select database_role, open_mode from v$database; DATABASE_ROLE OPEN_MODE
---------------- --------------------
SNAPSHOT STANDBY MOUNTED SQL> shutdown immediate
ORA-01109: database not open Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started. Total System Global Area 221331456 bytes
Fixed Size 2251856 bytes
Variable Size 163578800 bytes
Database Buffers 50331648 bytes
Redo Buffers 5169152 bytes
Database mounted.
Database opened.
SQL> select open_mode, database_role from v$database; OPEN_MODE DATABASE_ROLE
-------------------- ----------------
READ WRITE SNAPSHOT STANDBY

4.2 开始读写测试

连接到业务用户jingyu下,删除原有的test表并清空用户回收站:

SQL> conn jingyu/jingyu
Connected.
SQL> select * from cat; TABLE_NAME TABLE_TYPE
------------------------------ -----------
BIN$QSRM4jesEATgU544qMBwAw==$0 TABLE
T1 TABLE
T2 TABLE
TEST TABLE SQL> drop table test; Table dropped. SQL> select * from cat; TABLE_NAME TABLE_TYPE
------------------------------ -----------
BIN$QSRM4jesEATgU544qMBwAw==$0 TABLE
BIN$QaFQkzu4C/XgU544qMAz3Q==$0 TABLE
T1 TABLE
T2 TABLE SQL> purge user_recyclebin; Recyclebin purged. SQL> select * from cat; TABLE_NAME TABLE_TYPE
------------------------------ -----------
T1 TABLE
T2 TABLE

五、备库还原为physical standby

5.1 备库还原为physical standby

参数值确定:

--确定db_recovery_file_dest值及其大小
--选择取消db_recovery_file_dest参数值及其大小的设定
alter system reset db_recovery_file_dest_size sid='*' scope=spfile;
alter system reset db_recovery_file_dest sid='*' scope=spfile; --或者选择设置db_recovery_file_dest参数值及其大小为合理值
alter system set db_recovery_file_dest='/u01/app/oracle/fra' sid='*' scope=spfile;
alter system set db_recovery_file_dest_size=4407M sid='*' scope=spfile;

核心步骤:

--重启数据库至mount状态
SQL> shutdown immediate
SQL> startup mount
--切换数据库到physical standby
SQL> alter database convert to physical standby;
--重启数据库
SQL> shutdown immediate
SQL> startup
--查看当前数据库的scn
select current_scn||'' from v$database
--开启日志应用
alter database recover managed standby database using current logfile disconnect;
--确定job_queue_processes值
alter system set job_queue_processes=1000;
--查看standby的进程和状态
select process, status from v$managed_standby;
select database_role, open_mode from v$database;

验证备库的状态信息:

--format
set linesize 120
col NAME for a25
col VALUE for a18
col UNIT for a30
col TIME_COMPUTED for a20
col DATUM_TIME for a20
--select v$dataguard_stats
select * from v$dataguard_stats; --确定闪回数据库是否开启
SQL> select flashback_on from v$database; FLASHBACK_ON
------------------
NO

5.2 验证数据还原到切换前状态

--确定snapshot standby期间的所有操作都是回退的;
SQL> conn jingyu/jingyu
Connected.
SQL> select * from cat; TABLE_NAME TABLE_TYPE
------------------------------ -----------
BIN$QSRM4jesEATgU544qMBwAw==$0 TABLE
T1 TABLE
T2 TABLE
TEST TABLE

实验证明: 11g snapshot standby的确可以很方便的实现读写测试;之后也可以方便的切换回测试前的状态继续做为physical standby使用。

ORACLE 11gR2 DG(Physical Standby)日常维护02的更多相关文章

  1. ORACLE 11gR2 DG(Physical Standby)日常维护01

    环境:RHEL 6.4 + Oracle 11.2.0.4 一.主备手工切换 1.1 主库,切换成备库并启动到mount 1.2 备库,切换成主库并启动到open 1.3 新的备库启动日志应用 二.重 ...

  2. DG - physical standby switchover切换过程

    一.切换前检查1.检查备库已经全部接收到主库的redo如果是最大可用性.最大保护性模式,可以在primary端查看v$archive_dest_status,确认是否所有的redo已经传送到备库#在主 ...

  3. [Oracle] 临时将Physical Standby激活

    Oracle 10g/11g下如何将物理Standby库临时激活用于测试 在实际运营环境中, 我们经常碰到类似这样的需求: 譬如想不影响现网业务评估DB补丁在现网环境中运行的时间, 或者是想在做DB切 ...

  4. DG - physical standby failover切换过程

    1.failover前检查 #如果有多个standby数据库,查看哪个standby接收的redo最新. SQL> select * from v$archive_dest_status: #查 ...

  5. Oracle 11g DG配置简明版

    环境: 主库A机:在线生产环境,RHEL 6.4 + Oracle 11.2.0.3 备库B机:新增备机,RHEL 6.4 需求: 对生产环境最小影响前提下配置DG备库. 目录: 一.B机安装相同版本 ...

  6. 聊聊Oracle 11g的Snapshot Standby Database(上)

    Oracle 11g是Data Guard的重要里程碑版本.在11g中,Active DataGuard.Advanced Compression等特性大大丰富了Data Guard的功能和在实践领域 ...

  7. ORACLE Physical Standby DG 之switch over

    DG架构图如下: 计划,切换之后的架构图: DG切换: 主备切换:这里所有的数据库数据文件.日志文件的路径是一致的 [旧主库]主库primarydb切换为备库standby3主库检查switchove ...

  8. ORACLE Physical Standby DG 之fail over

    SQL> select thread#, low_sequence#, high_sequence# from v$archive_gap;确认下是否存在日志间隙,发现gap现象,说明failo ...

  9. oracle 容灾库日常维护 ,健康检查脚本 以及常见问题分析

    select DEST_ID, APPLIED_SCN FROM v$archive_dest select * from v$dataguard_status; SELECT gvi.thread# ...

随机推荐

  1. Database Replay和Consolidated Database replay

    简介 在数据库的迁移和升级场景中,我们经常会遇到一个问题:在做压力测试时,如何模拟真实的业务压力,解决这个问题的方法有很多,比如:应用方开发模拟程序或者使用压力测试工具模拟,如load runner, ...

  2. webapi - 使用依赖注入

    本篇将要和大家分享的是webapi中如何使用依赖注入,依赖注入这个东西在接口中常用,实际工作中也用的比较频繁,因此这里分享两种在api中依赖注入的方式Ninject和Unity:由于快过年这段时间打算 ...

  3. 如何在网页中提取Email地址

    开博好久了,今天第一次发表技术文档,之前总是将一些好的事例保存在电脑,时间久了找起来也很麻烦,所以还是放在博客里进行归类比较方便,这样也能将自己在学习过程中的一些心得体会分享给大家,也能给需要的人一点 ...

  4. c#语言规范

    0x00 分类 C#语言规范主要有两个来源,即我们熟知的ECMA规范和微软的规范.尽管C#的ECMA规范已经前后修订4次,但其内容仅仅到C# 2.0为止.所以慕容为了方便自己和各位方便查询,在此将常见 ...

  5. Tomcat启动报错org.springframework.web.context.ContextLoaderListener类配置错误——SHH框架

    SHH框架工程,Tomcat启动报错org.springframework.web.context.ContextLoaderListener类配置错误 1.查看配置文件web.xml中是否配置.or ...

  6. 简历生成平台项目开发-STEP1问卷设计

    周五课程结束完后,小组建立QQ群和微信群,着手讨论项目问题.一开始的大概想法:就业信息平台,收集企业招聘信息和就业生资料,提供给学生和企业的校企对接平台.后来发现群里谭卓同学也有个相关的思路,经过商量 ...

  7. JQuery阻止事件冒泡

    冒泡事件就是点击子节点,会向上触发父节点,祖先节点的点击事件. 我们在平时的开发过程中,肯定会遇到在一个div(这个div可以是元素)包裹一个div的情况,但是呢,在这两个div上都添加了事件,如果点 ...

  8. 札记:Java异常处理

    异常概述 程序在运行中总会面临一些"意外"情况,良好的代码需要对它们进行预防和处理.大致来说,这些意外情况分三类: 交互输入 用户以非预期的方式使用程序,比如非法输入,不正当的操作 ...

  9. Linux下部署ASP.NET服务连接oracle遇到的问题记录

    一.如何卸载MONO Q:mono是linux系统上跨平台软件,卸载它有两种方式: 1.知道mono安装路径,安装原来的路径直接覆盖安装(最为简单): 2.不知道mono安装路径,首先通过sudo f ...

  10. mono-3.4.0 源码安装时出现的问题 [do-install] Error 2 [install-pcl-targets] Error 1 解决方法

    Mono 3.4修复了很多bug,继续加强稳定性和性能(其实Mono 3.2.8 已经很稳定,性能也很好了),但是从http://download.mono-project.com/sources/m ...