About iSCSI Storage

2014/01/25 13:06
阅读数 91

The Internet Small Computer System Interface (iSCSI) is an IP-based standard for connecting storage devices. iSCSI encapsulates SCSI commands in IP network packets, which allows data transfer over long distances and sharing of storage by client systems. As iSCSI uses the existing IP infrastructure, it does not require the purchase and installation of fiber-optic cabling and interface adapters that are needed to implement Fibre Channel (FC) storage area networks.

A client system (iSCSI initiator) accesses the storage server (iSCSI target) over an IP network. To an iSCSI initiator, the storage appears to be locally attached.

Figure 16.1 shows a simple network where several iSCSI initiators are able to access the shared storage that is attached to an iSCSI target.

Figure 16.1 iSCSI Initiators and an iSCSI Target Connected via an IP-based Network

The diagram shows a simple Ethernet network where several iSCSI initiators are able to access the shared storage that is attached to an iSCSI target.

A hardware-based iSCSI initiator uses a dedicated iSCSI HBA. Oracle Linux supports iSCSI initiator functionality in software. The kernel-resident device driver uses the existing network interface card (NIC) and network stack to emulate a hardware iSCSI initiator. As the iSCSI initiator functionality is not available at the level of the system BIOS, you cannot boot an Oracle Linux system from iSCSI storage .

To improve performance, some network cards implement TCP/IP Offload Engines (TOE) that can create a TCP frame for the iSCSI packet in hardware. Oracle Linux does not support TOE, although suitable drivers may be available directly from the card vendor.

16.6.1 Configuring an iSCSI Target

An iSCSI target is typically a dedicated, network-connected storage device but it can also be a general-purpose computer. The procedure in this section demonstrates how to set up a simple iSCSI target.

To configure an Oracle Linux system as an iSCSI target:

  1. Install the scsi-target-utils package:

    # yum install scsi-target-utils
  2. Edit /etc/tgt/targets.conf and create entries for the iSCSI target and the storage devices (LUNs) that it will make available, for example:

    <target iqn.2012-01.com.mydom.host01:target1>
        direct-store /dev/sdb # LUN 1
        direct-store /dev/sdc # LUN 2

    The /etc/tgt/targets.conf file contains several sample configurations that you can use as templates.

    In the example, the target is uniquely identified by its iSCSI Qualified Name (IQN), which takes the format:



    • YYYY-MM

    • Specifies the year and month that the naming authority took ownership of the domain.

    • reverse_FQDN

    • Specifies the reverse fully qualified domain name of the naming authority.

    • target_name

    • Specifies an optional target name, which identifies the target at a site.

  3. Start the iSCSI target service, tgtd, and configure it to start after the system reboots:

    # service tgtd start# chkconfig tgtd on
  4. Use the tgtadm command to verify that the iSCSI target is available:

    # tgtadm -o show -m target
    Target 1: iqn.2012-01.com.mydom.host01:target1
        System information:
            Driver: iscsi
            State: ready
        I_T nexus information:
        LUN information:
            LUN: 0
                Type: controller
                SCSI ID: deadbeaf1:0
                SCSI SN: beaf10
                Size: 0 MB
                Online: Yes
                Removable media: No
                Backing store: No backing store
            LUN: 1
                Type: disk
                SCSI ID: deadbeaf1:1
                SCSI SN: beaf11
                Size: 10737 MB
                Online: Yes
                Removable media: No
                Backing store: No

You can use the tgtadm utility to monitor and configure iSCSI targets. In addition, the tgt-admin script provides a simplifed interface to the tgtadm commands that create, delete, and show target information. The tgt-setup-lunscript allows you to create targets, add devices to targets, and define which iSCSI initiators are allowed to connect to a target.

For more information, see the targets.conf(5)tgt-admin(8)tgt-setup-lun(8), and tgtadm(8) manual pages.

16.6.2 Configuring an iSCSI Initiator

