Sharing

顯示具有 iSCSI 標籤的文章。 顯示所有文章
顯示具有 iSCSI 標籤的文章。 顯示所有文章

2011年12月13日 星期二

SCST 使用方式


收集了一些還不錯的連結

http://wiki.alpinelinux.org/w/index.php?title=High_performance_SCST_iSCSI_Target_on_Linux_software_Raid&oldid=4999
介紹用 RAID 和 SCST 的搭配使用,不過後半段很清楚的描述從無到有把 iSCSI Target export 出去的流程


Add Target
-add_target -driver
Open Device
-open_dev -handler -attributes   這裡是填 handler 的屬性
Add LUN
-add_lun -driver -target [-group ] -device -attributes
Enable Target
-enable_target -driver
Enable Driver
-set_drv_attr iscsi -attributes enabled=1
Disable Driver
-set_drv_attr iscsi -attributes enabled=0
Disable Target
-disable_target -driver
Remove LUN
-rem_lun -driver -target [-group ]
Close Device
-close_dev -handler
Remove Target
-rem_target -driver


整個流程 Sample

# 加一個 Target
pjack@ubuntu3371:~$ sudo scstadmin -add_target iqn.2011-12.org.pjack:foo1 -driver iscsi

Collecting current configuration: done.


-> Making requested changes.
        -> Creating target 'iqn.2011-12.org.pjack:foo1' for driver 'iscsi': done.
        -> Done.

All done.


# 列出所有的 target 或是列出屬於 iscsi driver 的 Target, 看有沒有出現剛剛新增的
pjack@ubuntu3371:~$ sudo scstadmin -list_target

Collecting current configuration: done.

        Driver Target
        --------------------------------
        iscsi iqn.2011-12.org.pjack:foo1

All done.

pjack@ubuntu3371:~$ sudo scstadmin -list_driver iscsi

Collecting current configuration: done.

        Driver Target
        --------------------------------
        iscsi iqn.2011-12.org.pjack:foo1

All done.



# 看一下這個 Target 的一些屬性
pjack@ubuntu3371:~$ sudo scstadmin -list_tgt_attr iqn.2011-12.org.pjack:foo1 -driver iscsi -nonkey

Collecting current configuration: done.

        Attribute                    Value                                                                       Writable      KEY
        --------------------------------------------------------------------------------------------------------------------------
        HeaderDigest                 None                                                                        Yes           No
        RspTimeout                   90                                                                          Yes           No
        InitialR2T                   No                                                                          Yes           No
        MaxBurstLength               1048576                                                                     Yes           No
        QueuedCommands               32                                                                          Yes           No
        MaxRecvDataSegmentLength     1048576                                                                     Yes           No
        tid                          2                                                                           No            No
        redirect                     < not set="">                                                                   Yes           No
        NopInTimeout                 30                                                                          Yes           No
        rel_tgt_id                   0                                                                           Yes           No
        NopInInterval                30                                                                          Yes           No
        ImmediateData                Yes                                                                         Yes           No
        MaxXmitDataSegmentLength     1048576                                                                     Yes           No
        cpu_mask                     ffffffff,ffffffff,ffffffff,ffffffff,ffffffff,ffffffff,ffffffff,ffffffff     Yes           No
        enabled                      0                                                                           Yes           No
        per_portal_acl               0                                                                           Yes           No
        addr_method                  PERIPHERAL                                                                  Yes           No
        FirstBurstLength             1048576                                                                     Yes           No
        MaxSessions                  0                                                                           Yes           No
        MaxOutstandingR2T            32                                                                          Yes           No
        DataDigest                   None                                                                        Yes           No
        comment                      < n a="">                                                                       Yes           No
        io_grouping_type             auto                                                                        Yes           No

        Dynamic attributes available
        ----------------------------
        allowed_portal
        OutgoingUser
        IncomingUser

        LUN CREATE attributes available
        -------------------------------
        read_only



# 新增一個 Device
pjack@ubuntu3371:~$ sudo scstadmin -open_dev disk01 -handler vdisk_blockio -attributes filename=/dev/rbd0

Collecting current configuration: done.


-> Making requested changes.
        -> Opening device 'disk01' using handler 'vdisk_blockio': done.
        -> Done.

All done.


# 列出所有的 Device
pjack@ubuntu3371:~$ sudo scstadmin -list_device

Collecting current configuration: done.

        Handler           Device
        ------------------------
        vdisk_nullio     -
        vdisk_fileio     -
        vdisk_blockio    disk01
        vcdrom           -

All done.

# 列出使用 vdisk_blockio handler 的 Device
pjack@ubuntu3371:~$ sudo scstadmin -list_handler vdisk_blockio

Collecting current configuration: done.

        Handler           Device
        ------------------------
        vdisk_blockio    disk01

All done.


# 列出這個 device 的屬性
pjack@ubuntu3371:~$ sudo scstadmin -list_dev_attr disk01 -nonkey

Collecting current configuration: done.

        Attribute             Value                                          Writable      KEY
        --------------------------------------------------------------------------------------
        usn                   27cddc71                                       Yes           No
        blocksize             512                                            No            No
        t10_dev_id            27cddc71-disk01                                Yes           No
        rotational            1                                              No            No
        nv_cache              0                                              No            No
        type_string           Direct-access device (e.g., magnetic disk)     No            No
        removable             0                                              No            No
        read_only             0                                              No            No
        resync_size           < n a="">                                      Yes           No
        threads_num           1                                              Yes           No
        size_mb               1024                                           No            No
        write_through         0                                              No            No
        thin_provisioned      0                                              No            No
        handler               vdisk_blockio                                  No            No
        filename              /dev/rbd0                                      Yes           Yes
        dump_prs              < n a="">                                      Yes           No
        exported              < n a="">                                      No            No
        threads_pool_type     per_initiator                                  Yes           No
        type                  0                                              No            No


# 新增一個 LUN
pjack@ubuntu3371:~$ sudo scstadmin -add_lun 0 -driver iscsi -target iqn.2011-12.org.pjack:foo1 -device disk01

Collecting current configuration: done.


-> Making requested changes.
        -> Adding device 'disk01' at LUN 0 to driver/target 'iscsi/iqn.2011-12.org.pjack:foo1': done.
        -> Driver/target is not a fibre channel target, ignoring.
        -> Done.

All done.

# 透過 list_target 再多加 driver 參數, 可以看到這個 target 的 LUN
pjack@ubuntu3371:~$ sudo scstadmin -list_target iqn.2011-12.org.pjack:foo1 -driver iscsi

Collecting current configuration: done.

Driver: iscsi
Target: iqn.2011-12.org.pjack:foo1

Assigned LUNs:

        LUN  Device
        -----------
        0    disk01


All done.

# 看 LUN 的屬性
pjack@ubuntu3371:~$ sudo scstadmin -list_lun_attr 0 -driver iscsi -target iqn.2011-12.org.pjack:foo1 -nonkey

Collecting current configuration: done.

        Attribute     Value      Writable      KEY
        ------------------------------------------
        read_only     0          No            No
        device        disk01     No            No

All done.


# Enable Target
pjack@ubuntu3371:~$ sudo scstadmin -enable_target iqn.2011-12.org.pjack:foo1 -driver iscsi

Collecting current configuration: done.


-> Making requested changes.
        -> Enabling driver/target 'iscsi/iqn.2011-12.org.pjack:foo1': done.
        -> Done.

All done.

# 多了一個 rel_tgt_id 的屬性
pjack@ubuntu3371:~$ sudo scstadmin -list_tgt_attr iqn.2011-12.org.pjack:foo1 -driver iscsi

Collecting current configuration: done.

        Attribute      Value     Writable      KEY
        ------------------------------------------
        rel_tgt_id     1         Yes           Yes

        Dynamic attributes available
        ----------------------------
        allowed_portal
        OutgoingUser
        IncomingUser

        LUN CREATE attributes available
        -------------------------------
        read_only

All done.

# 把 iscsi enable
pjack@ubuntu3371:~$ sudo scstadmin -set_drv_attr iscsi -attributes enabled=1 -noprompt

Collecting current configuration: done.


-> Making requested changes.
        -> Enabling driver 'iscsi': done.
        -> Done, 0 change(s) made.

All done.

# 從另一台看是否能找到
pjack@ubuntu64-33-7:~$ sudo iscsiadm -m discovery -t st -p 172.16.33.71
172.16.33.71:3260,1 iqn.2011-12.org.pjack:foo1

# Login
pjack@ubuntu64-33-7:~/Git/WiStor/Node/src/wistor/ext/itri/iscsi$ sudo iscsiadm -m node -T iqn.2011-12.org.pjack:foo1 -p 172.16.33.71 -l
Logging in to [iface: default, target: iqn.2011-12.org.pjack:foo1, portal: 172.16.33.71,3260]
Login to [iface: default, target: iqn.2011-12.org.pjack:foo1, portal: 172.16.33.71,3260]: successful


# 回到本機看一下連線 session
pjack@ubuntu3371:~$ sudo scstadmin -list_sessions

Collecting current configuration: done.

