參考網頁:
鳥哥的 Linux 私房菜 — 網路磁碟裝置:iSCSI伺服器
1. 安裝 scsi-target-utils
# yum install scsi-target-utils
2. 建立目錄
# mkdir /iscsi_disks
3. 建立檔案 10G 分享
# dd if=/dev/zero of=/iscsi_disks/centos6-disk.img bs=1M count=10240
10240+0 records in
10240+0 records out
10737418240 bytes (11 GB) copied, 125.961 s, 85.2 MB/s
[@more@]4. 設定 tgt 設定檔 /etc/tgt/targets.conf
backing-store – 虛擬裝置
initiator-address – 可以連線的來源 IP 網段,也可以在防火牆上設定
incominguser – 使用者帳號及密碼設定
write-cache – 是否要使用快取
# vim /etc/tgt/targets.conf
<target iqn.2017-04.tces.test:centos6>
backing-store /iscsi_disks/centos6-disk.img
initiator-address 192.168.1.0/24
incominguser username password
write-cache off
</target>
5. 啟動服務
# chkconfig –level 3 tgtd on
# /etc/init.d/tgtd start
正在啟動 SCSI target daemon: [ 確定 ]
# netstat -antulp | grep 3260
tcp 0 0 0.0.0.0:3260 0.0.0.0:* LISTEN 1682/tgtd
tcp 0 0 :::3260 :::* LISTEN 1682/tgtd
6. 防火牆設定
# iptables -A INPUT -s 192.168.1.0/24 -m tcp -p tcp -m state –state NEW –dport 3260 -j ACCEPT
7. 顯示 target 相關資訊
# /usr/sbin/tgt-admin –show
Target 1: iqn.2017-04.tces.test:centos6
System information:
Driver: iscsi
State: ready
I_T nexus information:
LUN information:
LUN: 0
Type: controller
SCSI ID: IET 00010000
SCSI SN: beaf10
Size: 0 MB, Block size: 1
Online: Yes
Removable media: No
Prevent removal: No
Readonly: No
Backing store type: null
Backing store path: None
Backing store flags:
Account information:
ACL information: