Quantcast
Channel: Oracle DBA - RajaBaskar Blog
Viewing all articles
Browse latest Browse all 25

Standby Statspack Installation on oracle 11g database

$
0
0

Recently I triedgenerate the AWR report for particular timeframe on ACTIVE Data Guard database, ran the awrrpt.sql and it was failed. After that only I knew oracle doesn’t support the AWR/Statspack on active data guard database.
I have checked oracle metalink and they have suggested installing standby statspack for active data guard.
Lets see in this article ..

Active DataGuard Statspack Overview:

Oracle doesn’t support AWR and Statspack feature on active data guard database due to its read only nature. But the same time its supports STANDBY STATSPACK feature and a different set of scripts are required to install in primary database. 
How it’s internally work?

Using sbcreate.sql script, we have created standby statspack repository and STDBYPERF schema on primary database.
STDBYPERF schema having objects (tables, views and procedures)   looks like same as PERFSTAT schema and also having DB LINK between Primary and standby database.  While executing standby snapshot on primary database, this DB LINK fetching the performance data from standby database PERFSTAT schema to STDBYPERF schema. We can generate the standby statspack report on primary database itself.


http://1.bp.blogspot.com/-JPdc8OgvEmU/UAMBdeqekhI/AAAAAAAADLg/Q3SGTbWb8xA/s400/standby_statspack_arch.png


Standby Statspack Prerequisite:

1.       Normal Statspack must be installed on primary database.
2.       Create separate tablespace for both PERFSTAT and STDYBYPERF Schema’s.
3.       Check the GLOBAL_NAME init parameter value.
If GLOBAL_NAME=true, while creating the standby repository due to GLOBAL NAME issue sbcreate.sql script will fail.

To resolve this issue we need to set the GLOBAL_NAME value as false at session level.

Note: GLOBAL_NAME =false value should not be set at Instance level is not advisable.

Oracle Bug:

This one is oracle bug 11899453. This bug is fixed on 12.1

Temporary Solution:

We need to run the sbcreate.sql and sbaddins.sql scripts separately.  (Sbcreate.sql internally calling sbaddins.sql script... so metadata will not be fetched from the standby database to primary database via database link)

1.    sbcreate.sql script create the STDBYPERF user and its repository objects
2.    sbaddins.sql script add the standby instance standby statspack repository information on primary database and create the  private database link   between   primary(STDBYPERF) and DR(PERFSTAT) databases.
3.    Whenever we are taking standby statspack snap, this database link will copy the performance data from active data guard memory to standby Statspack repository.

4 4.       Add the standby TNSNAME entry in primary database server.

Installation Steps:

Normal Statspack installation steps: (Primary Database)
1.       Create separate tablespace PERFSTAT_DATA with 500 MB.
2.       Run the spcreate.sql script on primary database.

@?/rdbms/admin/spcreate.sql

  Enter the perfstat user password:perfstat
  Enter the default tablespace: perfstat_data
  Enter the temp tablespace: ESTT01

Standby Statspack installation steps: (Primary Database)

1      Run the spcreate.sql script on primary database.
@?/rdbms/admin/sbcreate.sql
Enter value for stdbyuser_password: STDBYPERF
Enter value for default_tablespace:PERFSTAT_DATA
Enter value for temporary_tablespace: TEMP
The following standby instances (TNS_NAME alias) have been configured
for data collection
…………………..
……………………….
=== END OF LIST ===


THE INSTANCE YOU ARE GOING TO ADD MUST BE ACCESSIBLE AND OPEN READ ONLY

Do you want to continue (y/n) ?
Enter value for key: n
begin
*
ERROR at line 1:
ORA-20101: Install failed - Aborted by user
ORA-06512: at line 3


Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options

2   Check the Global Parameter Value
SQL> conn / as sysdba
Connected.

SQL> show parameter global_names

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
global_names                         boolean     TRUE


3  Login as STDBYPERF user

SQL> conn stdbyperf
Enter password:
Connected.

To resolve this issue we need to set the GLOBAL_NAME value as false at session level.

SQL> alter session set global_names=false;

Session altered.

SQL> @?/rdbms/admin/sbaddins.sql

The following standby instances (TNS_NAME alias) have been configured
for data collection

=== END OF LIST ===


THE INSTANCE YOU ARE GOING TO ADD MUST BE ACCESSIBLE AND OPEN READ ONLY

Do you want to continue (y/n) ?
Enter value for key: y
You entered: y


Enter the TNS ALIAS that connects to the standby database instance
-----------------------------------------------------------------
Make sure the alias connects to only one instance (without load balancing).
Enter value for tns_alias: test_dr_AM_HOST
You entered: test_dr_AM_HOST


