Monday, November 10, 2008

PostgreSQL and Project Amber Road (Sun Storage 7000 Series)

The New Sun Microsystems  announced a new line of OpenStorage devices. The new Sun Storage 7000 Unified Storage Systems (code name Amber Road) are Storage appliances which uses ZFS as the core technology and DTrace as the means of "understanding" what's happening with the devices. This now allows systems which DO NOT have ZFS capabilities  (ala Linux, Windows, etc) to use and gain  benefit from the features of ZFS and DTrace (albeit limited to the "Storage" part only).

PostgreSQL (on Linux,Solaris, Windows) can use such systems through one of the standard protocols that these OpenStorage devices support

  • NFS

  • CIFS (Only on Windows)

  • iSCSI

PostgreSQL on NFS is already discussed at length (both merits and also the demerits of using NFS with PostgreSQL ) in the PostgreSQL community. Also I haven't met anybody yet who said that they are using PostgreSQL with their database on CIFS mounted devices. So I think one might actually select iSCSI as the favorable protocol for such OpenStorage devices with PostgreSQL. (Correct me via comments if you think otherwise.)

Here are quick steps that I had used to configure the PostgreSQL server (running Solaris 10) to use iSCSI devices exported from Sun Storage 7000 Unified Storage Platform

 In my case I had created two iSCSI LUN devices (one for PGDATA and one for pg_xlog) with file permissions for the postgres user. (This setup is generally done using the BUI - Browser User Interface of the OpenStorage "Amber Road" device.)

Now on the PostgreSQL Server I did the following to setup iSCSI initiators and LUNS:

  1. Add and display iSCSI target discovery address by giving the
    IP of the "Amber Road" system.

    # iscsiadm add

    # iscsiadm list

    Discovery Address:

  2. Display iSCSI targets discovered from the Amber Road system

    # iscsiadm list
    discovery-address -v

    Discovery Address:

    Target name:

    Target address:, 1

    Target name:

    Target address:, 1

  3. Enable and display static discovery.

    # iscsiadm modify discovery
    --static enable

    # iscsiadm list discovery


    Static: enabled

    Send Targets:

    iSNS: disabled

  4. Adds a target to the list of statically configured targets. A
    connection to the target will not be attempted unless the static
    configuration method of discovery has been enabled.

  5. # iscsiadm add static-config,

    # iscsiadm add static-config,

  6. Use Solaris devfsadm(1M) to create iSCSI device nodes.

    # devfsadm -i iscsi

  7. Use format(1M) command to access iSCSI disks. The disk(s) to
    be selected contain /scsi_vhci in their path name. Local disks are
    listed before iSCSI disks in the format command list. The following
    shows disk no. 4 and 5 are iSCSI disks.

    # format

    Searching for


    0. c0t0d0
    <DEFAULT cyl 17830 alt 2 hd 255 sec 63>


    1. c0t1d0
    <DEFAULT cyl 17830 alt 2 hd 255 sec 63>


    2. c0t2d0
    <DEFAULT cyl 17830 alt 2 hd 255 sec 63>


    3. c0t3d0
    <DEFAULT cyl 17830 alt 2 hd 255 sec 63>


    c2t600144F04890703F0000144FA6CCAC00d0 <DEFAULT cyl 13051 alt 2 hd
    255 sec 63>


    c2t600144F0489070250000144FA6CCAC00d0 <DEFAULT cyl 13051 alt 2 hd
    255 sec 63>


  8. For UFS Follow the following procedure

    1. Create file systems on iSCSI disks.

    # newfs

    # newfs

    1. Make the mount points.

    # mkdir /pgdata

    # mkdir /pglog

    1. Mount the iSCSI LUNs

    # mount -F ufs
    -o forcedirectio /dev/dsk/c2t600144F04890703F0000144FA6CCAC00d0s

    # mount -F ufs
    -o forcedirectio /dev/dsk/c2t600144F0489070250000144FA6CCAC00d0s0

  1. For ZFS Create zpool as follows:

    # zpool create pgdata

    zpool create pglog c2t600144F0489070250000144FA6CCAC00d0s0

  1. For ZFS with Read-Cache and Separate Intent Log (OpenSolaris
    2008.05 and later) using local disks

    # zpool create pgdata
    c2t600144F04890703F0000144FA6CCAC00d0s cache c0t1d0s1
    log c0t1d0s0

    zpool create pglog c2t600144F0489070250000144FA6CCAC00d0s0
    cache c0t2d0s1 log c0t2d0s0

PostgreSQL Setup:

times, UFS filesystems have “lost+found” directory which causes
PostgreSQL's initdb command to fail as directory is not empty. Also
major versions of database are incompatible and hence it makes sense
to take a naming convention as follows and create a sub directory
within /pgdata and /pglog depending on the version you are planning
to use:

/pgdata/8.3 /pglog/8.3

/pgdata/8.2 /pglog/8.2

/pgdata/8.1 /pglog/8.1

Then for PostgreSQL 8.3 (Solaris 10 10/08) the step is as follows

-D /pgdata/8.3 -X /pglog/8.3/pg_xlog

As for 8.2 the steps are as follows:

-D /pgdata/8.2

/pgdata/8.2/pg_xlog /pglog/8.2/

-s /pglog/8.2/pg_xlog /pgdata/8.2/pg_xlog

And for the default 8.1 the steps are similar:

-D /pgdata/8.1

/pgdata/8.1/pg_xlog /pglog/8.1/

-s /pglog/8.1/pg_xlog /pgdata/8.1/pg_xlog

And then use the pg_ctl from the version of PostgreSQL being used to start and stop the server:

start -D /pgdata/8.3 -l /pgdata/8.3/server.log

stop -D /pgdata/8.3

In another blog post I will explain on how to take snapshots with PostgreSQL and the OpenStorage devices.

No comments: