iSCSIを使用してストレージサーバの構築をしてみた。
まずscsi-target-utilsをインストールします。
# yum install scsi-target-utils
|
次にディスク領域を作成します。今回は「/mnt/iscsi」以下に30GBのディスクイメージを作成して使用します。
# mkdir /mnt/iscsi
# dd if=/dev/zero of=/mnt/iscsi/disk1.img bs=1M count=30720
# ls -l /mnt/iscsi/
合計 31488036
-rw-r--r-- 1 root root 32212254720 10月 17 08:44 disk1.img
|
iSCSIターゲットを作成します。targetnameは命名規則に従い指定します。
iqn.yyyy-mm.naming-authority:unique name
# tgtadm --lld iscsi --op new --mode target --tid 0 --targetname iqn.2006-10.com.fujitoko.iscsi:target1
|
作成したターゲットの確認をします。
# tgtadm --lld iscsi --op show --mode target
Target 1: iqn.2009-6.com.fujitoko.iscsi:target1
System information:
Driver: iscsi
State: ready
I_T nexus information:
LUN information:
LUN: 0
Type: controller
SCSI ID: deadbeaf0:0
SCSI SN: beaf00
Size: 0 MB
Online: Yes
Removable media: No
Backing store: No backing store
Account information:
ACL information:
|
/etc/tgt/targets.conf を編集します。
今回は192.168.1.111からのみ接続できるようにしました。
# vi /etc/tgt/targets.conf
# TGTD example targets file
#
# Example iSCSI target with one LUN.
# This gets read when "service tgtd start" is run.
#
<target iqn.2006-10.com.fujitoko.iscsi:target1>
# List of files to export as LUNs
#backing-store /usr/storage/disk_1.img
backing-store /mnt/iscsi/disk1.img
# Authentication :
# if no "incominguser" is specified, it is not used
#incominguser backup secretpass12
# Access control :
# defaults to ALL if no "initiator-address" is specified
#initiator-address 192.168.1.2
initiator-address 192.168.1.111
</target> |
tgtdを起動します。
# /etc/init.d/tgtd start
Starting SCSI target daemon: [ OK ]
|
サーバ起動時にtgtdが起動するようにします。
# chkconfig --list tgtd
tgtd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
# chkconfig tgtd on
# chkconfig --list tgtd
tgtd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
|
作成したターゲットを確認します。
# tgtadm --lld iscsi --op show --mode target
Target 1: iqn.2006-10.com.fujitoko.iscsi:target1
System information:
Driver: iscsi
State: ready
I_T nexus information:
LUN information:
LUN: 0
Type: controller
SCSI ID: deadbeaf1:0
SCSI SN: beaf10
Size: 0 MB
Online: Yes
Removable media: No
Backing store: No backing store
LUN: 1
Type: disk
SCSI ID: deadbeaf1:1
SCSI SN: beaf11
Size: 32212 MB
Online: Yes
Removable media: No
Backing store: /mnt/iscsi/disk1.img
Account information:
ACL information:
192.168.1.111
|
これでサーバ側の設定は完了です。
イニシエータから接続してみます。
※XPで接続しましたのでダウンロードセンターから
「Microsoft iSCSI Software Initiator」をダウンロードしました。
接続後、ローカルディスク同様の手順でフォーマットし、読み書きのテストを行いましょう。
問題がなければ完了です。
ストレージサーバが構築できました。
|