Enter the PERFSTAT user's password of the standby database
---------------------------------------------------------
Performance data will be fetched from the standby database via
database link. We will connect to user PERFSTAT.
Enter value for perfstat_password: perfstat
You entered: perfstat

... Creating database link

... Selecting database unique name

Database
------------------------------
test_dr_chn

... Selecting instance name

Instance
------------
test_dr1

... Creating package

Creating Package STATSPACK_test_dr_chn_test_dr1..
No errors.
Creating Package Body STATSPACK_test_dr_chn_test_dr1..
No errors.


Note: Using STATSPACK_test_dr_chn_test_dr1package, we are going to take the standby Statspack snap.

How to take standby snapshot manually?

Note: We should take standby statspack snap and report should be using STDBYPERF user.
If GLOBAL_NAMES=FALSE in instance level, we can set GLOBAL_NAMES=FALSE at session level

Login as STDBYPERF user

SQL> alter session set global_names=false;

Session altered.

SQL> execute STATSPACK_test_dr_chn_test_dr1.snap(10);

PL/SQL procedure successfully completed.


What happen if we take standby statspack snapshot other than STDBYPERF user?

Login as SYS user

SQL> alter session set global_names=false;

Session altered.

SQL> execute stdbyperf.STATSPACK_test_dr_chn_test_dr1.snap;
BEGIN stdbyperf.STATSPACK_test_dr_chn_test_dr1.snap; END;

*
ERROR at line 1:
ORA-02085: database link STDBY_LINK_TEST_DR_AM_HOST connects to TEST_DR
ORA-06512: at "STDBYPERF.STATSPACK_TEST_DR_CHN_TEST_DR1", line 59
ORA-06512: at "STDBYPERF.STATSPACK_TEST_DR_CHN_TEST_DR1", line 5445
ORA-06512: at line 1

After we have got above error, we didn’t take standby statspack snapshot. Let’s try now..

SQL> conn stdbyperf
Enter password:
Connected.

SQL> alter session set global_names=false;

Session altered.

SQL> execute STATSPACK_test_dr_chn_test_dr1.snap;
BEGIN STATSPACK_test_dr_chn_test_dr1.snap; END;

*
ERROR at line 1:
ORA-01400: cannot insert NULL into
("STDBYPERF"."STATS$STATSPACK_PARAMETER"."DB_UNIQUE_NAME")
ORA-06512: at "STDBYPERF.STATSPACK_TEST_DR_CHN_TEST_DR1", line 382
ORA-01403: no data found
ORA-06512: at "STDBYPERF.STATSPACK_TEST_DR_CHN_TEST_DR1", line 4127
ORA-06512: at "STDBYPERF.STATSPACK_TEST_DR_CHN_TEST_DR1", line 101
ORA-06512: at line 1


Conclusion:

If we are trying to take the snap other than stdbyperf user, some metadata’s were updated in standby repository table and mess up the standby repository. So we couldn’t take the standby snap and again we need to drop and recreate the standby statspack on primary database using sbdrop.sql and sbcreate.sql script.



How to generate the standby statspack report?

Login as STDBYPERF user only

SQL> @?/rdbms/admin/sbreport.sql

Instances in this Statspack schema
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

DB Unique Name                 Instance Name
------------------------------ ----------------
test_dr_chn                    test_dr1

Enter the DATABASE UNIQUE NAME of the standby database to report
Enter value for db_unique_name: test_dr_chn
You entered: test_dr_chn

Enter the INSTANCE NAME of the standby database instance to report
Enter value for inst_name: test_dr1
You entered: test_dr1


Specify the number of days of snapshots to choose from
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Entering the number of days (n) will result in the most recent
(n) days of snapshots being listed.  Pressing without
specifying a number lists all completed snapshots.



Listing all Completed Snapshots

                                          Snap
Instance       Snap Id   Snap Started    Level Comment
------------ --------- ----------------- ----- --------------------
test_dr1             1 06 Jul 2012 20:47    10
                     2 06 Jul 2012 21:16    10



Specify the Begin and End Snapshot Ids
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Enter value for begin_snap: 1
Begin Snapshot Id specified: 1

Enter value for end_snap: 2
End   Snapshot Id specified: 2


Specify the Report Name
~~~~~~~~~~~~~~~~~~~~~~~
The default report file name is sb_test_dr_chn_test_dr1_1_2.  To use this name,
press to continue, otherwise enter an alternative.

Enter value for report_name: sb_test_dr_chn_test_dr1_1_2.txt

Thanks !!!





Viewing all articles
Browse latest Browse all 25

Trending Articles