Sun Java Solaris Communities My SDN Account Join SDN
 
Article

Developer Recipes: Setting Up an OpenSolaris Storage Server in 10 Minutes or Less

 
By Dominic Kay, April 29, 2008  

Contents


Introduction


These short lessons will familiarize you with the simple commands in the Solaris OS for performing data management tasks.

These lessons use placeholders for machine names, disk addresses, and so on. Substitute your own information for that shown in the examples that follow.


Example 1: ZFS Filesystem


Objectives:

  • Understand the purpose of the ZFS filesystem.
  • Configure a ZFS pool and filesystem.

Requirements:

  • A server (SPARC or x64 based) running the OpenSolaris OS.
  • Configuration details from the running server.

Step 1: Identify your Disks.

Identify the storage available for adding to the ZFS pool using the format(1) command. Your output will vary from that shown here:

# format
Searching for disks...done


AVAILABLE DISK SELECTIONS:
       0. c0t2d0 
          /pci@0,0/pci1022,7450@2/pci1000,3060@3/sd@2,0
       1. c0t3d0 
          /pci@0,0/pci1022,7450@2/pci1000,3060@3/sd@3,0
Specify disk (enter its number): ^D

Step 2: Add your disks to your ZFS pool.

# zpool create -f  mypool c0t3d0s0
# zpool list
NAME     SIZE   USED  AVAIL    CAP  HEALTH  ALTROOT
mypool    10G    94K  10.0G     0%  ONLINE  -

Step 3: Create a filesystem in your pool.

# zfs create mypool/myfs
# df -h /mypool/myfs
Filesystem             size   used  avail capacity  Mounted on
mypool/myfs            9.8G    18K   9.8G     1%    /mypool/myfs


Example 2: Network File System (NFS)


Objectives:

  • Understand the purpose of the NFS filesystem.
  • Create an NFS shared filesystem on a server and mount it on a client.

Requirements:

  • Two servers (SPARC or x64 based) - one from the previous example - running the OpenSolaris OS.
  • Configuration details from the running systems.

Step 1: Create the NFS shared filesystem on the server.

Switch on the NFS service on the server:

# svcs nfs/server
STATE          STIME    FMRI
disabled       6:49:39  svc:/network/nfs/server:default
# svcadm enable nfs/server

Share the ZFS filesystem over NFS:

# zfs set sharenfs=on mypool/myfs
# dfshares
RESOURCE            SERVER ACCESS TRANSPORT
x4100:/mypool/myfs  x4100  -      -

Step 2: Switch on the NFS service on the client.

This is similar to the the procedure for the server:

# svcs nfs/client
STATE          STIME    FMRI
disabled       6:47:03  svc:/network/nfs/client:default
# svcadm enable nfs/client

Mount the shared filesystem on the client:

# mkdir /mountpoint
# mount -F nfs x4100:/mypool/myfs /mountpoint
# df -h /mountpoint
Filesystem         size  used  avail capacity  Mounted on
x4100:/mypool/myfs 9.8G  18K   9.8G  1%       /mountpoint


Example 3: Common Internet File System (CIFS)


Objectives:

  • Understand the purpose of the CIFS filesystem.
  • Configure a CIFS share on one machine (from the previous example) and make it available on the other machine.

Requirements:

  • Two servers (SPARC or x64 based) running the OpenSolaris OS.
  • Configuration details provided here.

Step 1: Create a ZFS filesystem for CIFS.

# zfs create -o casesensitivity=mixed mypool/myfs2
# df -h /mypool/myfs2
Filesystem  size   used avail capacity Mounted on
mypool/myfs 2 9.8G 18K  9.8G  1%       /mypool/myfs2

Step 2: Switch on the SMB Server service on the server.

# svcs smb/server
STATE          STIME    FMRI
disabled       6:49:39  svc:/network/smb/server:default
# svcadm enable smb/server

Step 3: Share the filesystem using CIFS.

