LoginSignup
5
7

More than 5 years have passed since last update.

【Ubuntu】iSCSIのターゲット・イニシエーターを構築してサクッとSpeedTestをする

Posted at

なにこれ

iSCSI(IPネットワークを利用してStorage Area Networkを構築可能なプロトコル)の入門の為に、iSCSIターゲットとiSCSIイニシエータを構築し、簡単なR/W速度テストを実施してみました。その時の忘備録です。

今回の構築・テスト環境は下記の環境で実施しています。
RouterもEthernetケーブルもL2スイッチ(図中省略)もGIGABIT対応のものを使っています。

+-----------------------------+
|   Router                    |
|   CISCO C841M-4X-JSEC/K9    |
|   172.20.0.1                |
+--------+--------------------+
         |
         +------------------------------+
         |                              |
  +------+---------------------+  +----------+----------+
  |  INITIATOR                 |  |  TARGET             |
  |  DELL XPS 8300             |  |  Fujitsu RX300S6    |
  |  (Ubuntu 16.04 on Vagrant) |  |  (Ubuntu 16.04)     |
  |    172.20.0.3              |  |     172.20.0.6      |
  +----------------------------+  +---------------------+

手順中に出てくるIPアドレス、ユーザー名・パスワードは環境に応じて変更してください。

手順

ターゲット側(つながれる方)

# 必要なパッケージのインストール
root@target:~# apt-get -y install iscsitarget iscsitarget-dkms
# iSCSIでアクセスさせるディスク領域の初期化
root@target:~# mkdir /var/iscsi_disks 
root@target:~# dd if=/dev/zero of=/var/iscsi_disks/disk01.img count=0 bs=1 seek=10G
# iSCSIターゲットの有効化
root@target:~# vi /etc/default/iscsitarget
ISCSITARGET_ENABLE=true
# iSCSIターゲットの設定(下記を最終行に追記)
root@target:~# vi /etc/iet/ietd.conf
Target iqn.2018-01.tokyo.tgr:target00
    Lun 0 Path=/var/iscsi_disks/disk01.img,Type=fileio
    initiator-address 172.20.0.3
    incominguser username password
root@target:~# systemctl restart iscsitarget

イニシエーター側(つなぐ方)

# 必要なものをいれる
root@initiator:~# apt-get -y install open-iscsi
# 認証方法にCHAPを選択し、ユーザー名・パスワードを指定する
root@initiator:~# vi /etc/iscsi/iscsid.conf
node.session.auth.authmethod = CHAP
node.session.auth.username = username
node.session.auth.password = password
# ターゲットを見つけ出す
root@initiator:~# iscsiadm -m discovery -t sendtargets -p 172.20.0.6
172.20.0.6:3260,1 iqn.2018-01.tokyo.tgr:target00
# ターゲットに接続する
root@initiator:~# iscsiadm -m node -p 172.20.0.6 --login
Logging in to [iface: default, target: iqn.2018-01.tokyo.tgr:target00, portal: 172.20.0.6,3260] (multiple)
Login to [iface: default, target: iqn.2018-01.tokyo.tgr:target00, portal: 172.20.0.6,3260] successful.
# セッション一覧を表示して接続確認する
root@initiator:~# iscsiadm -m session -o show
tcp: [1] 172.20.0.6:3260,1 iqn.2018-01.tokyo.tgr:target00 (non-flash)


ディスク領域の初期化

# パーティーションテーブルの初期化
root@initiator:~# parted --script /dev/sdb "mklabel msdos"
root@initiator:~# parted --script /dev/sdb "mkpart primary 0% 100%"
# ext4で初期化する
root@initiator:~# mkfs.ext4 /dev/sdb1
mke2fs 1.42.13 (17-May-2015)
Creating filesystem with 2621184 4k blocks and 655360 inodes
Filesystem UUID: fea7d38f-f896-40ec-a8d7-f2953f65414b
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

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

ファイルシステムとしてマウントする

root@initiator:~# mount /dev/sdb1 /mnt
root@initiator:~# df -hT
Filesystem                   Type      Size  Used Avail Use% Mounted on
/dev/sdb1                    ext4      9.8G   23M  9.2G   1% /mnt

簡単なパフォーマンステスト

Write

ddを使って1GBのダミーロードを書き込む。

root@initiator:~# dd if=/dev/zero of=/mnt/aaa bs=1M count=1024
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 12.0705 s, 89.0 MB/s

Read

hdparamを使った読み込み速度テスト。

root@initiator:~# hdparm -t /dev/sdb1

/dev/sdb1:
 Timing buffered disk reads: 168 MB in  3.01 seconds =  55.85 MB/sec

まとめ

  • iSCSIを活用して別HOSTにあるディスク(正確には仮想的なディスクのイメージ)をマウントできた
  • 読み込み55.9 MB/s(447 MBps)・書き込み 89.0 MB/s (712 MBps)の書き込み速度が得られた。読み込みのほうがもっと早いイメージがあったが、意外な結果になったので調査中。
  • Windows標準搭載のiSCSIイニシエーターだと、CHAP認証関連のエラーで接続ができなかった。
  • とりあえず、iSCSIに手軽に入門できた
5
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
7