Driver/Target: iscsi/iqn.2011-12.org.pjack:foo1

        Session: iqn.1993-08.org.debian:01:4e712cd57f99

        Attribute                    Value                                      Writable      KEY
        -----------------------------------------------------------------------------------------
        write_cmd_count              0                                          Yes           No
        HeaderDigest                 None                                       Yes           No
        sid                          10000023d0200                              Yes           No
        read_cmd_count               118                                        Yes           No
        bidi_io_count_kb             0                                          Yes           No
        commands                     0                                          Yes           No
        InitialR2T                   No                                         Yes           No
        MaxBurstLength               1048576                                    Yes           No
        MaxRecvDataSegmentLength     1048576                                    Yes           No
        active_commands              0                                          Yes           No
        none_cmd_count               7                                          Yes           No
        unknown_cmd_count            0                                          Yes           No
        ImmediateData                Yes                                        Yes           No
        MaxXmitDataSegmentLength     262144                                     Yes           No
        reinstating                  0                                          Yes           No
        FirstBurstLength             262144                                     Yes           No
        read_io_count_kb             354                                        Yes           No
        MaxOutstandingR2T            1                                          Yes           No
        bidi_cmd_count               0                                          Yes           No
        write_io_count_kb            0                                          Yes           No
        DataDigest                   None                                       Yes           No
        initiator_name               iqn.1993-08.org.debian:01:4e712cd57f99     Yes           No
        force_close                                                        Yes           No

# Logout
pjack@ubuntu64-33-7:~/Git/WiStor/Node/src/wistor/ext/itri/iscsi$ sudo iscsiadm -m node -T iqn.2011-12.org.pjack:foo1 -p 172.16.33.71 -u
Logging out of session [sid: 2, target: iqn.2011-12.org.pjack:foo1, portal: 172.16.33.71,3260]
Logout of [sid: 2, target: iqn.2011-12.org.pjack:foo1, portal: 172.16.33.71,3260]: successful

# disable target
pjack@ubuntu3371:~$ sudo scstadmin -disable_target iqn.2011-12.org.pjack:foo1 -driver iscsi -noprompt

Collecting current configuration: done.


-> Making requested changes.
        -> Disabling driver/target 'iscsi/iqn.2011-12.org.pjack:foo1': done.
        -> Done.

All done.

# remove lun
pjack@ubuntu3371:~$ sudo scstadmin -rem_lun 0 -driver iscsi -target iqn.2011-12.org.pjack:foo1 -device disk01 -noprompt

Collecting current configuration: done.


-> Making requested changes.
        -> Removing LUN 0 from driver/target 'iscsi/iqn.2011-12.org.pjack:foo1': done.
        -> Driver/target is not a fibre channel target, ignoring.
        -> Done.

All done.


# close the device
pjack@ubuntu3371:~$ sudo scstadmin -close_dev disk01 -handler vdisk_blockio -noprompt

Collecting current configuration: done.


-> Making requested changes.
        -> Closing device 'disk01' using handler 'vdisk_blockio': done.
        -> Driver/target is not a fibre channel target, ignoring.
        -> Driver/target is not a fibre channel target, ignoring.
        -> Done.

All done.

# remove the target
pjack@ubuntu3371:~$ sudo scstadmin -rem_target iqn.2011-12.org.pjack:foo1 -driver iscsi -noprompt

Collecting current configuration: done.


-> Making requested changes.
        -> Removing virtual target 'iqn.2011-12.org.pjack:foo1' from driver 'iscsi': done.
        -> Driver/target is not a fibre channel target, ignoring.
        -> Done.

All done.



http://iscsi-scst.sourceforge.net/SCST_Gentoo_HOWTO.txt
這篇裡面有不少設定 scstadmin 的範例

這篇大部份不透過 scstadmin 設定

這篇是滿早期的文章,有些已經不適用,包括安裝的 ppa 不能用,其它的部份則是可參考



這應該是把 scst 寫的最詳細的資料,而且有很多專有名詞的解釋及用法,改天應該要好好研究一下。
裡面有提到 /sys/kernel/scst_tgt/ 裡面的目錄結構,如果要查看每一個 target 有那一些連線,就要查看這個目錄,
/sys/kernel/scst_tgt/targets/iscsi//sessions

這是 scstadmin 官方的 README


https://git.ipxe.org/mirror/scst/.git/blob/master:/scstadmin/scstadmin.sysfs/scstadmin
這份有整理好的 scstadmin 指令


General Operations
-write_config < file>
Writes the current configuration to < file>.
-clear_config
Clear all SCST configuration.
Query Operations
-list_handler
List all available handlers
-list_handler [< hndlr>]
List all available device under specific handler
-list_driver
List all available drivers
-list_driver [< driver>]
List all available target under specific driver
-list_target
List all available targets
-list_target [< target>][-driver < driver>]
List all available LUN under specific target
List Attribute Operations
-list_scst_attr
List all attributes for SCST
-list_hnd_attr < hndlr>
List all attributes for a given handler.
-list_dev_attr < device>
List all attributes for a given device.
-list_drv_attr < driver>
List all attributes for a given driver.
-list_lun_attr < lun> -driver < driver> -target < target> [-group < group>]
List all attributes for a driver/target/lun
-list_sessions
List all current initiator sessions


# 看一下有支援那些 handler
pjack@ubuntu3371:~$ sudo scstadmin -list_handler

