【Oracle】Installing and Using Standby Statspack in 11g

Statspack/AWR cannot be executed on a standby due to its read-only nature. Therefore tuning the performance of the apply process involves manually collecting statistics.

In 11gR1, using the new Active Data Guard option, users can now use statspack from the primary database to collect data from a standby database that is opened read-only and performing recovery.  

The standby statspack is installed in a separate schema on the Primary database, STDBYPERF which is then propagated to the standby. 

This new user does not have DBA privileges and has no access to local V$ tables.

大致意思由于standby 库是只读的,我们不能直接在standby 库上或者AWR/SP 报告。在11gR1中可以通过使用Active Data Guard特性,我们可以通过主库来获取standby库的信息!备库的sp 是安装在主库的STDBYPERF下的。而这个用户没有dba 权限也不能访问本地的 v$ 表

本文仅仅适用于11g 以上的版本!

创建步骤:下面的所有步骤都是在primary 库上执行的!

Installing and Using Standby Statspack in 11g

1. Standby Statspack 的用法

1.1 Statspack 安装

The perfstat schema and statspack related objects must be present on the primary and standby prior to installing standby statspack.  The standby statspack installation script. (sbcreate.sql) creates the standby statspack schema to hold the standby snapshots. The script. asks for:

A password for stdbyperf user

Default tablespace

Temporary tablespace

The script. creates the ‘stdbyperf’ user and assigns it the selected default and temporary table space. After the user has been created it calls sbaddins.sql to add the first standby instance to the configuration.

Example:

SQL> @sbcreate

1.2添加standby 的实例到 Statspack Configuration

Log in to the primary as the 'stdbyperf' user and run the script. sbaddins.sql to add a standby instance to the configuration. The script. asks for:

The TNS alias of the standby database instance

The password of the perfstat user on the standby site。The script. then creates a private database link to the perfstat schema on the standby site and a separate gathering package for each standby instance. Example:

SQL> connect stdbyperf/your_password

SQL> @sbaddins

Input inst2_alias as the tns alias.

1.3 收集 Standby Instance的性能统计数据。

The script. sbaddins.sql creates a separate PL SQL package for each standby instance. Run the snap procedure of those packages to collect the performance data. The statspack_.snap procedure accesses the data dictionary and stats$ views on the standby database via database link connected to the original perfstat user und stores the data to stats$ tables on the primary instance. For example, while the standby is opened read only, login to the primary database and create the snap:

SQL> connect stdbyperf/your_password

SQL> exec statspack_.snap

1.4 生成 Standby Statistics 报告

The script. sbreport.sql generates the standby statistics report. The script. asks for: database id, instance number, high and low snapshots id to create the report. Example:

SQL>@sbreport

1.5 删除快照集

The script. sbpurge.sql purges a set of snapshots. The script. asks for database id, instance number, low and high snapshots ids. The script. purges all snapshots between the low and high snapshot ids for the given instance. Example:

SQL>@sbpurge

1.6 从配置中删除一个实例 

The script. sbdelins.sql deletes an instance from the configuration, and deletes the associated PL SQL package. The scripts asks for instance name. The snapshots are not automatically purged when the instance is deleted. After deleting the instance, you are not able to generate reports for that instance. Example:

SQL> @sbdelins

1.7 删除 Statspack 模式

The script. sbdrop.sql drops the stdbyperf user and tables. The script. must be run when connected to SYS (or internal). Example:

SQL> connect / as sysdba

SQL> @sbdrop

2. New Statistics Collected

Two new sections are added to standby statspack report: 

(1) Recovery Progress Stats

(2) Managed Standby Stats. 

An example is provided below.

Recovery Progress Stats DB/Inst: MADISON/madison1 End Snap: 2

-> End Snapshot Time: 20-Jun-07 13:59:29

-> ordered by Item, Recovery Start Time desc

Recovery Start Time Item Sofar Units Redo Timestamp

------------------- ----------------- -------------- ------- ------------------

08-Jun-07 11:58:15 Active Apply Rate 8,420 KB/sec

08-Jun-07 11:58:15 Active Time 4,291 Seconds

08-Jun-07 11:58:15 Apply Time per Lo 267 Seconds

08-Jun-07 11:58:15 Average Apply Rat 3 KB/sec

08-Jun-07 11:57:15 Average Apply Rat 955 KB/sec

08-Jun-07 11:58:15 Checkpoint Time p 0 Seconds

08-Jun-07 11:58:15 Elapsed Time 1,044,073 Seconds

08-Jun-07 11:57:15 Elapsed Time 6 Seconds

08-Jun-07 11:58:15 Last Applied Redo 15,273,580 SCN+Tim 20-Jun-07 13:59:29

08-Jun-07 11:57:15 Last Applied Redo 13,945,701 SCN+Tim 08-Jun-07 11:56:16

08-Jun-07 11:58:15 Log Files 16 Files

08-Jun-07 11:57:15 Log Files 33 Files

08-Jun-07 11:58:15 Redo Applied 3,181 Megabyt

08-Jun-07 11:57:15 Redo Applied 6 Megabyt

-------------------------------------------------------------

Managed Standby Stats DB/Inst: MADISON/madison1 End Snap: 2

-> End Snapshot Time: 20-Jun-07 13:59:29

-> ordered by Process

Process pid Status Resetlog Id Thread Seq Block Num

----------- ---------- ------------ ----------- ------ ------- -----------

Client Proc Client pid Blocks Delay(mins)

----------- ---------- -------------- --------------

ARCH 29360 CLOSING 624693241 2 59 18433

ARCH 29360 340 0

ARCH 29358 CLOSING 624693241 1 57 94209

ARCH 29358 1,596 0

ARCH 29356 CLOSING 624693241 1 56 903169

ARCH 29356 1,835 0

ARCH 29354 CLOSING 624693241 2 61 919553

ARCH 29354 770 0

MRP0 30839 APPLYING_LOG 624693241 2 62 57

N/A N/A 2,097,152 0

RFS 28886 IDLE 0 0 0 0

N/A 16388 0 0

RFS 28875 IDLE 624693241 2 62 2164

LGWR 16137 432 0

RFS 30192 IDLE 624693241 1 58 51

LGWR 2092 1 0

RFS 28892 IDLE 0 0 0 0

UNKNOWN 16384 0 0

RFS 30326 IDLE 0 0 0 0

N/A 2268 0 0

-------------------------------------------------------------

3. List of New Scripts and Short Descriptions

sbcreate.sql - Install standby statspack

sbcusr.sql - Called from sbcreate.sql to create the schema

sbctab.sql - Called from sbcreate.sql to create tables holding snapshots

sbaddins.sql - Called from sbcreate.sql to add a standby database instance to the configuration.

sbaddins.sql - Add a standby database instance to the configuration

sbcpkg.sql - Called from sbaddins.sql to create the instance specific statspack package

sblisins.sql - List instances in the standby statspack configuration

sbreport.sql - Create a standby statistics report

sbrepcon.sql - Called from sbreport.sql to get the report configuration

sbrepins.sql - Called from sbreport.sql to create the actual report

sbpurge.sql - Purge a set of snapshots identified by low and high snapshot ids

sbdelins.sql - Delete an instance from the standby statspack configuration

sbdrop.sql - Drop the stdbyoperf user and tables of the standby statspack

sbdtab.sql - Called from sbdrop.sql to drop tables

sbdusr.sql - Called from sbdrop.sql to drop user, must run from an account that connects to internal (SYS)

MOS DOC [ID 454848.1]

时间: 2025-01-20 10:06:26

【Oracle】Installing and Using Standby Statspack in 11g的相关文章

【oracle】静默安装 oracle 11gr2

[序言] oracle 提供了静默安装方法在不适用图形界面的情况下安装 oracle 软件 ,创建db,配置netca,快速完成oracle 的部署.  在以下情形中可以使用静默安装    a OUI 的 GUI 界面远程交互比较慢 .    b 数据库服务器无法使用图形界面访问.    c 批量部署oracle (标准环境统一情况下可以使用oracle 的relink ,这样更加快速). 本文主要讲述基本安装步骤,不涉及oracle 安装完成之后的运维规范: 监控,备份,定时日志清理,基础运维