# zfs set sharesmb=on mypool/myfs2

Verify using the following command:

# zfs get sharesmb mypool/myfs2
NAME          PROPERTY  VALUE  SOURCE
mypool/myfs2  sharesmb  on     local

Step 4: Verify the CIFS naming.

Because we have not explicitly named the share, we can examine the default name assigned to it using the following command:

# sharemgr show -vp
default nfs=()
zfs
    zfs/mypool/myfs nfs=()
          /mypool/myfs
    zfs/mypool/myfs2 smb=()
          mypool_myfs2=/mypool/myfs2

Both the NFS share (/mypool/myfs) and the CIFS share (mypool_myfs2) are shown.


Step 5: Edit the file /etc/pam.conf to support creation of an encrypted version of the user's password for CIFS.

Add the following line to the end of the file:

other password required pam_smb_passwd.so.1 nowarn

Step 6: Change the password using the passwd command.

# passwd username
New Password:
Re-enter new Password:
passwd: password successfully changed for root

Now repeat Steps 5 and 6 on the Solaris client.


Step 7: Enable CIF client services on the client node.

# svcs smb/client
STATE          STIME    FMRI
disabled       6:47:03  svc:/network/smb/client:default
# svcadm enable smb/client

Step 8: Make a mount point on the client and mount the CIFS resource from the server.

Mount the resource across the network and check it using the following command sequence:

# mkdir /mountpoint2
# mount -F smbfs //root@x4100/mypool_myfs2  /mountpoint2
Password: *******
# df -h /mountpoint2
Filesystem                size used avail capacity Mounted on
//root@x4100/mypool_myfs2 9.8G 18K  9.8G  1%       /mountpoint2
# df -n
/                  : ufs
/mountpoint        : nfs
/mountpoint2       : smbfs


Example 4: Comstar Fibre Channel Target


Objectives:

  • Understand the purpose of the Comstar Fibre Channel target.
  • Configure an FC target and initiator on two servers.

Requirements:

  • Two servers (SPARC or x64 based) running the OpenSolaris OS.
  • Configuration details provided here.

Step 1: Start the SSCSI Target Mode Framework and verify it.

Use the following commands to start up and check the service on the host that provides the target:

# svcs stmf
STATE          STIME    FMRI
disabled       19:15:25 svc:/system/device/stmf:default
# svcadm enable stmf
# stmfadm list-state
Operational Status: online
Config Status     : initialized

Step 2: Ensure that the framework can see the ports.

Use the following command to ensure that the target mode framework can see the HBA ports:

# stmfadm list-target -v

Target: wwn.210000E08B909221
    Operational Status: Online
    Provider Name     : qlt
    Alias             : qlt0,0
    Sessions          : 4
        Initiator: wwn.210100E08B272AB5
            Alias: ute198:qlc1
            Logged in since: Thu Mar 27 16:38:30 2008
        Initiator: wwn.210100E08B296A60
            Alias: ute198:qlc3
            Logged in since: Thu Mar 27 16:38:30 2008
        Initiator: wwn.210000E08B072AB5
            Alias: ute198:qlc0
            Logged in since: Thu Mar 27 16:38:30 2008
        Initiator: wwn.210000E08B096A60
            Alias: ute198:qlc2
            Logged in since: Thu Mar 27 16:38:30 2008
Target: wwn.210100E08BB09221
    Operational Status: Online
    Provider Name     : qlt
    Alias             : qlt1,0
    Sessions          : 4
        Initiator: wwn.210100E08B272AB5
            Alias: ute198:qlc1
            Logged in since: Thu Mar 27 16:38:30 2008
        Initiator: wwn.210100E08B296A60
            Alias: ute198:qlc3
            Logged in since: Thu Mar 27 16:38:30 2008
        Initiator: wwn.210000E08B072AB5
            Alias: ute198:qlc0
            Logged in since: Thu Mar 27 16:38:30 2008
        Initiator: wwn.210000E08B096A60
            Alias: ute198:qlc2
            Logged in since: Thu Mar 27 16:38:30 2008

