HowTo Rescan databases for the Grid Control Agent

If you create a new database, listener, etc. on a machine that has an existing Grid Control Agent on it, you may need to tell the agent to “rescan” the system to pick up the new database (to have the DB show up in OEM).

Set your agent home

AGENT_HOME=/opt/app/oracle/agent10g

Make sure $AGENT_HOME/bin is in your PATH
Run the agentca with the reconfigure option. (you may need to specify a –c for RACs)

vexbert<11> agentca -h
Usage: agentca -d/-f [-nctis]
        -d  option for rediscovery.
        -f  option for reconfigure.
        -n  to specify the CLUSTER_NAME.
        -c  specify the list of cluster nodes separated by commas
        -t  don't start the agent after rediscover or reconfigure.
        -i  oraInst.loc location on Unix/Linux Platforms only.
        -s secure the Agent during RAC/Cluster Agent reconfiguration
         (Don't use this option in upgraded home).

vexbert<11> agentca –f

Note: you may need to clean up duplicates in your OEM after running this on an existing system.

HowTo Find info about Shared memory allocation

Sometimes you may see core dumps, etc related to lack of shared memory.
To check to see how much is currently being used you can use the below command:

vexbert<10> ipcs -bm
IPC status from  as of Thu Oct 30 10:42:06 PDT 2008
T         ID      KEY        MODE        OWNER    GROUP      SEGSZ
Shared Memory:
m 1493172237   0x32d14fb8 --rw-r-----   oracle      dba 2097160192
m 1979711547   0x5e000b64 --rw-------     root     root        512
m  721420366   0xe867eba0 --rw-r-----   oracle      dba 2147491840
m         25   0x67e97344 --rw-r-----   oracle      dba  419438592
m         21   0xc4986724 --rw-rw----   oracle      dba  629153792
m         19   0x71e930c0 --rw-rw----   oracle      dba 1073758208
m          7   0x4154520e --rw-rw-rw-     root   tivoli    1048576
m          6   0x4154520a --rw-rw-rw-   tivoli   tivoli    1048576
m          5   0x4154520d --rw-rw-rw-   tivoli   tivoli    1048576
m          4   0x4154520c --rw-rw-rw-   tivoli   tivoli    1048576
m          3   0x4154520f --rw-rw-rw-   tivoli   tivoli    1048576
m          2   0x4154520b --rw-rw-rw-   tivoli   tivoli     524288
m          1   0x41545200 --rw-rw-rw-   tivoli   tivoli    1048576
m          0   0          --rw-------     root     root         64

The Oracle/DBA segments are related to Oracle database instances.
The SEGSZ is limited by the Unix kernel.

Gracefully bring down an Oracle RAC cluster

  • Stop the databases on all nodes
  • Run the following command to bring down the oracle CRS
    • sudo /etc/init.d/init.crs stop


sudo /etc/init.d/init.crs stop
Shutting down Oracle Cluster Ready Services (CRS):
Stopping resources. This could take several minutes.
Successfully stopped CRS resources.
Stopping CSSD.
Shutting down CSS daemon.
Shutdown request successfully issued.
Shutdown has begun. The daemons should exit soon.

There is a bug in 10g where, on reboot when CRS auto-starts a database, the database will be in a “hung” state.

The only way to solve this is to:

  • Kill the pmon process (to hard crash the database on all nodes).
  • Restart the databases manually (one at a time)

To avoid this, remove the DBs from the oratab before reboots on a cluster/RAC DB.

Generate a nice looking Explain Plan from sqlplus

In SQL as the user run:

SQL> explain plan for
SELECT DISTINCT consumer_id "consumerId", c.first_name "firstName", 
c.last_name "lastName", c.date_of_birth "dateOfBirth", c.case_id "caseId", 
cd.individual_id "individualId", cs.family_account_id "familyAccountId"
FROM consumer c, child_detail cd, case cs, address a
WHERE rownum  = 500 AND c.child_detail_id = cd.child_detail_id (+) AND 
cs.case_id = c.case_id AND (cs.home_address_id = a.address_id OR
cs.mailing_address_id = a.address_id) AND cs.family_account_id = :1 AND 
a.state_id = :2 ORDER BY UPPER(last_name), UPPER(first_name);
Explained.

SQL> select * from table(dbms_xplan.display());
Plan hash value: 2032295181
----------------------------------------------------------------------------------------------------------------
| Id  | Operation                              | Name                  | Rows  | Bytes | Cost (%CPU)| Time     |
----------------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT                       |                       |     4 |   352 |    27   (8)| 00:00:01 |
|   1 |  SORT ORDER BY                         |                       |     4 |   352 |    27   (8)| 00:00:01 |
|   2 |   HASH UNIQUE                          |                       |     4 |   352 |    26   (4)| 00:00:01 |
|*  3 |    COUNT STOPKEY                       |                       |       |       |            |          |
|   4 |     NESTED LOOPS OUTER                 |                       |     4 |   352 |    25   (0)| 00:00:01 |
|   5 |      NESTED LOOPS                      |                       |     4 |   284 |    19   (0)| 00:00:01 |
|   6 |       NESTED LOOPS                     |                       |     1 |    32 |    15   (0)| 00:00:01 |
|   7 |        TABLE ACCESS BY INDEX ROWID     | CASE                  |     1 |    23 |     3   (0)| 00:00:01 |
|*  8 |         INDEX UNIQUE SCAN              | IDX_FAMILY_ACCOUNT_ID |     1 |       |     2   (0)| 00:00:01 |
|*  9 |        TABLE ACCESS BY INDEX ROWID     | ADDRESS               |     1 |     9 |    15   (0)| 00:00:01 |
|  10 |         BITMAP CONVERSION TO ROWIDS    |                       |       |       |            |          |
|  11 |          BITMAP OR                     |                       |       |       |            |          |
|  12 |           BITMAP CONVERSION FROM ROWIDS|                       |       |       |            |          |
|* 13 |            INDEX RANGE SCAN            | XPK_ADDRESS_ID        | 79044 |       |     1   (0)| 00:00:01 |
|  14 |           BITMAP CONVERSION FROM ROWIDS|                       |       |       |            |          |
|* 15 |            INDEX RANGE SCAN            | XPK_ADDRESS_ID        | 79044 |       |     1   (0)| 00:00:01 |
|  16 |       TABLE ACCESS BY INDEX ROWID      | CONSUMER              |     3 |   117 |     4   (0)| 00:00:01 |
|* 17 |        INDEX RANGE SCAN                | CONSUMER_CASE_ID_IDX  |     3 |       |     2   (0)| 00:00:01 |
|  18 |      TABLE ACCESS BY INDEX ROWID       | CHILD_DETAIL          |     1 |    17 |     2   (0)| 00:00:01 |
|* 19 |       INDEX UNIQUE SCAN                | XPK_CHILD_DETAIL_ID   |     1 |       |     1   (0)| 00:00:01 |
----------------------------------------------------------------------------------------------------------------

Getting the full query with Oracle Statspack (9i)

Oracle statspack is essential if you're trying to track down a performance problem. However, one problem I came across is that the top summary report you get from spreport is only a partial query. This makes it tough for developers to track down exactly where in the code the bad query lives - Especially if they have a lot of similar queries with just a few changes in the where clause.

SQL> @?/rdbms/admin/spreport
                                                     CPU      Elapsd
  Buffer Gets    Executions  Gets per Exec  %Total Time (s)  Time (s) Hash Value
--------------- ------------ -------------- ------ -------- --------- ----------
     42,659,654           31    1,376,117.9   27.0   743.40   1621.51 2018450324

Doesn't leave you with the full query in most cases, just the first 5 lines or so.
Something like this

     27,611,489          142      194,447.1    1.8   450.19    711.84 2018450324
Module: PIPE)@BaanCA (TNS V1-V3)
SELECT /*+FIRST_ROWS INDEX_ASC(a ttfgld418200$idx1)*/ a.t$cprj,a
.t$docn,a.t$fcom,a.t$fitr,a.t$line,a.t$lino,a.t$ocom,a.t$orno,a.
t$pono,a.t$prin,a.t$sern,a.t$sint,a.t$tmpk,a.t$trdt,a.t$tror,a.t
$trtm,a.t$ttyp,b.t$amnt,b.t$amth,b.t$btno,b.t$ccty,b.t$ccur,b.t$
cpcp,b.t$cprj,b.t$crdt,b.t$crtm,b.t$crus,b.t$cuni,b.t$cuno,b.t$c

