Script to find top consumers of PGA memory

set pagesize 1000
set lines 100
col sid format 9999
col username format a12
col module format a30
column pga_memory_mb format 9,999.99 heading "PGA MB"
column max_pga_memory_mb format 9,999.99 heading "PGA MAX|MB"
col service name format a20 
col sql_text format a70 heading "Currently executing SQL"
set echo on 

WITH pga AS 
    (SELECT sid,
            ROUND(SUM(CASE name WHEN 'session pga memory' 
                       THEN VALUE / 1048576 END),2) pga_memory_mb,
            ROUND(SUM(CASE name WHEN 'session pga memory max' 
                      THEN VALUE / 1048576  END),2) max_pga_memory_mb
      FROM v$sesstat  
      JOIN v$statname  USING (statistic#)
     WHERE name IN ('session pga memory','session pga memory max' )
     GROUP BY sid)
SELECT sid, username,s.module, 
       pga_memory_mb, 
       max_pga_memory_mb, substr(sql_text,1,70) sql_text
  FROM v$session s
  JOIN (SELECT sid, pga_memory_mb, max_pga_memory_mb,
               RANK() OVER (ORDER BY pga_memory_mb DESC) pga_ranking
         FROM pga)
  USING (sid)
  LEFT OUTER JOIN v$sql sql 
    ON  (s.sql_id=sql.sql_id and s.sql_child_number=sql.child_number)
 WHERE pga_ranking <=5
 ORDER BY  pga_ranking
/

Oracle Database Startup Script

Let's create oracle start up script which will help you to start and stop database through the script. This script can help you when you have to integrate Oracle with Linux cluster.

Create a file like db_startup.sh and provide belo script code into it. 

---------------------------------------------------------------------------------------------
#!/bin/sh
# description: Oracle auto start-stop script.
#
# Set ORACLE_HOME to be equivalent to the $ORACLE_HOME
# from which you wish to execute dbstart and dbshut;
#
# Set ORACLE_OWNER to the user id of the owner of the 
# Oracle database in ORACLE_HOME.

ORACLE_HOME=/u01/app/oracle/11.2.0/dbhome_1
ORACLE_OWNER=oracle

if [ ! -f $ORACLE_HOME/bin/dbstart ]
then
    echo "Oracle startup: cannot start"
    exit
fi

case "$1" in
    'start')
        # Start the Oracle databases:
        # The following command assumes that the oracle login 
        # will not prompt the user for any values
        su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/dbstart $ORA_HOME"
        touch /var/lock/subsys/dbora
        ;;
    'stop')
        # Stop the Oracle databases:
        # The following command assumes that the oracle login 
        # will not prompt the user for any values
        su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/dbshut $ORACLE_HOME"
        rm -f /var/lock/subsys/dbora
        ;;

echo "Usage: $0 start|stop|restart|reload"
        exit 1
esac
exit 0

---------------------------------------------------------------------------------------------
Following commands will be used for DB start-up

#sh db_startup.sh start  - To start database
#sh db_startup.sh stop - To staop Database

NFS mount for Oracle Datapump

Many times we required NFS mount point on database server to do multiple activities and we face issue while mounting the NFS mount point with default settings. To overcome from this issue you can below command with parameter settings to mount the NFS mount point on DB server.

#mount -o hard,rw,noac,rsize=32768,wsize=32768,suid,proto=tcp,vers=3 -F nfs nfs_server:/file_system /dir_name

Here

nfs_server - Hostname or IP address of NFS server
file_system - Directory or mount point or file system of NFS server which is going to mount on DB server.
dir_name - Directory name on DB server on which NFS file system would be placed.

Bonding Configuration in Linux

1. Create ifcfg-bond0 file as given below.

#vi /etc/sysconfig/network-scripts/ifcfg-bond0

DEVICE=bond0 
IPADDR=192.168.59.130
NETMASK=255.255.255.0 
GATEWAY=192.168.59.1
NETWORK=192.168.0.0
USERCTL=no 
BOOTPROTO=none 
ONBOOT=yes

2. Append below lines in ifcfg-eth0 and ifcfg-eth1

#vi /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0 
BOOTPROTO=none 
ONBOOT=yes

############# Bond Configuration Parameter #########

MASTER=bond0 
SLAVE=yes

#vi /etc/sysconfig/network-scripts/ifcfg-eth1