Step 3: Create a device to use as storage for the target.

Use ZFS to create a volume (zvol) for use as the storage behind the target:

# zpool list
NAME     SIZE   USED  AVAIL    CAP  HEALTH  ALTROOT
mypool    68G    94K  68.0G     0%  ONLINE  -

# zfs create -V 5gb mypool/myvol
# zfs list
NAME           USED  AVAIL  REFER  MOUNTPOINT
mypool        5.00G  61.9G    18K  /mypool
mypool/myvol     5G  66.9G    16K  -

Step 4: Register the zvol with the framework.

The zvol becomes the SCSI logical unit (disk) behind the target:

# sbdadm create-lu /dev/zvol/rdsk/mypool/myvol
Created the following LU:
GUID                             DATA SIZE   SOURCE
6000ae4093000000000047f3a1930007 5368643584  /dev/zvol/rdsk/mypool/myvol

Confirm its existence as follows:

# stmfadm list-lu -v
LU Name: 6000AE4093000000000047F3A1930007
    Operational Status: Online
    Provider Name     : sbd
    Alias             : /dev/zvol/rdsk/mypool/myvol
    View Entry Count  : 0

Step 5: Find the initiator HBA ports to which to map the LUs.

Discover HBA ports on the initiator host using the following command:

# fcinfo hba-port
HBA Port WWN: 25000003ba0ad303
        Port Mode: Initiator
        Port ID: 1
        OS Device Name: /dev/cfg/c5
        Manufacturer: QLogic Corp.
        Model: 2200
        Firmware Version: 2.1.145
        FCode/BIOS Version: ISP2200 FC-AL Host Adapter Driver:
        Type: L-port
        State: online
        Supported Speeds: 1Gb
        Current Speed: 1Gb
        Node WWN: 24000003ba0ad303
HBA Port WWN: 210000e08b096a60
        Port Mode: Initiator
        Port ID: 10200
        OS Device Name: /dev/cfg/c3
        Manufacturer: QLogic Corp.
        Model: 375-3108-xx
        Firmware Version: 3.3.26
        FCode/BIOS Version:  fcode: 1.13;
        Type: N-port
        State: online
        Supported Speeds: 1Gb 2Gb
        Current Speed: 2Gb
        Node WWN: 200000e08b096a60
HBA Port WWN: 210100e08b296a60
        Port Mode: Initiator
        Port ID: 10c00
        OS Device Name: /dev/cfg/c4
        Manufacturer: QLogic Corp.
        Model: 375-3108-xx
        Firmware Version: 3.3.26
        FCode/BIOS Version:  fcode: 1.13;
        Type: N-port
        State: online
        Supported Speeds: 1Gb 2Gb
        Current Speed: 2Gb
        Node WWN: 200100e08b296a60
HBA Port WWN: 210000e08b072ab5
        Port Mode: Initiator
        Port ID: 10b00
        OS Device Name: /dev/cfg/c1
        Manufacturer: QLogic Corp.
        Model: 375-3108-xx
        Firmware Version: 3.3.26
        FCode/BIOS Version:  fcode: 1.13;
        Type: N-port
        State: online
        Supported Speeds: 1Gb 2Gb
        Current Speed: 2Gb
        Node WWN: 200000e08b072ab5
HBA Port WWN: 210100e08b272ab5
        Port Mode: Initiator
        Port ID: 10d00
        OS Device Name: /dev/cfg/c2
        Manufacturer: QLogic Corp.
        Model: 375-3108-xx
        Firmware Version: 3.3.26
        FCode/BIOS Version:  fcode: 1.13;
        Type: N-port
        State: online
        Supported Speeds: 1Gb 2Gb
        Current Speed: 2Gb
        Node WWN: 200100e08b272ab5

Step 6: Create a host group and add the world-wide numbers (WWNs) of the initiator host HBA ports to it.

