Arch LinuxでLIOを使う(iSCSI Target)
Arch Linuxで手軽に使えるiSCSI Targetは無いかと調べていたら、Kernel 2.6.38以降ではLIOというターゲットがすでに標準で使えるらしい。
iSCSIの他にもFibre Channel (QLogic), FCoE,InfiniBandに対応していて、かなり高機能。
さらにはSCSI-3 Persistent reservationsにも対応しており、MSFC用としても良さそうなので早速試してみる。
※機能詳細は公式Web参照
LIO本体は上述の通りカーネルモジュール(target_core_mod 等)となるため、あとは設定ツールのみ用意する。
ツールには標準の「lio-util」もしくはブランチとなる「targetcli-fb」が存在し、今回は設定が容易な後者を選択する。
・環境
OS: Arch Linux (3.3.7-1-ARCH) (32-bit)
ターゲットディスク: /dev/sda4
IPアドレス(IP-SAN用): 2.2.2.1/24
・前提
各パッケージの依存関係解決が大変なので、yaouortを使用する。
・yaourtのインストール
# pacman -Sy diffutils gettext yajl # cd /usr/local/src # wget https://aur.archlinux.org/packages/pa/package-query/package-query.tar.gz # tar xvzf package-query.tar.gz # cd package-query # makepkg --asroot ; echo $? # pacman -U package-query-1.0.1-1-i686.pkg.tar.xz # cd ../ # wget https://aur.archlinux.org/packages/ya/yaourt/yaourt.tar.gz # tar xvzf yaourt.tar.gz # cd yaourt # makepkg --asroot ; echo $? # pacman -U yaourt-1.1-1-any.pkg.tar.xz # cd ../
・targetcli-fbのインストール
# pacman -Sy python2-distribute # yaourt targetcli-fb ※「Edit PKGBUILD ?」は「N」、その他は「Y」で。
・LIOの起動
# /etc/rc.d/target start :: Mounting configfs [DONE] :: Starting lio targets [BUSY] Warning: Could not load preferences file /root/.targetcli/prefs.bin. Restore file /etc/target/saveconfig.json not found [DONE] ※configはまだ作成していないのでnot foundで問題なし
・ターゲットディスクのPATH確認
ディスクの指定にPCIのパスを使用する為、事前確認。
# ls -l /dev/disk/by-path total 0 lrwxrwxrwx 1 root root 9 Jun 2 17:42 pci-0000:00:10.0-scsi-0:0:0:0 -> ../../sda lrwxrwxrwx 1 root root 10 Jun 2 17:42 pci-0000:00:10.0-scsi-0:0:0:0-part1 -> ../../sda1 lrwxrwxrwx 1 root root 10 Jun 2 17:42 pci-0000:00:10.0-scsi-0:0:0:0-part2 -> ../../sda2 lrwxrwxrwx 1 root root 10 Jun 2 17:42 pci-0000:00:10.0-scsi-0:0:0:0-part3 -> ../../sda3 lrwxrwxrwx 1 root root 10 Jun 2 17:42 pci-0000:00:10.0-scsi-0:0:0:0-part4 -> ../../sda4
・LIO設定 - 初期状態
# targetcli Welcome to the targetcli shell: Copyright (c) 2011 by RisingTide Systems LLC. For help on commands, type 'help'. /> /> /> ls o- / ................................ [...] o- backstores ..................... [...] | o- block ........... [0 Storage Object] | o- fileio .......... [0 Storage Object] | o- pscsi ........... [0 Storage Object] | o- ramdisk ......... [0 Storage Object] o- ib_srpt .................. [Not found] o- iscsi ..................... [0 Target] o- loopback .................. [0 Target] o- qla2xxx .................. [Not found] o- tcm_fc ................... [Not found] />
・LIO設定 - ターゲットブロック作成
/> cd backstores/block /backstores/block> create block0 /dev/disk/by-path/ pci-0000:00:10.0-scsi-0:0:0:0-part4 Created block storage object block0 using /dev/disk/by-path/pci-0000:00:10.0-scsi-0:0:0:0-part4. Entering new node /backstores/block/block0 /backstores/block>
・LIO設定 - ターゲットiqn作成
/backstores/block/block0> cd /iscsi /iscsi> /iscsi> create Created target iqn.2003-01.org.linux-iscsi.arch01.i686:sn.0e7067a5552a. Created TPG 1. Entering new node /iscsi/iqn.2003-01.org.linux-iscsi.arch01.i686:sn.0e7067a5552a/tpg1 /iscsi/iqn.20...67a5552a/tpg1> /iscsi/iqn.20...67a5552a/tpg1> /iscsi/iqn.20...67a5552a/tpg1> ls o- tpg1 .............. [enabled, auth] o- acls .................... [0 ACL] o- luns .................... [0 LUN] o- portals .............. [0 Portal] /iscsi/iqn.20...67
・LIO設定 - Lun作成
/iscsi/iqn.20...67a5552a/tpg1> cd luns /iscsi/iqn.20...52a/tpg1/luns> create /backstores/block/block0 Created LUN 0. Entering new node /iscsi/iqn.2003-01.org.linux-iscsi.arch01.i686:sn.0e7067a5552a/tpg1/luns/lun0 /iscsi/iqn.20...pg1/luns/lun0>
・LIO設定 - ポータル作成(リッスンIP,ポート指定)
/iscsi/iqn.20...pg1/luns/lun0> cd ../../portals /iscsi/iqn.20.../tpg1/portals> /iscsi/iqn.20.../tpg1/portals> create 2.2.2.1 ip_port=3260 Using default IP port 3260 Created network portal 2.2.2.1:3260. Entering new node /iscsi/iqn.2003-01.org.linux-iscsi.arch01.i686:sn.0e7067a5552a/tpg1/portals/2.2.2.1:3260 /iscsi/iqn.20...8.122.10:3260>
・LIO設定 - イニシエーターリスト作成
/iscsi/iqn.20...8.122.10:3260> cd ../../acls /iscsi/iqn.20...52a/tpg1/acls> /iscsi/iqn.20...52a/tpg1/acls> create iqn.2005-03.org.open-iscsi:hogehoge Created Node ACL for iqn.2005-03.org.open-iscsi:hogehoge Created mapped LUN 0. Entering new node /iscsi/iqn.2003-01.org.linux-iscsi.arch01.i686:sn.0e7067a5552a/tpg1/acls/iqn.2005-03.org.open-iscsi:hogehoge /iscsi/iqn.20...scsi:hogehoge> ※必要なホストの数だけ登録する。
・LIO設定 - CHAP認証無効化
CHAP認証を使用しないため、デフォルト値より変更
/iscsi/iqn.20...scsi:hogehoge> cd /iscsi/iqn.2003-01.org.linux-iscsi.arch01.i686:sn.0e7067a5552a/tpg1/ /iscsi/iqn.20...67a5552a/tpg1> /iscsi/iqn.20...67a5552a/tpg1> set attribute authentication=0 Parameter authentication is now '0'. /iscsi/iqn.20...67a5552a/tpg1>
・LIO設定 - 設定確認
/iscsi/iqn.20...67a5552a/tpg1> cd / /> /> ls o- / .................................. [...] o- backstores ....................... [...] | o- block ............. [1 Storage Object] | | o- block0 [/dev/disk/by-path/pci-0000:00:10.0-scsi-0:0:0:0-part4 activated] | o- fileio ............ [0 Storage Object] | o- pscsi ............. [0 Storage Object] | o- ramdisk ........... [0 Storage Object] o- ib_srpt .................... [Not found] o- iscsi ....................... [1 Target] | o- iqn.2003-01.org.linux-iscsi.arch01.i686:sn.0e7067a5552a ......... [1 TPG] | o- tpg1 ..................... [enabled] | o- acls ..................... [1 ACL] | | o- iqn.2005-03.org.open-iscsi:hogehoge ................ [1 Mapped LUN] | | o- mapped_lun0 .......... [lun0 block/block0 (rw)] | o- luns ..................... [1 LUN] | | o- lun0 [block/block0 (/dev/disk/by-path/pci-0000:00:10.0-scsi-0:0:0:0-part4)] | o- portals ............... [1 Portal] | o- 2.2.2.1:3260 .............. [OK] o- loopback .................... [0 Target] o- qla2xxx .................... [Not found] o- tcm_fc ..................... [Not found]
・LIO設定 - 設定保存
/> saveconfig Existing file /etc/target/saveconfig.json backed up to saveconfig.json.backup Configuration saved to /etc/target/saveconfig.json /> /> exit Global pref auto_save_on_exit=true Existing file /etc/target/saveconfig.json backed up to saveconfig.json.backup Configuration saved to /etc/target/saveconfig.json
・起動確認
# netstat -anp | grep -i listen tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 270/sshd tcp 0 0 2.2.2.1:3260 0.0.0.0:* LISTEN - tcp6 0 0 :::22 :::* LISTEN 270/sshd tcp6 0 0 :::80 :::* LISTEN 578/httpd
・自動起動設定
# cp -p /etc/rc.conf /etc/rc.conf.20120601 # vi /etc/rc.conf # diff -wb /etc/rc.conf.20110601 /etc/rc.conf 119c119 < DAEMONS=(hwclock syslog-ng net-profiles sshd netfs crond) --- > DAEMONS=(hwclock syslog-ng net-profiles sshd netfs crond target) #
以上