【ORACLE】relink oracle 10g 数据库

通常要迁移一个数据库,我们会使用 1 冷备份,整个数据库迁移, 2 rman duplicate 功能进行复制到本机或者复制到异机, 前面两种都必须先在目标库上安装软件.这里测试另外一种方法:对于单实例数据库,复制整个oracle 10g 数据库到另一个服务器,relink 之后可以重新使用.. 查看源库数据库库文件在$ORACLE_BASE 目录下的分布: oracle@yangDB1:/opt/oracle>ll 总计 36 drwxrwx--- 3 oracle oinstall 4096

【Oracle】Oracle 11gR2发布11.2.0.3 Patchset补丁集

11.2.0.3 Patch Set - Availability and Known Issues [ID 1348336.1]   修改时间 07-MAR-2012     类型 README     状态 PUBLISHED     Known Issues specific to the 11.2.0.3 Patch Set Please note that 11.2 Patch Sets 11.2.0.2 and higher are supplied as full releases

【oracle】静默安装oracle软件和数据库之一

oracle 的静默安装可以在无交互模式安装数据库,适合没有图形界面的情况下进行oracle 数据库软件的安装和数据库创建,netca 的配置. 本文对静默安装数据库软件进行技术介绍.执行静默安装需要一个响应文件oracle根据响应文件来进行默认安装. 静默安装的企业级版本的响应文件: ee.rsp RESPONSEFILE_VERSION=2.2.1.0.0 UNIX_GROUP_NAME="oinstall" FROM_LOCATION="/home/oracle/dat

【Oracle】安装10.2.0.1 遇到的问题。

安装oracle 10.2.0.1 for x86--64位的过程中遇到了如下错误: INFO: /usr/bin/ld: crt1.o: No such file: No such file or directory INFO: collect2: ld returned 1 exit status INFO: End output from spawned process. INFO: ---------------------------------- INFO: Exception th

【Oracle】RMAN-03009 ORA-01400 错误解决方法

  生产库备份遇到ORA-01400 错误~当rman 不使用 catalog时,RMAN 命令可以正常实施~!当rman 备份使用catalog数据库时,执行rman 命令总是报错:ORA-01400:cannot insert NULL into ("RMAN_YANGDB"."RLH"."LOW_TIME") RMAN> resync catalog; starting full resync of recovery catalog

【DataGuarad】逻辑迁移与standby备库

standby 库不支持expdp,可以使用exp代替 oracle@rac3:/home/oracle>expdp yang/yang directory=dump dumpfile=yang.dmp tables=yang                      Export: Release 11.2.0.1.0 - Production on Tue Sep 20 19:46:42 2011 Copyright (c) 1982, 2009, Oracle and/or its aff

【Oracle】lsnrctl reload 命令简介

oracle 提供了lsnrctl reload 命令,在下面两种情况 1 修改listener.ora 2 修改sqlnet.ora 之后又不想停止监听,可以考虑lsnrctl reload命令! reload命令会重新读取listener.ora的内容,这个命令让用户不停止监听器的情况下,改变监听器的配置.但是对于sqlnet.ora的修改考虑一下情况: 1 如果之前sqlnet.ora没有被当前的监听器使用,这时必须关闭然后重启监听! 2 如果之前正在使用sqlnet.ora,那么lsnr

【Oracle】单表的选择率

  本文只是记录<基于成本的oracle 优化法则>的简单的笔记(因为要重新搭建RAC 把之前的环境删掉了,oracle 环境还没建好,现在先纸上谈兵一下 ) 优化器并没有智能--只是一个软件! 1 对含有空值的字段  基本选择率=1/num_distinct num_nulls=120 num_rows=1200 选择率=基本选择率*(num_rows-num_nulls)/num_rows=1/12*((1200-120)/1200)=0.075 调整后的基数=1200*0.075=90