PoJokAndZs

Entries categorized as ‘Uncategorized’

Automate kill inactive user in oracle database

June 10, 2009 · Leave a Comment

Step by step to automatically kill inactive user in oracle database
To see inactive user in oracle database you can use this query “select * from v$session where status=’INACTIVE’ or user=’sys’”
1. Create procedure for killing inactive oracle database user (oracle user have to be grant dbms_sql to execute this procedure)
CREATE OR REPLACE PROCEDURE kill_session_1 ( session_id in varchar2,serial_num in varchar2)
AS
cur INTEGER;
ret INTEGER;
string VARCHAR2(100);
BEGIN

– Comment out the following three lines to
– not use KILL

string :=’ALTER SYSTEM KILL SESSION’ || CHR(10) ||CHR(39)||session_id||’,'||serial_num||CHR(39);

– Uncomment the following 4 lines to use DISCONNECT

–string := ‘ALTER SYSTEM DISCONNECT SESSION’ || CHR(10) || CHR(39)||session_id||’,'||serial_num||CHR(39)||CHR(10)||’ POST_TRANSACTION’;
cur := dbms_sql.open_cursor;
dbms_sql.parse(cur,string,dbms_sql.native);
ret := dbms_sql.execute(cur) ;
dbms_sql.close_cursor(cur);
END;
/
2. Create sql script ORA_KILL.sql for spooling command to execute procedure created (see no 1)
REM
REM ORA_KILL.SQL
REM FUNCTION: Kills nonessential Oracle sessions (those that aren’t
REM owned)
REM : by SYS or “NULL”
REM DEPENDENCIES: Depends on kill_session procedure
REM MRA 9/12/96
REM
SET HEADING OFF TERMOUT OFF VERIFY OFF ECHO OFF
SPOOL kill_all.sql
SELECT ‘EXECUTE kill_session_1(‘||chr(39)||sid||chr(39)||’,'||
chr(39)||serial#||chr(39)||’);’ FROM v$session
WHERE username = ‘ECARE2′ and status=’INACTIVE’
/
SPOOL OFF
START kill_all.sql

3. Create shell script to automate execute sql script using cronjob (for unix user)
sqlplus -s $schema/$pass@$dbLink as sysdba<<!
set timing on
@ORA_KILL

Categories: Uncategorized

RMAN setup using catalog database quick guide

June 10, 2009 · Leave a Comment

To setup RMAN using catalog database follow these steps :
1. Create user for catalog database repository in catalogue database
-Create tablespace for catalog database
sql>CREATE TABLESPACE RMAN_CAT
DATAFILE ‘RMAN_CAT’ SIZE 500 M
-Create user for catalog database
sql>create user rman_cat identified by rman_cat
temporary tablespace temp
default tablespace rman_cat
quota unlimited on rman_cat
-Grant appropriate privilege for user created
sql>grant recovery_catalog_owner,resource,create session to rman_cat
-Connect to recovery catalog using RMAN
$rman catalog rman_cat/rman_cat@rman_cat
RMAN>create catalog tablespace rman_cat
2. Connect to target database (Database to be backup) and catalog database using RMAN
-Connect using rman and register database
$rman target sys/pass@target catalog rman_cat/rman_cat@rman_cat
RMAN>register database;
-Check RMAN configuration
RMAN> Show all;
Command above will see RMAN configuration

Categories: Uncategorized

WE WILL NOT GO DOWN (Song for Gaza)

January 16, 2009 · 1 Comment

SONG DEDICATED TO PALESTINIAN

WE WILL NOT GO DOWN (Song for Gaza)

(Composed by Michael Heart)

Copyright 2009

A blinding flash of white light

Lit up the sky over Gaza tonight

People running for cover

Not knowing whether they’re dead or alive

They came with their tanks and their planes

With ravaging fiery flames

And nothing remains

Just a voice rising up in the smoky haze

We will not go down

In the night, without a fight

You can burn up our mosques and our homes and our schools

But our spirit will never die

We will not go down

In Gaza tonight Women and children alike

Murdered and massacred night after night

While the so-called leaders of countries afar

Debated on who’s wrong or right

But their powerless words were in vain

And the bombs fell down like acid rain

But through the tears and the blood and the pain

You can still hear that voice through the smoky haze

We will not go down

In the night, without a fight

You can burn up our mosques and our homes and our schools

But our spirit will never die

We will not go down

In Gaza tonight

Categories: Uncategorized
Tagged: , , ,

Happy New Year 1430 Hijriah and 2009

January 6, 2009 · Leave a Comment

Happy new year 1430 Hijriah and 2009…..

Hope we all will be better people in this very new year….. Amin….

Alhamdulillah for the things we got in 1429 Hijriah and 2008, bad things and good things is not coming for no reasons, but it gives us experiences, to strengthen us, to taught us to be the best person,  give our best for everything goods  and do not ever we lost tracks ( Follow Alquran and the prophet Muhammad ways)

And to my fellow Muslim Palestinian ..I am praying for you… Your victory will come…

Categories: Uncategorized

Oracle Database Monitoring For Beginner (The Simple Way)

August 27, 2008 · 1 Comment

  • Why Monitor Oracle Database
  • Database need to be monitored to check the performance of the monitored database, so we can change the database parameter based on result from monitoring and keep the database in it’s best performance.

    Database monitoring also needed so we always know the condition of database, and know the symptom of our database and we can take action right before more problem happens to database.

  • Types of Oracle Database Monitoring
  • Database Monitoring can be grouped into three types :

  • 1. Status monitoring
  • This monitoring type monitors current status of an events and give reports or alert when it exceeds a defined threshold

    Examples of Status Monitoring are, check tablespace where it’s about to fills up, check segment near their maximum extents.

  • 2. Performance monitoring
  • Monitors oracle instance memory (sga, buffer, etc), sql query running in database, session which consumes a lot of memory, etc.

    Examples of Performance monitoring are, query from v_$sqlarea to check what SQL has been running in our Oracle Machine, query from v$sgastat and query to get hit ratio for cache , library and buffer cache.

  • 3. Trend Analysis
  • Collects historical data on specific event that occur in database like SGA status, segment that cannot extends, filled up tablespace and make analysis from that historical data so that we can predict the status of SGA in any given time or we can now when the tablespace will filled up.

    Examples of Trend Analysis are, make a histroy table for events we monitored. We can make history table for tablespace so that from that history table we could gain information and make prediction when will the time the tablespace will be filled up. Or we can make history table from v_$session, so from that table we can know what time our database accessed by so many user.

    Next is the query to monitored database … soon…

    There are two ways to write error-free programs. Only the third one works.

     

     

Categories: IT TipZzz · Uncategorized