Scripted management of Solaris 10 COMSTAR iSCSI targets

We’re using one of our Solaris machines to publish iSCSI targets to some VMware ESXi hosts (initiators) for client virtual machines.

To make provisioning new LUNs as simple as possible I’ve written an interactive script that first creates a ZFS backing store, then creates the LU for STMF, gives you the option of creating a new iSCSI target or using an existing one, and finally attaches the LU to the selected target.

Here’s a sample output from the script:

-----------------------------------------------------------------
ZFS / iSCSI / COMSTAR Simple Management Toolset
(c)Copyright 2009 Thoughtspace Ltd. Developed by Timothy Creswick
-----------------------------------------------------------------

Please specify the name for the new ZFS backing store.
Your new store will be created inside mpool/clients/iscsi

Existing backing stores are:
NAME                                 USED  AVAIL  REFER  MOUNTPOINT
mpool/clients/iscsi                  271G   973G    19K  /mpool/clients/iscsi
mpool/clients/iscsi/testing           24K   973G    24K  -
mpool/clients/iscsi/testing-three     24K   973G    24K  -
mpool/clients/iscsi/testing-two       24K   973G    24K  -

New backing store: mpool/clients/iscsi/test

Should the backing store be created as a sparse volume? [Yes/No] no

Please enter the size of the backing store: 10GB

Will create a ZFS store with the following details:
  Name:    mpool/clients/iscsi/test
  Size:    10GB
  Sparse:  No

Proceed? [Yes/No] y

Creating ZFS backing store... OK

Creating the STMF LU... OK (GUID is 600144f094ab000000004aa29327000b)

You can either attach this LU / device to an existing iSCSI target as a new LUN,
or you can create a new iSCSI target and STMF target group for this ZFS backing
store.

In general, you want to have a single iSCSI target per Virtual Machine, so if the
virtual machine requires multiple disks, then you should attach each additional
disk as a new LUN on an existing target.

If this is the first disk that you are attaching via iSCSI to the Virtual Machine
you should create a new iSCSI / STMF target.

Create a new iSCSI target? [Yes/No] y

Creating iSCSI target... OK (iqn.1986-03.com.sun:02:2fff96a8-63b2-48bd-b447-bda2a1fc9ead)

Creating STMF target group... OK

Assigning new iSCSI target to target group:
  Waiting for STMF service to terminate.... OK
  Adding TG member... OK
  Starting STMF service.... OK

Adding LU view to target group... OK

All done. Your ZFS device should be available on target iqn.1986-03.com.sun:02:2fff96a8-63b2-48bd-b447-bda2a1fc9ead.

You can get a copy of the script here. Please feel free to use and modify – I’d be interested in any feedback.

This entry was posted in General and tagged , , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

2 Comments

  1. roth
    Posted March 27, 2011 at 5:46 pm | Permalink

    Hi Tim, having trouble. i am newbie to solaris. I have created the following zpool create nas_pool c9d0
    vi create create-iscsi-target.sh
    changed ZFS_BASE=nas_pool > to nas_pool

    roth@rac1:/var/tmp# sh ./create-iscsi-target.sh

    —————————————————————–
    ZFS / iSCSI / COMSTAR Simple Management Toolset
    (c)Copyright 2009 Thoughtspace Ltd. Developed by Timothy Creswick
    —————————————————————–

    Please specify the name for the new ZFS backing store.
    Your new store will be created inside nas_pool
    -e
    Existing backing stores are:
    NAME USED AVAIL REFER MOUNTPOINT
    nas_pool 83.5K 293G 31K /nas_pool
    -en
    New backing store: nas_pool/

    -e
    ERROR: The ZFS name you specified is already in use.
    Will now exit.

    cannot open ‘nas_pool/’: invalid dataset name
    roth@rac1:/var/tmp#

    Thanks
    What am I doing wrong here

    • Timothy Creswick
      Posted March 28, 2011 at 9:39 pm | Permalink

      Hi there – looks to me like you’re not putting in a name for the new backing store. This script will contain all of its activity within the path defined by the ZFS_BASE variable.

      Try entering something different at the “New backing store:” prompt.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

What is 6 + 14 ?
Please leave these two fields as-is:
IMPORTANT! To be able to proceed, you need to solve the following simple question (so we know that you are a human)