Collecting current configuration: done.

        Handler
        -------------
        vdisk_fileio
        vdisk_blockio
        vdisk_nullio
        vcdrom

All done.

# 看一下有支援那些 driver
pjack@ubuntu3371:~$ sudo scstadmin -list_driver

Collecting current configuration: done.

        Driver
        -----
        iscsi

All done.

# 看一下有 blockio 支援的屬性
pjack@ubuntu3371:~$ sudo scstadmin -list_hnd_attr vdisk_blockio -nonkey

Collecting current configuration: done.

        Attribute       Value                                          Writable      KEY
        --------------------------------------------------------------------------------
        type_string     Direct-access device (e.g., magnetic disk)     No            No
        disk01          < n a="">                                      Yes           No
        trace_level     out_of_mem                                     Yes           No
                        minor                                          Yes           No
                        pid                                            Yes           No
                        line                                           Yes           No
                        function                                       Yes           No
                        special                                        Yes           No
                        mgmt                                           Yes           No
                        mgmt_dbg                                       Yes           No
        type            0                                              No            No

        Possible trace levels:
          (use trace_level="add < level>", none, all or default to set):
                debug, function, line, pid, entryexit,
                buff, mem, sg, out_of_mem, special,
                scsi, mgmt, minor, mgmt_dbg, scsi_serializing,
                retry, recv_bot, send_bot, recv_top, pr,
                send_top, order,

        Device CREATE attributes available
        ----------------------------------
        blocksize
        write_through
        rotational
        nv_cache
        thin_provisioned
        filename
        removable
        read_only

# 看一下有 fileio 支援的屬性
pjack@ubuntu3371:~$ sudo scstadmin -list_hnd_attr vdisk_fileio -nonkey

Collecting current configuration: done.

        Attribute       Value                                          Writable      KEY
        --------------------------------------------------------------------------------
        type_string     Direct-access device (e.g., magnetic disk)     No            No
        trace_level     out_of_mem                                     Yes           No
                        minor                                          Yes           No
                        pid                                            Yes           No
                        line                                           Yes           No
                        function                                       Yes           No
                        special                                        Yes           No
                        mgmt                                           Yes           No
                        mgmt_dbg                                       Yes           No
        type            0                                              No            No

        Possible trace levels:
          (use trace_level="add < level>", none, all or default to set):
                debug, function, line, pid, entryexit,
                buff, mem, sg, out_of_mem, special,
                scsi, mgmt, minor, mgmt_dbg, scsi_serializing,
                retry, recv_bot, send_bot, recv_top, pr,
                send_top, order,

        Device CREATE attributes available
        ----------------------------------
        o_direct
        blocksize
        write_through
        rotational
        nv_cache
        thin_provisioned
        filename
        removable
        read_only

All done.

# 看一下有 nullio 支援的屬性
pjack@ubuntu3371:~$ sudo scstadmin -list_hnd_attr vdisk_nullio -nonkey

Collecting current configuration: done.

        Attribute       Value                                          Writable      KEY
        --------------------------------------------------------------------------------
        type_string     Direct-access device (e.g., magnetic disk)     No            No
        trace_level     out_of_mem                                     Yes           No
                        minor                                          Yes           No
                        pid                                            Yes           No
                        line                                           Yes           No
                        function                                       Yes           No
                        special                                        Yes           No
                        mgmt                                           Yes           No
                        mgmt_dbg                                       Yes           No
        type            0                                              No            No

        Possible trace levels:
          (use trace_level="add < level>", none, all or default to set):
                debug, function, line, pid, entryexit,
                buff, mem, sg, out_of_mem, special,
                scsi, mgmt, minor, mgmt_dbg, scsi_serializing,
                retry, recv_bot, send_bot, recv_top, pr,
                send_top, order,

        Device CREATE attributes available
        ----------------------------------
        removable
        blocksize
        read_only
        rotational

# 看一下有 cdrom 支援的屬性
pjack@ubuntu3371:~$ sudo scstadmin -list_hnd_attr vcdrom -nonkey

Collecting current configuration: done.

        Attribute       Value                Writable      KEY
        ------------------------------------------------------
        type_string     CD-ROM device        No            No
        trace_level     out_of_mem           Yes           No
                        minor                Yes           No
                        pid                  Yes           No
                        line                 Yes           No
                        function             Yes           No
                        special              Yes           No
                        mgmt                 Yes           No
                        mgmt_dbg             Yes           No
        type            5                    No            No

        Possible trace levels:
          (use trace_level="add < level>", none, all or default to set):
                debug, function, line, pid, entryexit,
                buff, mem, sg, out_of_mem, special,
                scsi, mgmt, minor, mgmt_dbg, scsi_serializing,
                retry, recv_bot, send_bot, recv_top, pr,
                send_top, order,

All done.

# 看一下有 iscsi driver 支援的屬性
pjack@ubuntu3371:~$ sudo scstadmin -list_drv_attr iscsi --nonkey

