Wednesday, April 22, 2020

EM agent start fails With 'java.lang.OutOfMemoryError'


I will show how to solve EM Agent failing to startup related to java memory problems.

Suddenly i found my agent is not starting with error Failed. So now its time to find issue and need to fix.

I have checked multiple logfiles but found this error in emagent.nohup, there was an error related to java memory:


It was an "Out of Memory Exception". To solve it, I had to increase the java heap space allocated to emagent.

(Reference Oracle Doc Id- 1399201.1)

Edit '$AGENT_BASE/agent_inst/sysman/config/emd.properties' and increase the memory allocated to 512M.

Before-

cat emd.properties | grep agentJavaDefines

agentJavaDefines=-Xmx128M -XX:MaxPermSize=96M

After-

cat emd.properties | grep agentJavaDefines
agentJavaDefines=-Xmx512M -XX:MaxPermSize=96M

Now Try to restart agent using "emctl start agent".

emctl start agent
Oracle Enterprise Manager Cloud Control 12c Release 5
Copyright (c) 1996, 2015 Oracle Corporation.  All rights reserved.
Starting agent ..................... started.

 if you still face any issues, you will need to clear the agent state and retry.
Do the following:
  1. Stop and kill any remaining process related to EM Agent that is still running (perl or java).
  2. Clean all files from '$AGENT_BASE/agent_inst/sysman/emd/state/*' folder (or move them to a temporary place).
  3. Clear agent state by running: emctl clearstate agent.
  4. Increase the memory allocated editing emd.properties, as showed before, if not already done.
  5. Try to start the agent again.










Monday, March 30, 2020

Redo and Undo Generation 


To find sessions generating lots of redo, you can use either of the following 
methods. Both methods examine the amount of undo generated. When a transaction 
generates undo, it will automatically generate redo as well.

The methods are:
1) Query V$SESS_IO. This view contains the column BLOCK_CHANGES which indicates
   how much blocks have been changed by the session. High values indicate a 
   session generating lots of redo.

   The query you can use is:

       SQL> SELECT s.sid, s.serial#, s.username, s.program,
         2  i.block_changes
         3  FROM v$session s, v$sess_io i
         4  WHERE s.sid = i.sid
         5  ORDER BY 5 desc, 1, 2, 3, 4;

Run the query multiple times and examine the delta between each occurrence
   of BLOCK_CHANGES. Large deltas indicate high redo generation by the session.

2) Query V$TRANSACTION. This view contains information about the amount of
   undo blocks and undo records accessed by the transaction (as found in the 
   USED_UBLK and USED_UREC columns).

  The query you can use is:

      SQL> SELECT s.sid, s.serial#, s.username, s.program, 
        2  t.used_ublk, t.used_urec
        3  FROM v$session s, v$transaction t
        4  WHERE s.taddr = t.addr
        5  ORDER BY 5 desc, 6 desc, 1, 2, 3, 4;

   Run the query multiple times and examine the delta between each occurrence
   of USED_UBLK and USED_UREC. Large deltas indicate high redo generation by 
   the session.

You use the first query when you need to check for programs generating lots of 
redo when these programs activate more than one transaction. The latter query 
can be used to find out which particular transactions are generating redo.


Friday, March 27, 2020

Unregistered Database From RMAN Catalog


If we need to unregister database from recovery catalog so we have two option-

1> Need to connect from target server and using RMAN easily we can unregister.

2> Suppose in a case if we dont have database(someone dropped) and we need to clear this from             rman catalog server then


Sol-

Connect to rman catalog server, then connect to rman user or whatever is catalog user we have then do needful as below.

SQL>  Conn rman/rman

       Below is the query by which we will get command which we need to execute, so we need to    pass DB_NAME in my case DB_NAME is TEST.

SQL> select 'EXECUTE dbms_rcvcat.unregisterdatabase('||db_key||','||dbid||');' FROM                           rc_database WHERE name in('TEST') ;


SQL> 'EXECUTEDBMS_RCVCAT.UNREGISTERDATABASE('||DB_KEY||','||DBID||');'
--------------------------------------------------------------------------------
EXECUTE dbms_rcvcat.unregisterdatabase(36631376,3102016920);

SQL> select db_key,DBID,NAME from rc_database where name='TEST';

    DB_KEY       DBID NAME
---------- ---------- --------
  36631376 3102016920 TEST

SQL>EXECUTE dbms_rcvcat.unregisterdatabase(36631376,3102016920);

PL/SQL procedure successfully completed.