Difference between revisions of "TGT iSCSI Target"

From ArchWiki
Jump to: navigation, search
m (add ja link)
 
(13 intermediate revisions by 6 users not shown)
Line 1: Line 1:
 
[[Category:Storage]]
 
[[Category:Storage]]
 +
[[ja:TGT iSCSI ターゲット]]
 
[[nl:TGT iSCSI Target]]
 
[[nl:TGT iSCSI Target]]
{{Poor writing|Dutch article is the original, English is not my native language.}}
+
{{Related articles start}}
 
+
{{Related|iSCSI Target}}
{{Article summary start}}
+
{{Related|iSCSI Boot}}
{{Article summary text|Installation and configuration of TGT as iSCSI target }}
+
{{Related articles end}}
{{Article summary heading|Related}}
+
{{Article summary wiki|iSCSI Target}}
+
{{Article summary wiki|iSCSI Boot}}
+
{{Article summary end}}
+
  
 
The [http://stgt.sourceforge.net TGT SCSI framework] can be used for several storage protocols. This document describes the usage of TGT as iSCSI target.
 
The [http://stgt.sourceforge.net TGT SCSI framework] can be used for several storage protocols. This document describes the usage of TGT as iSCSI target.
  
==Why TGT==
+
==About TGT==
  
There are several different iSCSI targets for Linux available, with more or less the same performance. TGT has the following advantages:
+
STGT was introduced into the Linux kernel at the end of 2006 by Fujita Tomonori. It has a library in the kernel which assists the in-kernel target drivers. All target processing happens in user space. At the end of 2010, the LIO project was chosen to replace STGT as the in-kernel SCSI target implementation. When LIO was chosen to replace STGT, its implementation has been adapted to allow STGT userspace modules to continue functioning, therefore the STGT community has supported the LIO inclusion in the kernel.
  
 +
Advantages:
 
* active development
 
* active development
* the only iSCSI target that can be used for vSphere environments
+
* simplicity
 +
* support for iSCSI for Ethernet NICs, iSER, virtual SCSI target driver for IBM pSeries
 +
* supports virtual disks, DVDs, VTLs, RADOS block devices (rbd)
 +
* supports SCSI UNMAP
 +
 
 +
As a disadvantage some developers and users have argued that because the target processing happens in user space, in some cases this may lead to performance bottlenecks.
 +
However, using 'aio' type LUNs gives a huge performance boost. AIO should only be used in environments that are safe against power loss.
  
 
==Installation==
 
==Installation==
  
The {{AUR|tgt}} software must be deployed from [[AUR]].  
+
Install the {{AUR|tgt}} package. If you want to use the direct store, then {{Pkg|sg3_utils}} must also be installed.
If you want to use the direct store, then sg3_utils must be deployed from the <nowiki>[</nowiki>[https://www.archlinux.org/packages/?sort=&repo=Extra extra]<nowiki>]</nowiki> repository.
+
 
 
Using direct-store, the properties of the physical device will be available for the initiator and target.
 
Using direct-store, the properties of the physical device will be available for the initiator and target.
  
Line 31: Line 35:
 
The configuration can be done:
 
The configuration can be done:
  
* using the {{ic|tgtadm}} utility, afterwards you can use {{ic|tgt-admin --dump}} to save the configuration. <br> You can find this method in the [http://fedoraproject.org/wiki/Scsi-target-utils_Quickstart_Guide Scsi-target-utils Quickstart Guide], as linked from the [http://stgt.sourceforge.net TGT website]. Unfortunately the bad thing about this method is that not all parameters will be stored in the configuration file.
+
* using the {{ic|tgtadm}} utility, afterwards you can use {{ic|tgt-admin --dump}} to save the configuration. {{ic|tgt-admin}} is a Perl script that parses {{ic|/etc/tgt/targets.conf}} and configures tgt. You can find this method in the [http://fedoraproject.org/wiki/Scsi-target-utils_Quickstart_Guide Scsi-target-utils Quickstart Guide], as linked from the [http://stgt.sourceforge.net TGT website].
* editing the /etc/tgt/targets.conf file.
+
* editing the /etc/tgt/targets.conf file. STGT supports multiple configurations. Include other config files in the main configuration file: {{ic|include /etc/tgt/*.conf}}
 +
* manual configuration:
 +
 
 +
Create a target:
 +
tgtadm --lld iscsi --op new --mode target --tid <unique target ID> -T <unique iSCSI iqn>
 +
 
 +
Allow only connection from specific initiators:
 +
tgtadm --lld iscsi --op bind --mode target --tid <target ID> --initiator-name <initiator IQN>
 +
 
 +
or using the initiator IP:
 +
tgtadm --lld iscsi --op bind --mode target --tid <target ID> --initiator-address <initiator IP>
 +
 
 +
Map a LUN to the target:
 +
tgtadm --lld iscsi --op new --mode logicalunit --tid <target ID> --lun <unique LUN ID> -b /path_to/lun.img
 +
 
 +
LUN ID must be a non-zero decimal value. LUN 0 is reserved for the target controller.
 +
 
 +
For ESXi it is very important to map LUNs with persistent LUN IDs. If the LUN on the storage system changes its ID, ESXi will not be able to automatically remount it, and will trigger a PDL condition.
 +
Use direct-store instead of backing-store to define LUN IDs which will be persistent across reboots.
 +
 
 +
View current configuration:
 +
 
 +
tgtadm --op show --mode target --tid <target ID>
 +
MaxRecvDataSegmentLength=8192
 +
HeaderDigest=None
 +
DataDigest=None
 +
InitialR2T=Yes
 +
MaxOutstandingR2T=1
 +
ImmediateData=Yes
 +
FirstBurstLength=65536
 +
MaxBurstLength=262144
 +
DataPDUInOrder=Yes
 +
DataSequenceInOrder=Yes
 +
ErrorRecoveryLevel=0
 +
IFMarker=No
 +
OFMarker=No
 +
DefaultTime2Wait=2
 +
DefaultTime2Retain=20
 +
OFMarkInt=Reject
 +
IFMarkInt=Reject
 +
MaxConnections=1
 +
RDMAExtensions=Yes
 +
TargetRecvDataSegmentLength=262144
 +
InitiatorRecvDataSegmentLength=262144
 +
MaxOutstandingUnexpectedPDUs=0
 +
MaxXmitDataSegmentLength=8192
 +
MaxQueueCmd=128
 +
 
 +
Save configuration:
 +
 
 +
tgt-admin --dump > /etc/tgt/targets.conf
 +
 
 +
Reload configuration:
 +
 
 +
tgt-admin --update ALL
 +
 
 +
This command only updates targets that are not in use. Use '--force' to update targets that are in use.
  
 
==Example configuration==
 
==Example configuration==
Line 56: Line 116:
 
  MaxCommands=128
 
  MaxCommands=128
  
In the first part of this example, /dev/sdb will be offered as lun 12 and chap authentication is configured.  
+
In the first part of this example, /dev/sdb will be mapped as LUN 12 and chap authentication is configured.  
 
In the second part are some [http://www.ietf.org/rfc/rfc3720.txt iSCSI advanced parameters]
 
In the second part are some [http://www.ietf.org/rfc/rfc3720.txt iSCSI advanced parameters]
  
 
==Start==
 
==Start==
  
If the configuration is well done, TGT can be started:
+
STGT can be [[started/enabled]] with the {{ic|tgtd.service}} unit.
 
+
sudo rc.d start tgt
+
 
+
If you want to start TGT during the boot process of Arch Linux, add tgt in the [[DAEMONS]] area of the [[rc.conf]] file.
+
 
+
DAEMONS = ( ... network tgt ... )
+
  
You can check if everything works like expected:
+
You can check if everything works as expected:
  
 
  tgt-admin -s
 
  tgt-admin -s

Latest revision as of 14:41, 25 November 2016

Related articles

The TGT SCSI framework can be used for several storage protocols. This document describes the usage of TGT as iSCSI target.

About TGT

STGT was introduced into the Linux kernel at the end of 2006 by Fujita Tomonori. It has a library in the kernel which assists the in-kernel target drivers. All target processing happens in user space. At the end of 2010, the LIO project was chosen to replace STGT as the in-kernel SCSI target implementation. When LIO was chosen to replace STGT, its implementation has been adapted to allow STGT userspace modules to continue functioning, therefore the STGT community has supported the LIO inclusion in the kernel.

Advantages:

  • active development
  • simplicity
  • support for iSCSI for Ethernet NICs, iSER, virtual SCSI target driver for IBM pSeries
  • supports virtual disks, DVDs, VTLs, RADOS block devices (rbd)
  • supports SCSI UNMAP

As a disadvantage some developers and users have argued that because the target processing happens in user space, in some cases this may lead to performance bottlenecks. However, using 'aio' type LUNs gives a huge performance boost. AIO should only be used in environments that are safe against power loss.

Installation

Install the tgtAUR package. If you want to use the direct store, then sg3_utils must also be installed.

Using direct-store, the properties of the physical device will be available for the initiator and target.

Please notice, if you're using a Firewall, tcp port 3260 should be open.

Configuration

The configuration can be done:

  • using the tgtadm utility, afterwards you can use tgt-admin --dump to save the configuration. tgt-admin is a Perl script that parses /etc/tgt/targets.conf and configures tgt. You can find this method in the Scsi-target-utils Quickstart Guide, as linked from the TGT website.
  • editing the /etc/tgt/targets.conf file. STGT supports multiple configurations. Include other config files in the main configuration file: include /etc/tgt/*.conf
  • manual configuration:

Create a target:

tgtadm --lld iscsi --op new --mode target --tid <unique target ID> -T <unique iSCSI iqn>

Allow only connection from specific initiators:

tgtadm --lld iscsi --op bind --mode target --tid <target ID> --initiator-name <initiator IQN>

or using the initiator IP:

tgtadm --lld iscsi --op bind --mode target --tid <target ID> --initiator-address <initiator IP>

Map a LUN to the target:

tgtadm --lld iscsi --op new --mode logicalunit --tid <target ID> --lun <unique LUN ID> -b /path_to/lun.img

LUN ID must be a non-zero decimal value. LUN 0 is reserved for the target controller.

For ESXi it is very important to map LUNs with persistent LUN IDs. If the LUN on the storage system changes its ID, ESXi will not be able to automatically remount it, and will trigger a PDL condition. Use direct-store instead of backing-store to define LUN IDs which will be persistent across reboots.

View current configuration:

tgtadm --op show --mode target --tid <target ID>
MaxRecvDataSegmentLength=8192
HeaderDigest=None
DataDigest=None
InitialR2T=Yes
MaxOutstandingR2T=1
ImmediateData=Yes
FirstBurstLength=65536
MaxBurstLength=262144
DataPDUInOrder=Yes
DataSequenceInOrder=Yes
ErrorRecoveryLevel=0
IFMarker=No
OFMarker=No
DefaultTime2Wait=2
DefaultTime2Retain=20
OFMarkInt=Reject
IFMarkInt=Reject
MaxConnections=1
RDMAExtensions=Yes
TargetRecvDataSegmentLength=262144
InitiatorRecvDataSegmentLength=262144
MaxOutstandingUnexpectedPDUs=0
MaxXmitDataSegmentLength=8192
MaxQueueCmd=128

Save configuration:

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

Reload configuration:

tgt-admin --update ALL

This command only updates targets that are not in use. Use '--force' to update targets that are in use.

Example configuration

<target iqn.2004-01.nl.xtg:iscsi-server1>
 direct-store /dev/sdb
 write-cache on
 initiator-address ALL
 incominguser user password
 scsi_id 00010001
 vendor_id XTG
 lun 12
</target>
MaxRecvDataSegmentLength 131072
MaxXmitDataSegmentLength 131072
MaxBurstLength 262144
FirstBurstLength 262144
TargetRecvDataSegmentLength=262144
InitiatorRecvDataSegmentLength=262144
MaxOutstandingUnexpectedPDUs=0
MaxOutstandingR2T=1
MaxCommands=128

In the first part of this example, /dev/sdb will be mapped as LUN 12 and chap authentication is configured. In the second part are some iSCSI advanced parameters

Start

STGT can be started/enabled with the tgtd.service unit.

You can check if everything works as expected:

tgt-admin -s

See also