To configure an Oracle Linux system as an iSCSI initiator:

  1. Install the iscsi-initiator-utils package:

    # yum install iscsi-initiator-utils
  2. Use the SendTargets discovery method to discover the iSCSI targets at a specified IP address:

    # iscsiadm -m discovery --type sendtargets –p iscsid:                               [ OK ],1 iqn.2012-01.com.mydom.host01:target1,1 iqn.2012-01.com.mydom.host01:target2


    An alternate discovery method is Internet Storage Name Service (iSNS).

    The command also starts the iscsid service if it is not already running.

    The following command displays information about the targets that is now stored in the discovery database:

    # iscsiadm -m discoverydb –t st –p BEGIN RECORD 2.0-872.41.el6
    discovery.startup = manual
    discovery.type = sendtargets
    discovery.sendtargets.address =
    discovery.sendtargets.port = 3260
    discovery.sendtargets.auth.authmethod = None
    discovery.sendtargets.auth.username_in = <empty>
    discovery.sendtargets.auth.password_in = <empty>
    discovery.sendtargets.timeo.login_timeout = 15
    discovery.sendtargets.use_discoveryd = No
    discovery.sendtargets.discoveryd_poll_inval = 30
    discovery.sendtargets.repoen_max = 5
    discovery.sendtargets.timeo.auth_timeout = 45
    discovery.sendtargets.timeo.active_timeout = 30
    discovery.sendtargets.iscsi.MaxRecvDataSegmentLength = 32768
  3. Establish a session and log in to a specific target:

    # iscsiadm -m node -l# iscsiadm -m node --targetname iqn.2012-01.com.mydom.host01:target1 \  –p -lLogin to [iface: default, target: iqn.2012-01.com.mydom.host01:target1, 
    portal:] successful.
  4. Verify that the session is active, and display the available LUNs:

    # iscsiadm -m session –P 3Target: iqn.2012-01.com.mydom.host01:target1
    Current Portal:,1
    Persistent Portal:,1
    Iface Name: default
    Iface Transport: tcp
    Iface Initiatorname: iqn.1988-12.com.oracle:392a7cee2f
    Iface IPaddress:
    Iface HWaddress: <empty>
    Iface Netdev: <empty>
    SID: 1
    iSCSI Connection State: LOGGED IN
    iSCSI Session State: LOGGED IN
    Internal iscsid Session State: NO CHANGE
    Attached SCSI devices:
    Host Number: 4 State: running
    scsi10 Channel 00 Id 0 Lun:0
    scsi10 Channel 00 Id 0 Lun:1
        Attached scsi disk sdb
    State: running
    scsi10 Channel 00 Id 0 Lun:2
        Attached scsi disk sdc
    State: running

    The LUNs are represented as SCSI block devices (sd*) in the local /dev directory, for example:

    # fdisk –l | grep /dev/sd[bc]Disk /dev/sdb: 10.7 GB, 10737418240 bytes
    Disk /dev/sdc: 10.7 GB, 10737418240 bytes

    To distinguish between target LUNs, examine their paths under /dev/disk/by-path:

    # ls -l /dev/disk/by-path/lrwxrwxrwx  1 root root  9 May 15 21:05
      084591f8-6b8b-c857-f002-ecf8a3b387f3-lun-1 -> ../../sdb
    lrwxrwxrwx 1 root root  9 May 15 21:05
      084591f8-6b8b-c857-f002-ecf8a3b387f3-lun-2 -> ../../sdc

    You can view the initialization messages for the LUNs in the /var/log/messages file:

    # grep -i scsi /var/log/messagesApr 8 15:08:53 host02 kernel: scsi12 : iSCSI Initiator over TCP/IP
    Apr 8 15:08:53 host02 kernel: sd 4:0:0:1: [sdb] Attached SCSI disk
    Apr 8 15:08:53 host02 kernel: sd 4:0:0:2: [sdc] Attached SCSI disk

    You can configure and use a LUN in the same way as you would any other physical storage device. For example, you can configure it as an LVM physical volume, file system, swap partition, Automatic Storage Management (ASM) disk, or raw device.

    Specify the _netdev option when creating mount entries for iSCSI LUNs in /etc/fstab, for example:

    UUID=084591f8-6b8b-c857-f002-ecf8a3b387f3     /iscsi_mount_point     ext4     _netdev   0  0

    This option indicates the file system resides on a device that requires network access, and prevents the system from attempting to mount the file system until the network has been enabled.


    Specify an iSCSI LUN in /etc/fstab by using UUID=UUID or LABEL=label rather than the device path. A device path can change after re-connecting the storage or rebooting the system.

    Any discovered LUNs remain available across reboots provided that the target continues to serve those LUNs and you do not log the system off the target.

For more information, see the iscsiadm(8) and iscsid(8) manual pages.

16.6.3 Updating the Discovery Database

If the LUNs that are available on an iSCSI target change, you can use the iscsiadm command on an iSCSI initiator to update the entries in its discovery database. The following example assume that the target supports the SendTargets discovery method

To add new records that are not currently in the database:

# iscsiadm -m discoverydb –t st –p –o new --discover

To update existing records in the database:

# iscsiadm -m discoverydb –t st –p –o update --discover

To delete records from the database that are no longer supported by the target:

# iscsiadm -m discoverydb –t st –p –o delete --discover

For more information, see the iscsiadm(8) manual page.

0 收藏
0 评论
0 收藏