Friday, March 25, 2011

- Oracle 11g Automatic Memory Management (AMM) --

Let's start with a brief introduction to basic concepts.

PROGRAM GLOBAL AREA (PGA): is a region that contains data and control information for a server process, this is non shared memory created by the database when a server process is started and access is exclusive to the particular server process.SH
SHARED_GLOBAL_AREA (SGA) :  Is a group of memory structures that contain data and control information for the Oracle instance, it is shared by all background processes.

Oracle has made great progress to simplify memory management through the last versions of the RDBMS. In 9i they introduced PGA management, in 10g they automated the SGA management and in 11g you can manage both (PGA and SGA) with a single configuration using "Automatic Memory Management (AMM)". AMM allows you to allocate a chunk of memory which Oracle uses to manage both SGA and PGA, AMM uses 2 parameters:

MEMORY_TARGET: Amount of memory available to Oracle to use dynamically to control SGA and PGA, this is the amount of memory Oracle will allocate when you start the database to manage PGA and SGA.

MEMORY_MAX_TARGET: Maximum amount of memory that Oracle can use, when no specified the max is equal to MEMORY_TARGET.

When  AMM is in use, SGA_TARGET (Introduced in 10g) and PGA_AGGREGATE_TARGET (Introduced in 9i)  act as the minimum size setting for their respective areas. It is recommend to set this to 0 when using AMM so Oracle can take full control of it.

Thursday, March 3, 2011

-- How to map disk devices to physical devices in Solaris --

You can map between the two device naming conventions using a script like the one below.

Instance Names: Instance names refer to the nth device in the system (for example, sd20).

Instance names are occasionally reported in driver error messages. You can determine the binding of an instance name to a physical name by looking at dmesg(1M) output, as in the following example.

sd9 at esp2: target 1 lun 1 sd9 is /sbus@1,f8000000/esp@0,800000/sd@1,0

Once the instance name has been assigned to a device, it remains bound to that device.

Instance numbers are encoded in a device's minor number. To keep instance numbers consistent across reboots, the system records them in the /etc/path_to_inst file.

!/usr/bin/env perl

use strict;

my @path_to_inst = qx#cat /etc/path_to_inst#;
map {s/"//g} @path_to_inst;
my ($device, $path, @instances);

for my $line (qx#ls -l /dev/dsk/*s2#) {
    ($device, $path) = (split(/\s+/, $line))[-3, -1];
    $path =~ s#.*/devices(.*):c#$1#;

    @instances =
        map {join("", (split /\s+/)[-1, -2])}
            grep {/$path/} @path_to_inst;
*emphasized text*
    for my $instance (@instances) {
        print "$device $instance\n";