Linux

Proxmox VE (Debian 7) 上的基本 iSCSI 目標設置不起作用

  • December 16, 2013

我在我的磁碟上創建了一個 Linux LVM 分區,並希望通過 iSCSI 在網路上共享它。但是,使用 iscsiadm(本地和遠端)無法訪問目標。設置如下所示。

有人知道我無法連接/發現我的 iSCSI 目標的原因嗎?(如果您需要更多資訊,請告訴我。)

在我的設置中,node01 在 Proxmox VE 3.1 (Debian 7) 上執行,DNS 名稱為 node01.domain.name,靜態 IP 地址為 192.168.0.1:

$ Linux node01 2.6.32-23-pve #1 SMP Tue Aug 6 07:04:06 CEST 2013 x86_64 GNU/Linux

創建 LVM 卷組:

$ fdisk /dev/sdf

Command (m for help): p

Disk /dev/sdf: 2000.4 GB, 2000398934016 bytes
81 heads, 63 sectors/track, 765633 cylinders, total 3907029168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x9f0d1cbd

  Device Boot      Start         End      Blocks   Id  System
/dev/sdf1            2048  3907029167  1953513560   8e  Linux LVM

Command (m for help): q

$ pvcreate /dev/sdf1
 Physical volume "/dev/sdf1" successfully created
$ vgcreate myvg /dev/sdf1
 Volume group "myvg" successfully created

iSCSI 目標設置:

$ sudo apt-get install iscsitarget
Then I have changed the configuration files as follows ...
$ more /etc/default/iscsitarget
ISCSITARGET_ENABLE=true
# ietd options
# See ietd(8) for details
ISCSITARGET_OPTIONS=""
$  more /etc/iet/ietd.conf
Target iqn.2099-12.name.domain:storage01.lun1
       Lun 0 Path=/dev/sdf1,Type=blockio
       Alias LUN1

$ more /etc/iet/initiators.allow
#ALL ALL
iqn.2099-12.name.domain:storage01.lun1 192.168.0.1, 192.168.0.2, 192.168.0.3, 192.168.0.4, 192.168
.0.5, 192.168.0.6
$ /etc/init.d/iscsitarget restart
Removing iSCSI enterprise target devices: :.
Removing iSCSI enterprise target modules: :.
Starting iSCSI enterprise target service:.
.

iSCSI 測試:

$ iscsiadm -m discovery -t st -p node01.domain.name
iscsiadm: cannot make connection to 192.168.0.1: Connection refused
iscsiadm: cannot make connection to 192.168.0.1: Connection refused
iscsiadm: cannot make connection to 192.168.0.1: Connection refused
iscsiadm: cannot make connection to 192.168.0.1: Connection refused
iscsiadm: cannot make connection to 192.168.0.1: Connection refused
iscsiadm: cannot make connection to 192.168.0.1: Connection refused
iscsiadm: connection login retries (reopen_max) 5 exceeded
iscsiadm: Could not perform SendTargets discovery: encountered connection failure

這並不是對我自己的問題的粗魯回答,而是真的是我的“解決方案”:

apt-get purge iscsitarget
apt-get install tgt

# Unfortunately, on my version of Proxmox VE there is no init.d script to start and stop tgtd. As a consequence, I need to go nasty ways of workarounds to start and stop tgtd on startup/shutdown/restart. See below:
/usr/sbin/tgtd
tgtadm --lld iscsi --op new --mode target --tid 1 -T iqn.2099-12.name.domain:storage01
tgtadm --lld iscsi --op new --mode logicalunit --tid 1 --lun 1 -b /dev/sdf1
tgtadm --lld iscsi --op bind --mode target --tid 1 -I 192.168.0.1, 192.168.0.2, 192.168.0.3, 192.168.0.4, 192.168
.0.5, 192.168.0.6

# To see if everything is configured correctly, use this:
tgtadm --lld iscsi --op show --mode target

在發起方方面,執行以下操作:

iscsiadm --mode discovery --type sendtargets --portal 192.168.0.1
# Shows this output: 192.168.0.1:3260,1 iqn.2099-12.name.domain:storage01

# This creates a volume /dev/sdg and partition /dev/sdg1
iscsiadm --mode node --targetname iqn.2099-12.name.domain:storage01 --portal 192.168.0.1:3260 --login

有關更多資訊,請參見此處:http ://www.cyberciti.biz/tips/howto-setup-linux-iscsi-target-sanwith-tgt.html

要使其永久化,請在目標端使用它:

tgtadm --dump > /etc/tgt/targets.conf

# Add this to /etc/rc.local
/usr/sbin/tgtd
tgt-admin --execute

要進行乾淨的“註銷”,請將其添加到啟動端關閉的腳本中

# Some code to turn off your disk users
iscsiadm --mode node --targetname iqn.2099-12.name.domain:storage01 --portal 192.168.0.1:3260 --logoff
rm /dev/sdg

引用自:https://serverfault.com/questions/557013