ORA-DB-ONE

fuser command to find out processes that hold references to the filesystem.

Posted in Linux by jackyoon on January 18, 2012

To find out which processes hold references to the filesystem, use fuser -cv option to print out processes with their commands.

$ fuser -cv /usr

USER PID ACCESS COMMAND
/usr root 283 ….m atd

root 839 ….m sshd

etc


Codes Meaning
f,o The process has a file open for reading or writing
c The process’s current directory is on the filesystem
e,t The process is currently executing a file.
r The process’s root directory(set with chroot) is on the filesystem.
m,s The process has mapped a file or shared library.

Using Oracle’s preinstalled perl DBD::Oracle library

Posted in Perl Scripts by jackyoon on December 21, 2011

Oracle started bundle perl DBD::Oracle with their software from version 10g. I used to install DBD::Oracle on each machine that I monitor oracle database through nagios but I started using preinstalled one and this is how you can do it.

The DBD::Oracle is located under ORACLE_HOME/perl/lib/site_perl//DBD. So, I set following two environment to use pre-installed library.

export PERL5LIB=$ORACLE_HOME/perl/lib/site_perl/5.10.0/x86_64-linux-thread-multi:$PERL5LIB
export PATH=$ORACLE_HOME/perl/bin:$PATH

In addition to that we also need to use perl executable under ORACLE_HOME. So, it is recommended to change your existing script to use the perl under your environment variable instead of fixed /usr/bin/perl.

#!/usr/bin/env perl

Last, if you are using nrpe and want to check oracle database the you have to put below three environment variables in side nrpe(/etc/init.d/nrpe) auto start script.

export ORACLE_HOME=/home/app/oracle/product/11g
export PERL5LIB=$ORACLE_HOME/perl/lib/site_perl/5.10.0/x86_64-linux-thread-multi:$PERL5LIB
export PATH=$ORACLE_HOME/perl/bin:$PATH

Verify perl library path

Posted in Perl Scripts by jackyoon on December 21, 2011

Sometimes, it is necessary to print list of library pathes in my environment. This will provide list of library pathes in order.

perl -e ‘foreach (@INC) { print $_,”\n” }’

/usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.8
/usr/lib/perl5/site_perl/5.8.5
/usr/lib/perl5/site_perl
/usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.8
/usr/lib/perl5/vendor_perl
/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi
/usr/lib/perl5/5.8.8

AWR – DB Report with dbms_workload_repository Package

Posted in AWR Report by jackyoon on November 8, 2011

* You can use dbms_workload_repository package to generate AWR DB Reports.

AWR_REPORT_TEXT
AWR_REPORT_HTML
SELECT OUTPUT

FROM TABLE(DBMS_WORKLOAD_REPOSITORY.AWR_REPORT_HTML

(2934657915,1,33907,33913);

* You can also use same pakcage to generate AWR DB comparison reports.

AWR_DIFF_REPORT_TEXT
AWR_DIFF_REPORT_HTML
SELECT OUTPUT

FROM TABLE(DBMS_WORKLOAD_REPOSITORY.AWR_DIFF_REPORT_HTML(

2934657915,1,33907,33913,

2934657915,1,43981,44832);

AWR – Scripts

Posted in AWR Report by jackyoon on November 6, 2011
Purpose Scripts
AWR DB Report awrrpt.sql, awrrpti.sql
AWR DB Compare Report awrddrpt.sql
AWR SQL Report awrsqrpt.sql
AWR Information Detail awrinfo.sql
ASH Report ashrpt.sql, ashrpti.sql
ADDM Report addmrpt.sql, addmrpti.sql
ETC awrddinp.sql, awrinput.sql

AWR – Comparing two snapshot areas.

Posted in AWR Report by jackyoon on November 6, 2011

You can compare two separate snapshot areas using below script.

SQL> @awrddrpt.sql
SQL>

AWR – Base Line

Posted in AWR Report by jackyoon on November 6, 2011

* When you optimizing your database using AWR, you can create “Base Line” to compare the values with other snapshots.

–> For example, if you want to compare statistics before and after the turning.
SQL> BEGIN
DBMS_WORKLOAD_REPOSITORY.CREATE_BASELINE(
START_SNAP_ID => 33873,
END_SNAP_ID => 33883,
BASELINE_NAME => ‘GOOD_SNAP’ );
END;
/

* Drop Base Line ( You can drop the baseline if you don’t need it any more.)
–> Baseline snapshopt doest not automatally purged, So, you should manually drop the baseline when you don’t need it anymore.

SQL> BEGIN
DBMS_WORKLOAD_REPOSITORY.DROP_BASELINE(
BASELINE_NAME => ‘GOOD_SNAP’,
CASCADE => TRUE );
END;
/

* Review Baseline information
SQL> SELECT * FROM DBA_HIST_BASELINE;

AWR – Modify snapshot settings

Posted in AWR Report by jackyoon on November 6, 2011

– Default –
AWR Snapshot interval : 60
AWR Snapshot retention: 7 days
Number of Top SQL Sampling: 30

– Change to –
AWR Snapshot interval : 30
AWR Snapshot retention: 30 days
Number of Top SQL Sampling: 50

SQL> BEGIN
DBMS_WORKLOAD_REPOSITORY.MODIFY_SNAPSHOT_SETTINGS(
INTERVAL => 30, RETENTION => 30*24*60, TOPNSQL => ’50′ );
EDN;
/

– Review AWK setting –
SQL> SELECT * FROM DBA_HIST_WR_CONTROL;

AWK – Review Snapshot information

Posted in AWR Report by jackyoon on November 6, 2011

You can review snapshot information with below query.

SQL> alter session set nls_date_format=’yyyy/mm/dd hh24:mi:ss’;
SQL> select snap_id,instance_number,startup_time,begin_interval_time,end_interval_time
from dba_hist_snapshot
order by instance_number,snap_id
/

AWK – Create Snapshot

Posted in AWR Report by jackyoon on November 6, 2011

You can manually create snapshot running DBMS_WORKLOAD_REPOSITORY.CREATE_SNAPSHOT() procedure.

-With TYPICAL option
SQL> exec dbms_workload_repository.create_snapshot();

- with ALL option
SQL> exec dbms_workload_repository.create_snapshot(flush_level => ‘ALL’);

Follow

Get every new post delivered to your Inbox.