Top
PRIMECLUSTER Global Disk Services  Configuration and AdministrationGuide 4.4
FUJITSU Software

4.8.3 Creating iSCSI Target

Set the following configuration for all nodes in which the mirroring function among servers is used.

The "current node" in the following procedure indicates: node 1 if you execute the procedure on the node 1; node 2 if you execute the procedure on the node 2.

The setting procedures are different depending on OS version.

[RHEL6]

  1. Add the iSCSI target setting to the /etc/tgt/targets.conf file.

    Add the following content.

    <target targetname>
      initiator-address IPaddress1
      initiator-address IPaddress2
      write-cache off
      <backing-store by-id>
        lun LUN
        scsi_id SCSI-ID
      </backing-store>
    </target>
    

    Point

    • For targetname, describe the target name of the current node.
      Specify the unique string of characters (255 characters or less) in the cluster system.

    • For IPaddress1, describe the IP address for the mirroring among servers on node 1. The IPv4 address or the IPv6 address can be set.

    • For IPaddress2, describe the IP address for the mirroring among servers on node 2. The IPv4 address or the IPv6 address can be set.

    • Set all the IP addresses used for the mirroring among servers as the initiator-address.

    • For by-id, describe the path of the by-id file stored in a disk on the current node which performs mirroring among servers.

    • For LUN, describe the LUN number for the iSCSI device of the disk specified by by-id.
      Specify the unique string of characters in the iSCSI target (in <target targetname> ... </target>).

    • For SCSI-ID, describe the SCSI ID of the iSCSI device with which by-id specifies.
      Specify the unique number in the cluster system.

    • If the current node has multiple disks on which the mirroring among servers is performed, describe four lines starting from <backing-store by-id> to </backing-store> for each disk.

    Description example (node 1)

    <target target-0101>
      initiator-address 192.168.56.20
      initiator-address 192.168.56.10
      write-cache off
      <backing-store /dev/disk/by-id/scsi-3500000e111c56610>
        lun 1
        scsi_id SDX01
      </backing-store>
    </target>
    

    Description example (node 2)

    <target target-0201>
      initiator-address 192.168.56.20
      initiator-address 192.168.56.10
      write-cache off
      <backing-store /dev/disk/by-id/scsi-3500000e114784360>
        lun 1
        scsi_id SDX02
      </backing-store>
    </target>
    
  2. Restart the SCSI target daemon (tgtd).

    # service tgtd restart
    Stopping SCSI target daemon:                               [  OK  ] 
    Starting SCSI target daemon:                               [  OK  ]

    If the SCSI target daemon (tgtd) is not started, the following message will be output.

    Stopping SCSI target daemon: not running                   [FAILED]

    Then, if the following message is output, there is no problem.

    Starting SCSI target daemon:                               [  OK  ]