Collecting current configuration: done.

        Attribute            Value          Writable      KEY
        -----------------------------------------------------
        open_state           open           No            No
        isns_entity_name     < not set="">  Yes           No
        version              3.0.0-pre1     No            No
        trace_level          out_of_mem     Yes           No
                             minor          Yes           No
                             pid            Yes           No
                             line           Yes           No
                             function       Yes           No
                             special        Yes           No
                             mgmt           Yes           No
                             mgmt_dbg       Yes           No
                             conn           Yes           No
        iSNSServer           < not set="">  Yes           No
        enabled              0              Yes           No

        Possible trace levels:
          (use trace_level="add < level>", none, all or default to set):
                debug, function, line, pid, entryexit,
                buff, mem, sg, out_of_mem, special,
                scsi, mgmt, minor, mgmt_dbg, scsi_serializing,
                retry, recv_bot, send_bot, recv_top, pr,
                send_top, d_write, conn, conn_dbg, iov,
                pdu, net_page,

        Dynamic attributes available
        ----------------------------
        OutgoingUser
        IncomingUser



scstadmin script 內容


把原本的 IET 改接到 SCST,另外也有提到一些 performance fine tune 的建議,另外也有 /sys/kernel/scst_tgt/ 的目錄結構


http://linux-iscsi.org/index.php/ALUA
對於 ALUA 的解釋

Install SCST on Ubuntu 11.10 Server


因為安裝 SCST 需要 patch Linux Kernel,所以目前 Ubuntu 本身不支援這個方案,未來比較有可能支援的是 LIO,不過 LIO 還沒成熟,有支援 Multipath 功能的就只能使用 SCST, 所以目前就暫時先用這個方案了,但真的是一個很麻煩的東西。

Installation 的步驟,先參考這篇來 Patch Kernel
http://www.tomlecluse.be/blog/20110902/scst-and-scstadmin-ubuntu-1104

Install necessary packages
sudo apt-get install fakeroot kernel-wedge build-essential makedumpfile kernel-package libncurses5 libncurses5-dev
sudo apt-get build-dep --no-install-recommends linux-image-$(uname -r)

Get the current kernel source
mkdir /usr/src
cd /usr/src
apt-get source linux-image-$(uname -r)
ln -s /usr/src/linux-3.0.0 linux
cd linux-3.0.0

接下來參考這篇 http://iscsi-scst.sourceforge.net/iscsi-scst-howto.txt

Patch Kernel
svn co https://scst.svn.sourceforge.net/svnroot/scst/trunk scst
cd /usr/src/linux-3.0.0
patch -p1 < $HOME/scst/iscsi-scst/kernel/patches/put_page_callback-3.0.patch
patch -p1 < $HOME/scst/scst/kernel/scst_exec_req_fifo-3.0.patch
make clean
build kernel 之前要先產生 config 檔, 操作方式有好幾種可以選擇, 鳥哥裡面有一篇寫的很清楚,
http://linux.vbird.org/linux_basic/0540kernel.php
分別有 menuconfig / oldconfig / xconfig / gconfig / config 幾種方式

Build Kernel
make oldconfig
make && make modules
make modules_install && make install

Build SCST
make scst scst_install iscsi iscsi_install scstadm scstadm_install

Start SCST
modprobe scst
modprobe scst_vdisk
modprobe iscsi-scst
iscsi-scstd




2011年12月5日 星期一

iSCSI written by Greg Ferro 筆記

http://etherealmind.com/iscsi-network-designs-part-1-some-basics/

iSCSI initiator performance

When implementing iSCSI in your server operating system you have two choices, software or hardware (using Host Block Adapter).
  • Software: The TCP/IP packet is generated by the operating system using your core CPU
  • Hardware: Host Bus Adapter is a PCI card that performs the TCP processing. This is known as TCP Offload and the cards are generally known as TCP Offload Engines or TOE.

http://etherealmind.com/iscsi-network-designs-part-2-simple-scaling/

Increase the bandwidth

Use Link Aggregation Control Protocol (LACP) or Etherchannel to increase the bandwidth to between 2-6 gigabits per second

The are some pre-conditions:
1) server NICs and drivers must support LACP
2) switches must support LACP
3) switches must support enough LACP bundles. (cheaper switches may only support a few LACP bundles per switch).
4) all bundles must terminate on the same switch (or switch stack or chassis).



Software Initiators

  • using a general purpose CPU to perform the data transformation
  • it is not optimised for performance

TCP Offload Engines (TOE)

  • TOE cards are able to improve the TCP performance of a server

Host Bus Adapters

  • generic term for connecting the I/O bus of your server to an external system
  • iSCSI Header and Data Digest calculations are very CPU intensive. Only a full iSCSI offload HBA has the logic built into the ASIC to accelerate these calculations.
http://etherealmind.com/iscsi-part-4-fibrechannel-iscsi-integration/

None 


Redundancy


iSCSI implements its HA features. There are three ways to achieve this:
  1. Link Aggregation – LACP
  2. iSCSI Multipathing – Active / Standby
  3. iSCSI Multipathing – Active / Active

Link Aggregation – Etherchannel / LACP

  • two network cards in the servers
  • the two network cards must connect to the same Cisco switch (2)
  • network adapters and drivers must have support for LACP
  • at least one switch with supports LACP (sometimes know as Etherchannel)
  • you must be able to configure both the server drivers and switch configuration
    其實這不太算是 Redundany,因為 NIC 在同一台機器上,通常會壞的不是網卡,而是其它東西,機器本身如果出了問題,LACP 也幫不上忙,LACP 的好處是可以增加讀寫的 Performance,尤其是寫入的部份,作為 LB 倒是滿適合的。另外是也需要 Switch 有支援才能做到這個功能。

iSCSI Multipathing Active / Standby => MC/S (Multiple Connections per Session)

This is defined in the iSCSI RFC as the method for achieving high availability. The iSCSI initiator will initiate at least two TCP connections to the iSCSI target. Data will flow down the primary connection until a failure is detected and data will then be diverted to the second connection.


我覺得作者這部份的描述是錯誤的,找了很多資料,我認為圖的部份以及文字的部份是在描述 MC/S 這個方式,用 Active/Standby 來當標題並不合適

iSCSI Multipathing Active / Active => MPIO (Multi-Path Input/Output)

MPIO 本身有兩種方案,分別就是 Active/Standby 及 Active/Active,所以我覺得作者的標題下的不太正確,相關文章我覺得這篇寫的最清楚。

http://blog.xuite.net/weirchen/blog/22184665

現在支援較豐富的是 MPIO,我個人認為是因為 MC/S的限制較多,除了不能針對每一個 Lun 來做設定,他似乎也間接限定了 Target 的兩個連線必須連到同一台主機的兩個 NIC,不過這有待確認,但肯定的是如果主機背後是 Distributed Storage Server,那使用 MPIO 可以將連線連到不同的主機,只要他們能連接到同一塊 Volume。

Conclusion


2011年11月10日 星期四

iSCSI Target Management

收集一下目前可以管理 iSCSI Target 的東西,目前有使用過的

各種 Solution
比較
IET 的說明
  • A iSCSI target driver for Ethernet adapters, which tgt has used as a base for istgt

Tgt 的說明

  • Designed to work with multiple SCSI type devices and integrate them into the Linux kernel in a standard way
  • implementing a significant portion of tgt in user space while maintaining performance comparable to a target driver implemented in kernel space
  • The first author has maintained IET. The failure to push it into the mainline kernel is one of the reasons why tgt was born.

SCST 的說明
  • all the SCST components reside in kernel space



  1. 在使用上 IET 需要先設置 conf 檔案,雖然也可以用指令動態管理,但卻沒有方法更新 Conf 檔
  2. Tgt 則是全部用指令,之後再 output 設置到 conf 檔案
  3. Performance 似乎在 Kernal space 執行的  SCST 最好
  4. 根據這篇,似乎 Ubuntu 不支援 SCST,有點可惜
  5. LIO 還在開發中,但提供的介面很齊全,不管是 CLI or LIB 都有,在系統整合時應該會方便不少,但可惜它的穩定性以及開發時間都還無法滿足我的要求。


2011年9月20日 星期二

Export Ceph RBD with iSCSI

原本要使用 LIO , 但因為 Linux Kernel 2.6.38 似乎還沒把 iSCSI 整合進來, 所以就改用 iET (iSCSI Enterprise Target) 來試驗整個 Ceph 提供的 RBD (Rados Block Device)

如果對 iSCSI 還很不了解, 可以先從這兩篇開始了解
至於設定的部份可以參考這幾篇


第一步先從簡單的 partition 開始熟悉 iSCSI

設定 Target

root@ubuntu1104-64-5:/dev$ apt-get install iscsitarget
root@ubuntu1104-64-5:/dev$ apt-get install open-iscsi

安裝完出現警告訊息: iscsitarget not enabled in "/etc/default/iscsitarget", not starting... ... (warning). 這個問題需編輯設定檔:/etc/default/iscsitarget 將「ISCSITARGET_ENABLE=false」改為「ISCSITARGET_ENABLE=true」,iSCSI Target 服務才能作用。

接下來要設定 iET 的 /etc/iet/ietd.conf

iSNSServer 172.16.33.5
iSNSAccessControl No
Target iqn.2011-09.com.example:storage.lun1
# ubuntu1104--64--5-lvol1 是之前就切好的一塊 partition, 我們用fileio 來把它 release 出去
# ScsiId 及 ScsiSN 現在不知道是做什麼的, 暫時不管它
Lun 0 Path=/dev/mapper/ubuntu1104--64--5-lvol1,Type=fileio,ScsiId=xyz,ScsiSN=xyz
 

root@ubuntu1104-64-5:/dev$ /etc/init.d/iscsitarget restart
 * Removing iSCSI enterprise target devices:
   ...done.
 * Stopping iSCSI enterprise target service:
   ...done.
 * Removing iSCSI enterprise target modules:
   ...done.
 * Starting iSCSI enterprise target service
   ...done.
   ...done.


然後設定允許的連線 /etc/iet/initiators.allow, 末行顯示 ALL ALL 表示預設開放所有來源與目的連線,測試初期就先保持這樣了。

設定 Initiator

先把 /etc/iscsi/iscsid.conf 內的 node.startup 設成 automatic

# 重啟 initiator 的服務
root@ubuntu1104-64-6:/etc/iscsi$ /etc/init.d/open-iscsi restart
* Disconnecting iSCSI targets
...done.
* Stopping iSCSI initiator service
...done.
* Starting iSCSI initiator service iscsid
...done.
* Setting up iSCSI targets
...done.

# 然後尋找我們剛剛開出來的 iSCSI
root@ubuntu1104-64-6:/etc/iscsi$ iscsiadm -m discovery -t st -p 172.16.33.5
172.16.33.5:3260,1 iqn.2011-09.com.example:storage.lun1

root@ubuntu1104-64-6:/etc/iscsi# iscsiadm -m node
172.16.33.5:3260,1 iqn.2011-09.com.example:storage.lun1

# 如果有連結到, 應該會在這邊看到它的目錄
root@ubuntu1104-64-6:/etc/iscsi$ ll /etc/iscsi/nodes/
total 12
drw------- 3 root root 4096 2011-09-20 16:06 ./
drwxr-xr-x 5 root root 4096 2011-09-20 15:20 ../
drw------- 3 root root 4096 2011-09-20 16:06 iqn.2011-09.com.example:storage.lun1/

# 登入到這個節點, 不過基本上前面會自動登入, 所以在這個步驟可能會看到"already exists"
root@ubuntu1104-64-6:/etc/iscsi$ iscsiadm -m node -T iqn.2011-09.com.example:storage.lun1 -p 172.16.33.5 -l
Logging in to [iface: default, target: iqn.2011-09.com.example:storage.lun1, portal: 172.16.33.5,3260]
Login to [iface: default, target: iqn.2011-09.com.example:storage.lun1, portal: 172.16.33.5,3260]: successful

# 用 fdisk 看一下, 會看到多了個 sdb 這個 device, 然後有一個 sdb0 partition
root@ubuntu1104-64-6:/etc/iscsi$ fdisk -l
Disk /dev/sdb: 53.7 GB, 53687091200 bytes
64 heads, 32 sectors/track, 51200 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xe4a1139a

Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1       51200    52428784   83  Linux


# 格式化這個 partition
root@ubuntu1104-64-6:/etc/iscsi$ mkfs.ext4 /dev/sdb1
mke2fs 1.41.14 (22-Dec-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
3276800 inodes, 13107196 blocks
655359 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
400 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424

Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 35 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

# mount 起來
root@ubuntu1104-64-6:/data$ mount /dev/sdb1 /data/scsi

# 看一下所有 mount 的狀況
root@ubuntu1104-64-6:/data$ mount
/dev/mapper/ubuntu1104--64--6-root on / type ext4 (rw,errors=remount-ro)
proc on /proc type proc (rw,noexec,nosuid,nodev)
none on /sys type sysfs (rw,noexec,nosuid,nodev)
fusectl on /sys/fs/fuse/connections type fusectl (rw)
none on /sys/kernel/debug type debugfs (rw)
none on /sys/kernel/security type securityfs (rw)
none on /dev type devtmpfs (rw,mode=0755)
none on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)
none on /dev/shm type tmpfs (rw,nosuid,nodev)
none on /var/run type tmpfs (rw,nosuid,mode=0755)
none on /var/lock type tmpfs (rw,noexec,nosuid,nodev)
/dev/sda1 on /boot type ext2 (rw)
/dev/mapper/ubuntu1104--64--6-lvol0 on /data/osd.2 type btrfs (rw,noatime)
/dev/mapper/ubuntu1104--64--6-lvol1 on /data/osd.3 type btrfs (rw,noatime)
/dev/sdb1 on /data/scsi type ext4 (rw)

# 看一下 partition 的使用狀況
root@ubuntu1104-64-6:/data$ df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/mapper/ubuntu1104--64--6-root
47328184   2595704  42328336   6% /
none                  12358244       224  12358020   1% /dev
none                  12366300         0  12366300   0% /dev/shm
none                  12366300        48  12366252   1% /var/run
none                  12366300         0  12366300   0% /var/lock
/dev/sda1               233191     45272    175478  21% /boot
/dev/mapper/ubuntu1104--64--6-lvol0
52428800   1033620  49277220   3% /data/osd.2
/dev/mapper/ubuntu1104--64--6-lvol1
52428800   1034584  49276440   3% /data/osd.3
/dev/sdb1             51606124    184136  48800552   1% /data/scsi