Name the group mygroup:

# stmfadm create-hg mygroup
# stmfadm list-hg
Host Group: mygroup

Add the WWNs of the ports to the group:

# stmfadm add-hg-member -g mygroup wwn.210000E08B096A60 \
wwn.210100E08B296A60 \
wwn.210100E08B272AB5 \
wwn.210000E08B072AB5

Now check that everything is in order:

# stmfadmlist-hg-member -v -g mygroup

With the host group created, you're now ready to export the logical unit. This is accomplished by adding a view entry to the logical unit using this host group, as shown in the following command:

# stmfadm add-view -h mygroup  6000AE4093000000000047F3A1930007

Step 7: Check the visibility of the targets on the initiator host.

First, force the devices on the initiator host to be rescanned with a simple script:

#!/bin/ksh
fcinfo hba-port |grep "^HBA" |awk '{print $4}'|while read ln
do
        fcinfo remote-port -p $ln -s >/dev/null 2>&1
done

The disk exported over FC should then appear in the format list:

# format
Searching for disks...done

c6t6000AE4093000000000047F3A1930007d0: configured with capacity of 5.00GB


AVAILABLE DISK SELECTIONS:
       0. c5t8d0 <SUN18G cyl 7506 alt 2 hd 19 sec 248>
          /pci@8,600000/SUNW,qlc@2/fp@0,0/ssd@w2100002037203777,0
       1. c5t10d0 <SUN18G cyl 7506 alt 2 hd 19 sec 248>
          /pci@8,600000/SUNW,qlc@2/fp@0,0/ssd@w2100002037205d7b,0
       2. c5t12d0 <drive not available>
          /pci@8,600000/SUNW,qlc@2/fp@0,0/ssd@w21000020371bcc5e,0
       3. c6t6000AE4093000000000047F3A1930007d0 <SUN-COMSTAR-1.0 cyl 20477 alt
 hd 16 sec 32>
          /scsi_vhci/ssd@g6000ae4093000000000047f3a1930007
       
Specify disk (enter its number): 3
selecting c6t6000AE4093000000000047F3A1930007d0
[disk formatted]
Disk not labeled.  Label it now? y

FORMAT MENU:
        disk       - select a disk
        type       - select (define) a disk type
        partition  - select (define) a partition table
        current    - describe the current disk
        format     - format and analyze the disk
        repair     - repair a defective sector
        label      - write label to the disk
        analyze    - surface analysis
        defect     - defect list management
        backup     - search for backup labels
        verify     - read and display labels
        save       - save new disk/partition definitions
        inquiry    - show vendor, product and revision
        volname    - set 8-character volume name
        !<cmd>     - execute <cmd>, then return
        quit
format> p


PARTITION MENU:
        0      - change '0' partition
        1      - change '1' partition
        2      - change '2' partition
        3      - change '3' partition
        4      - change '4' partition
        5      - change '5' partition
        6      - change '6' partition
        7      - change '7' partition
        select - select a predefined table
        modify - modify a predefined partition table
        name   - name the current table
        print  - display the current table
        label  - write partition map and label to the disk
        !<cmd> - execute <cmd>, then return
        quit
partition> p
Current partition table (default):
Total disk cylinders available: 20477 + 2 (reserved cylinders)

Part      Tag    Flag     Cylinders         Size            Blocks
  0       root    wm       0 -   511      128.00MB    (512/0/0)     262144
  1       swap    wu     512 -  1023      128.00MB    (512/0/0)     262144
  2     backup    wu       0 - 20476        5.00GB    (20477/0/0) 10484224
  3 unassigned    wm       0                0         (0/0/0)            0
  4 unassigned    wm       0                0         (0/0/0)            0
  5 unassigned    wm       0                0         (0/0/0)            0
  6        usr    wm    1024 - 20476        4.75GB    (19453/0/0)  9959936
  7 unassigned    wm       0                0         (0/0/0)            0

partition>