[RHEL7]

  1. Execute targetcli to be an interactive mode.

    # targetcli
  2. Set not to add a default portal automatically.

    /> set global auto_add_default_portal=false
  3. Register a disk or a partition of a local node for the mirroring among servers.

    /> /backstores/block/ create storage_name device_path

    Point

    • Specify arbitrary characters (255 characters or less) to storage_name.

    • Specify the path for by-id file on a disk or in a partition for the mirroring among servers on a local node to device_path.

    • If there are plural disks for the mirroring among servers on a local node, perform the procedure for each disk.

    Execution example

    /> /backstores/block/ create storage1 /dev/disk/by-id/scsi-3500000e111c56611
  4. Check the setting of device.

    Execute the following command to check that emulate_write_cache is 0.

    /> /backstores/block/storage_name get attribute emulate_write_cache

    Point

    Specify the storage name set in the step 3 to storage_name.

    Execution example

    /> /backstores/block/storage1 get attribute emulate_write_cache
    emulate_write_cache=0
  5. Create iSCSI target.

    /> /iscsi/ create
  6. Check the created iSCSI target.

    /> /iscsi/ ls

    Execution example

    /> /iscsi/ ls
    o- iscsi ..................................................................... [Targets: 1]
      o- iqn.2003-01.org.linux-iscsi.node1.x8664:sn.2613f8620d98 .................... [TPGs: 1]
        o- tpg1 ........................................................ [no-gen-acls, no-auth]
          o- acls ................................................................... [ACLs: 0]
          o- luns ................................................................... [LUNs: 0]
          o- portals ............................................................. [Portals: 0]

    This example shows that iqn name "iqn.2003-01.org.linux-iscsi.node1.x8664:sn.2613f8620d98" was created and the target was created in /iscsi/.

  7. Register iSCSI initiators of both nodes.

    /> /iscsi/iqn_name/tpgX/acls create initiator_name_of_node1
    /> /iscsi/iqn_name/tpgX/acls create initiator_name_of_node2

    Point

    • Specify the iqn name confirmed in the step 6 to iqn_name.

    • Specify the directory name (Example: tpg1) created in the iqn_name directory to tpgX.

    • Initiator name can be confirmed in the /etc/iscsi/initiatorname.iscsi file.

    Execution example

    /> /iscsi/iqn.2003-01.org.linux-iscsi.node1.x8664:sn.2613f8620d98/tpg1/acls create \
    iqn.1994-05.com.redhat:dee92ff9979d
    /> /iscsi/iqn.2003-01.org.linux-iscsi.node1.x8664:sn.2613f8620d98/tpg1/acls create  \
    iqn.1994-05.com.redhat:fa7eb9cf483c

    Note

    An iSCSI initiator name needs to be differed in each node of the cluster system.

    If an iSCSI initiator name in each node is identical, change it to a different iSCSI initiator name in each node.

    See the following procedure to change an iSCSI initiator name.

    1. Determine a new iSCSI initiator name.
      Use the following command to create an initiator name with random ID.

      (Example)

      # iscsi-iname
      iqn.1994-05.com.redhat:5ea612eab618
    2. Change a configuration file.
      In the /etc/iscsi/initiatorname.iscsi file, rewrite a character string following "InitiatorName=" to the iSCSI initiator name of the step 1.

      (Example)

      [Before change]

      InitiatorName=iqn.1994-05.com.redhat:4539cd846026

      [After change]

      InitiatorName=iqn.1994-05.com.redhat:5ea612eab618
    3. Restart iscsid to update the configuration.

      (Example)

      # systemctl restart iscsid.service
  8. Connect the device registered in the step 3.

    /> /iscsi/iqn_name/tpgX/luns create /backstores/block/storage_name

    Point

    • Specify iqn name confirmed in the step 6 to iqn_name.

    • Specify the directory name (Example: tpg1) created in the iqn_name directory to tpgX.

    • Specify the storage name set in the step 3 to storage_name.

    • If there are plural disks for the mirroring among servers on a local node, perform the procedure for each disk.

    Execution example

    /> /iscsi/iqn.2003-01.org.linux-iscsi.node1.x8664:sn.2613f8620d98/tpg1/luns create \
    /backstores/block/storage1
  9. Register IP address for the target.

    /> /iscsi/iqn_name/tpgX/portals create IPaddress

    Point

    • Specify the iqn name confirmed in the step 6 to iqn_name.

    • Specify the directory name (Example: tpg1) created in the iqn_name directory to tpgX.

    • Specify IP address for the mirroring among servers on a local node to IPaddress.
      IPv4 address or IPv6 address can be set.
      IP address of cip can not be specified. Use IP address assigned NIC (such as eth0) directly.
      For conditions for NIC and IP address, refer to "3.9.1 Network Configuration."

    Execution example

    /> /iscsi/iqn.2003-01.org.linux-iscsi.node1.x8664:sn.2613f8620d98/tpg1/portals create \
    192.168.125.123
  10. End the interactive mode of targetcli. This operation records the settings.

    /> exit
  11. Confirm the target configuration.

    # targetcli ls

    Point

    (*1) Confirm that the path for by-id file of the device used for the mirroring among servers was output.

    (*2) Confirm that iSCSI initiator name for each cluster node was output.

    (*3) Confirm that the storage confirmed in (*1) was assigned for each iSCSI initiator.

    (*4) Confirm that IP address of a local node for the mirroring among servers was output.

    Execution example

    # targetcli ls
    o- / .............................................................................. [...]
      o- backstores ................................................................... [...]
      | o- block ....................................................... [Storage Objects: 1]
      | | o- storage1 . [/dev/disk/by-id/scsi-3500000e111c56611 (8.0GiB) write-thru activated] (*1)
      | o- fileio ...................................................... [Storage Objects: 0]
      | o- pscsi ....................................................... [Storage Objects: 0]
      | o- ramdisk ..................................................... [Storage Objects: 0]
      o- iscsi ................................................................. [Targets: 1]
      | o- iqn.2003-01.org.linux-iscsi.node1.x8664:sn.2613f8620d98 ................ [TPGs: 1]
      |   o- tpg1 .................................................... [no-gen-acls, no-auth]
      |     o- acls ............................................................... [ACLs: 2]
      |     | o- iqn.1994-05.com.redhat:dee92ff9979d ........................ [Mapped LUNs: 1] (*2)
      |     | | o- mapped_lun0 .................................... [lun0 block/storage1 (rw)] (*3)
      |     | o- iqn.1994-05.com.redhat:fa7eb9cf483c ........................ [Mapped LUNs: 1] (*2)
      |     |   o- mapped_lun0 .................................... [lun0 block/storage1 (rw)] (*3)
      |     o- luns ............................................................... [LUNs: 1]
      |     | o- lun0 ............. [block/storage1 (/dev/disk/by-id/scsi-3500000e111c56611)]
      |     o- portals ......................................................... [Portals: 1]
      |       o- 192.168.125.123:3260 ................................................... [OK] (*4)
      o- loopback .............................................................. [Targets: 0]