如果要把 iscsi 的連結斷掉

iscsiadm -m node -T iqn.2011-09.com.example:storage.lun1 -p 172.16.33.5 -u

Create Ceph RBD

參考連結: http://ceph.newdream.net/wiki/RBD

# 製造一個 rbd , 大小為 5G
root@ubuntu1104-64-5:/dev/rbd/rbd$ rbd create goo --size 5120

# 看目前在 rbd 內的 list
root@ubuntu1104-64-5:/dev/rbd/rbd$ rbd list
foo

# 從 rbd 去觀察 foo
root@ubuntu1104-64-5:~$ rbd info foo
rbd image 'foo':
        size 5120 MB in 1280 objects
        order 22 (4096 KB objects)
        block_name_prefix: rb.0.3
        parent:  (pool -1)

# 從 rados 去看一下 rbd 的狀況, 可以發現多了一個 foo.rbd
root@ubuntu1104-64-5:~$ rados ls -p rbd
foo.rbd
rb.0.1.000000000000
rb.0.1.000000000001
rbd_directory
rbd_info

root@ubuntu1104-64-5:~$ modprobe rbd

# 把 rbd 加到系統內, 等下才看的到這個 device
root@ubuntu1104-64-5:/dev$ echo "172.16.33.5 name=admin,secret=AQDeRGdOMNL3MhAAuzvelwICjpYhLIk7IMcX2g== rbd foo" > /sys/bus/rbd/add
root@ubuntu1104-64-5:/dev$ mknod /dev/rbd0 b 254 0


# 看一下 rbd device 有沒有出現
root@ubuntu1104-64-5:~$ ls /sys/bus/rbd/devices
0
root@ubuntu1104-64-5:~$ ls /dev/rbd/rbd
foo:0

# format rbd0
root@ubuntu1104-64-5:/dev$ mkfs -t ext3 /dev/rbd0
mke2fs 1.41.14 (22-Dec-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
327680 inodes, 1310720 blocks
65536 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1342177280
40 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736

Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information:
done

# mount 起來
root@ubuntu1104-64-5:/dev$ mount -t ext3 /dev/rbd0 /mnt

root@ubuntu1104-64-5:/dev$ df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/ubuntu1104--64--5-root
                       46G  6.6G   37G  16% /
none                   12G  228K   12G   1% /dev
none                   12G     0   12G   0% /dev/shm
none                   12G   64K   12G   1% /var/run
none                   12G     0   12G   0% /var/lock
/dev/sda1             228M   45M  172M  21% /boot
/dev/mapper/ubuntu1104--64--5-lvol2
                       50G  1.1G   47G   3% /data/osd.0
/dev/mapper/ubuntu1104--64--5-lvol0
                       50G  1.1G   47G   3% /data/osd.1
/dev/rbd0             5.0G  139M  4.6G   3% /mnt

# 測試完畢, 再將它 umount
root@ubuntu1104-64-5:/dev$ umount /mnt

Export RBD via iSCSI

可以參考 http://ceph.newdream.net/wiki/ISCSI
首先改 /etc/iet/ietd.conf 裡面的設定

Target iqn.2011-09.net.newdream.ceph:rados.iscsi.001
        # 記得要使用 blockio, 而不是 fileio
        Lun 0 Path=/dev/rbd0,Type=blockio

然後分別重啟 target 及 Initiator, 步驟和上面的一樣,

root@ubuntu1104-64-7:~$ fdisk -l

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000c4797

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          32      248832   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              32       60802   488134657    5  Extended
/dev/sda5              32       60802   488134656   8e  Linux LVM

Disk /dev/sdb: 5368 MB, 5368709120 bytes
166 heads, 62 sectors/track, 1018 cylinders
Units = cylinders of 10292 * 512 = 5269504 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

# 因為是用 blockio 當成一個 device export 出來, 所以上面沒有任何 partition
Disk /dev/sdb doesn't contain a valid partition table

# 直接 mount 起來
root@ubuntu1104-64-7:~$ mount /dev/sdb /mnt

# 看一下狀況, 多了一個 5G 的 sdb
root@ubuntu1104-64-7:~$ df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/ubuntu1104--64--7-root
                      435G   11G  402G   3% /
none                   12G  216K   12G   1% /dev
none                   12G     0   12G   0% /dev/shm
none                   12G   60K   12G   1% /var/run
none                   12G     0   12G   0% /var/lock
/dev/sda1             228M   45M  172M  21% /boot
/dev/sdb              5.0G  139M  4.6G   3% /mnt

大致上這樣就完成啦! 收工~