So what you'd need to do to get the entire query is to first note the "Hash Value" from
your spreport

SQL> @?/rdbms/admin/sprepsql
Specify the Begin and End Snapshot Ids
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Enter value for begin_snap: 28631
Begin Snapshot Id specified: 28631

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

Specify the Hash Value
~~~~~~~~~~~~~~~~~~~~~~
Enter value for hash_value: 2018450324
Hash Value specified is: 2018450324

The result will all of the lines of the query and some nice info about it.

SQL Statistics
~~~~~~~~~~~~~~
-> CPU and Elapsed Time are in seconds (s) for Statement Total and in
   milliseconds (ms) for Per Execute
                                                       % Snap
                     Statement Total      Per Execute   Total
                     ---------------  ---------------  ------
        Buffer Gets:      27,611,489        194,447.1    1.83
         Disk Reads:       4,007,081         28,218.9    6.01
     Rows processed:          77,378            544.9
     CPU Time(s/ms):             450          3,170.3
 Elapsed Time(s/ms):             712          5,012.9
              Sorts:             142              1.0
        Parse Calls:               4               .0
      Invalidations:               0
      Version count:               1
    Sharable Mem(K):             143
         Executions:             142

SQL Text
~~~~~~~~
SELECT /*+FIRST_ROWS INDEX_ASC(a ttfgld418200$idx1)*/ a.t$cprj,a
.t$docn,a.t$fcom,a.t$fitr,a.t$line,a.t$lino,a.t$ocom,a.t$orno,a.
t$pono,a.t$prin,a.t$sern,a.t$sint,a.t$tmpk,a.t$trdt,a.t$tror,a.t
$trtm,a.t$ttyp,b.t$amnt,b.t$amth,b.t$btno,b.t$ccty,b.t$ccur,b.t$
cpcp,b.t$cprj,b.t$crdt,b.t$crtm,b.t$crus,b.t$cuni,b.t$cuno,b.t$c
vat,b.t$cwar,b.t$dbcr,b.t$dcdt,b.t$dim1,b.t$dim2,b.t$dim3,b.t$di
m4,b.t$dim5,b.t$docn,b.t$fact,b.t$fcom,b.t$fitr,b.t$fprd,b.t$fye
r,b.t$inpo,b.t$item,b.t$leac,b.t$line,b.t$lino,b.t$nper,b.t$nuni
,b.t$ocom,b.t$orno,b.t$podt,b.t$pono,b.t$potm,b.t$pous,b.t$qty1,
b.t$qty2,b.t$rate,b.t$refr,b.t$rprd,b.t$ryer,b.t$sern,b.t$sint,b
.t$srno,b.t$suno,b.t$tmpk,b.t$trdt,b.t$tror,b.t$trtm,b.t$tsls,b.
t$ttyp,b.t$vamh,b.t$vamt,b.t$vprd,b.t$vtyp,b.t$vyer,c.t$dsca,c.t
$dscb,c.t$psts,c.t$sdat,c.t$ddat,c.t$cuno,c.t$cprj,c.t$intp,d.t$
ttyp,d.t$desc,e.t$leac,f.t$cpcp,f.t$dsca,g.t$nama FROM baan.ttfg
ld418200 a,baan.ttfgld410200 b,baan.ttipcs020200 c,baan.ttfgld01
1200 d,baan.ttfgld008200 e,baan.tticpr010200 f,baan.ttccom010200
 g WHERE ((b.t$podt >= :1) AND (b.t$podt <= :2)="" or="" (a.t$sint=":16)" a="" nd="" (((b.t$fyer="" *="" :5)="" +="" b.t$fprd)="" <=":7))" and="" (:8=":9" (:10=":11" a.t$sint=":3)" (:12=":13" (a.t$ttyp=":18)" (a.t$docn=":23" a.t$fitr="">= :24 AND a.t$tror <= :25="" and="" a.t$fitr=":28" a.t$="" tror="">= :29 AND a.t$orno >= :30 AND a.t$cprj <= :31="" and="" a.t$tror="" <="" a.t$orno=":34)" (b.t$btno=":36)" (b.t$cpcp=":38)" (b.t$leac=":40" not(b.t="" $crdt=":40" (b.t$crtm="" :41)))="" (b.t$crdt="" :43)))="" (c.t$psts="">= :44) 
AND (c.t$psts <= :45)="" order="" by="" 7,15,4,14,16,11,5="" 
			

About

Random Database, OS or otherwise interesting tips and tricks.

User


Clicky Web Analytics