Accessing Block Storage on Linux

Linux での MPIO iSCSI LUN への接続

開始する前に、ブロック・ストレージ・ボリュームにアクセスするホストが SoftLayer ポータルで許可されていることを確認してください。

  1. ブロック・ストレージ・リスト・ページで、新たにプロビジョンされたボリュームに関連付けられている「アクション (Actions)」ボタンをクリックして、「ホストを許可 (Authorize Host)」をクリックします。
  2. リストから 1 つ以上の目的のホストを選択して、「送信 (Submit)」をクリックします。これにより、ホストはボリュームへのアクセスを許可されます。

ブロック・ストレージ・ボリュームのマウント

以下に、Linux ベースの SoftLayer コンピューティング・インスタンスをマルチパス入出力 (MPIO) Internet Small Computer System Interface (iSCSI) 論理装置番号 (LUN) に接続するために必要なステップを示します。この例は、Red Hat Enterprise Linux 6 に基づいています。オペレーティング・システム (OS) ベンダーの資料に従って、このステップをその他の Linux ディストリビューション用に調整することができます。

: 手順に示されているホスト IQN、ユーザー名、パスワード、ターゲット・アドレスは、SoftLayer ポータルの「ブロック・ストレージの詳細」画面から取得できます。

  1. iSCSI とマルチパスのユーティリティーをホストにインストールします。
    1. # yum install iscsi-initiator-utils
    2. # yum install device-mapper-multipath
  1. マルチパス構成ファイルを作成または編集します。
    defaults { user_friendly_names no max_fds max flush_on_last_del yes queue_without_daemon no dev_loss_tmo infinity fast_io_fail_tmo 5 } # All data under blacklist must be specific to your system. blacklist { wwid "SAdaptec*" devnode "^hd[a-z]" devnode "^(ram|raw|loop|fd|md|dm-|sr|scd|st)[0-9]*" devnode "^cciss.*" } devices { device { vendor "NETAPP" product "LUN" path_grouping_policy group_by_prio features "3 queue_if_no_path pg_init_retries 50" prio "alua" path_checker tur failback immediate path_selector "round-robin 0" hardware_handler "1 alua" rr_weight uniform rr_min_io 128 getuid_callout "/lib/udev/scsi_id -g -u -d /dev/%n" } }
    1. 以下のコマンドに示されている最小構成で、/etc/multipath.conf を編集します。
    1. マルチパス・モジュールをロードして、マルチパス・サービスを開始し、ブート時に開始するように設定します。
      1. # modprobe dm-multipath
      2. # service multipathd start
      3. # chkconfig multipathd on
    1. マルチパスが機能していることを確認します。
      1. # multipath -l (この時点ではブランクが返されれば、機能しています)
    1. /etc/iscsi/initiatorname.iscsi ファイルを SoftLayer ポータルの IQN で更新します。

    InitiatorName="value-from-the-SL-Portal"

    1. SoftLayer ポータルのユーザー名とパスワードを (引用符を差し引いて) 使用して、/etc/iscsi/iscsid.conf の CHAP 設定を編集します。

    node.session.auth.authmethod = CHAP node.session.auth.username = "Username-value-from-SL-Portal" node.session.auth.password = "Password-value-from-SL-Portal" discovery.sendtargets.auth.authmethod = CHAP discovery.sendtargets.auth.username = "Username-value-from-SL-Portal" discovery.sendtargets.auth.password = "Password-value-from-SL-Portal"

     

    Note: Leave the other CHAP settings commented. SoftLayer storage uses only one-way authentication.

     

    1. Set iSCSI to start at boot and start it at this time.
      1. # chkconfig iscsi on
      2. # chkconfig iscsid on
      3. # service iscsi start
      4. # service iscsid start

     

     

    1. Discover the device using the Target IP address obtained from the SoftLayer Portal.

      # iscsiadm -m discovery -t sendtargets -p "ip-value-from-SL-Portal"

      # iscsiadm -m node -L automatic

      1. Run the discovery against the iSCSI array:
      2. Set the host to automatically log into the iSCSI array:

     

     

    1. Verify that the host has logged into the iSCSI array and maintained its sessions.
      1. # iscsiadm -m session
      2. # multipath -l (should report the paths at this time)
      3. If you get a blank value, try updating device-mapper (yum update device-mapper or apt-get update device-mapper), then restarting the multipathd service again and it should connect this time.

       

     

     

    1. Verify the device is connected.  By default the device will attach to /dev/mapper/mpathX where X is the generated ID of the connected device.
      1. # fdisk -l | grep /dev/mapper

       

     

     

    Should report something similar to the following,

    Disk /dev/mapper/3600a0980383030523424457a4a695266: 73.0 GB, 73023881216 bytes

    The volume is now mounted and accessible on the host.

     

     

     

     

    Unmounting Block Storage volumes

     

    Following are the steps required to disconnect a Linux-based SoftLayer compute instance to an MPIO iSCSI LUN. The example is based on Red Hat Enterprise Linux 6. The steps can be adjusted for other Linux distributions according to the OS vendor documentation.

     

    1. First unmount the filesystem from the ICSCI target.

     

     

    Determine where your iscsi target is mounted. Look for a device with format /dev/mapper/"uuid"

     

    # mount

     

    ...

     

    ...

     

    /dev/mapper/3600a0980383034524c2446597a6e6b69 on /mnt/prime type ext4 (rw)

     

    ...

     

    # umount /dev/mapper/3600a0980383034524c2446597a6e6b69

    1. Unmount the device.

     

    1. Obtain the Target ID and the Portal IDs of the iSCSI Target.

      tcp: [1] 10.2.62.90:3260,1033 iqn.1992-08.com.netapp:tor0101

      tcp: [2] 10.2.62.75:3260,1030 iqn.1992-08.com.netapp:tor0101

      "iqn.1992-08.com.netapp:tor0101"

      "10.2.62.90:3260,1033" and "10.2.62.75:3260,1030"

      1. # iscsiadm -m session
      2. In output above the Target ID are represented as
      3. In output above the Portal IDs are represented as

       

    2. Now you must logout of the Target Portals and disconnect the iSCSI Target using the information above. Note: If you only have one iSCSI device or are logging out of all iSCSI devices, you can use iscsiadm -m node -u
      1. # iscsiadm --m node -T iqn.1992-08.com.netapp:tor0101 --portal 10.2.62.90:3260 -u Logging out of session [sid: 1, target: iqn.1992-08.com.netapp:tor0101, portal: 10.2.62.90,3260]

        Logout of [sid: 1, target: iqn.1992-08.com.netapp:tor0101, portal: 10.2.62.90,3260] successful.

         

      2. # iscsiadm --m node -T iqn.1992-08.com.netapp:tor0101 --portal 10.2.62.75:3260 –u Logging out of session [sid: 2, target: iqn.1992-08.com.netapp:tor0101, portal: 10.2.62.75,3260]

        Logout of [sid: 2, target: iqn.1992-08.com.netapp:tor0101, portal: 10.2.62.75,3260] successful.

         

       

    3. Now that you are disconnected and logged out of the portal you must remove the ISCI Target records from your local system.

      # iscsiadm -m node -o delete -T iqn.1992-08.com.netapp:tor0101 --portal 10.2.62.90:3260

      # iscsiadm -m node -o delete -T iqn.1992-08.com.netapp:tor0101 --portal 10.2.62.75:3260

      1. Flush the multipath configuration.

        # multipath -l

        3600a0980383034524c2446597a6e6b69 dm-0 , size=20G features='1 queue_if_no_path' hwhandler='0' wp=rw

        |-+- policy='round-robin 0' prio=-1 status=active

        | `- #:#:#:# -    #:#    active undef running `-+- policy='round-robin 0' prio=-1 status=enabled `- #:#:#:# -    #:#    active undef running

        # multipath -f 3600a0980383034524c2446597a6e6b69

        1. List the paths to find the one for your device.
        2. Flush the path associated to your device.

         

         

         

        Create a file system (optional)

         

        Following are the steps to create a file system on top of the newly mounted volume. A file system is necessary for most applications to utilize the volume.

         

        1. Get the disk name.
          1. # fdisk -l | grep /dev/mapper (the disk name returned will be similar to /dev/mapper/XXX).

           

         

         

        1. Create a partition on the disk using fdisk.
          1. # fdisk /dev/mapper/XXX (where XXX represents the disk name returned in Step 1).
          2. Follow the commands codes listed below:

           

         

         

        Command

        Result

        • *Command: n

        Creates a new partition.

        • Command action: p

        Makes the partition the primary one.

        • Partition number (1-4): 1

        Becomes partition 1 on the disk.

        • First cylinder (1-8877): 1 (default)

        Start at cylinder 1.

        • Last cylinder, +cylinders or +size {K, M, G}: 8877 (default)

        Hit Enter to go to the last cylinder.

         

        • *Command: t

        Sets up the type of partition.

        • Select partition 1.

        Selects partition 1 to be set up as a specific type.

        • **Hex code: 83

        Selects Linux as the Type (83 is the hex code for Linux).

         

        • *Command: w

        Writes the new partition information to the disk.

        The partition table has been altered!

        Received once the table has been updated.

         

        Calling ioctl()

        Rereads the partition table.

        WARNING: Re-reading the partition table failed with error 22: Invalid argument.

        The kernel still uses the old table. The new table will be used at

        the next reboot or after you run partprobe(8) or kpartx(8)

        Syncing disks.

         

        *Type m for Help.

        **Type L to list the hex codes

         

         

         

        1. Review the new partition on the disk.
          1. # fdisk –l /dev/mapper/XXX
          2. The new partition should be listed with the disk, similar to XXXlp1, followed by the size, Type (83), and Linux. Remember the partition name; you’ll need it in Step 3.

           

         

         

        1. Create a file system on the new partition.
          1. # mkfs.ext3 /dev/mapper/XXXlp1 (where XXXlp1represents the partition name is that was returned in Step 2).

           

         

         

        1. Create a mount point for the file system and mount it.
          1. # mkdir /PerfDisk (or where you want to mount the file system).
          2. # mount /dev/mapper/XXXlp1 /PerfDisk (using the partition name from Step 2).
          3. # df -h (you should see your new file system listed).