Difference between revisions of "ISCSI Initiator"

From ArchWiki
Jump to: navigation, search
(improve install link as recommended in Help:Style#Package management instructions)
 
(21 intermediate revisions by 9 users not shown)
Line 1: Line 1:
 
[[Category:Storage]]
 
[[Category:Storage]]
 
[[Category:Networking]]
 
[[Category:Networking]]
{{Article summary start}}
+
[[ja:ISCSI イニシエータ]]
{{Article summary text|How to access an iSCSI Target with an initiator.}}
+
[[zh-CN:ISCSI initiator]]
{{Article summary heading|Series}}
+
{{Related articles start}}
{{Article summary wiki|iSCSI Target}}
+
{{Related|iSCSI Target}}
{{Article summary wiki|iSCSI Initiator}}
+
{{Related|iSCSI Boot}}
{{Article summary heading|Related}}
+
{{Related articles end}}
{{Article summary wiki|iSCSI Boot}}
+
{{Article summary end}}
+
  
 
With [[Wikipedia:iSCSI]] you can access storage over an IP-based network.
 
With [[Wikipedia:iSCSI]] you can access storage over an IP-based network.
Line 14: Line 12:
 
The exported storage entity is the '''[[iSCSI Target|target]]''' and the importing entity is the '''initiator'''.
 
The exported storage entity is the '''[[iSCSI Target|target]]''' and the importing entity is the '''initiator'''.
  
The preferred initiator is [http://open-iscsi.org/ Open-iSCSI] as of 2011. An older initiator, [http://sourceforge.net/projects/linux-iscsi/ Linux-iSCSI], was merged with Open-iSCSI.
+
This article describes how to access an iSCSI target with the [http://open-iscsi.org/ Open-iSCSI] initiator.
Linux-iSCSI should not be confused with linux-iscsi.org, the website for the LIO [[iSCSI Target|target]].
+
  
== Setup With Open-iSCSI ==
+
== Installation ==
Even {{AUR|open-iscsi}} is not in the official repositories, so you need to build it from AUR.
+
[[Install]] the {{Pkg|open-iscsi}} package from the [[official repositories]].
  
=== Using the Daemon ===
+
{{Note|An older initiator, [http://sourceforge.net/projects/linux-iscsi/ Linux-iSCSI], was merged with Open-iSCSI in April 2005.
You only have to include the IP of the [[iSCSI Target|target]] as {{ic|SERVER}} in {{ic|/etc/conf.d/open-iscsi}} at the client.
+
This should not be confused with [http://linux-iscsi.org/ linux-iscsi.org], the website for the LIO [[iSCSI Target|target]].}}
  
At the server (target) you might need to include the client iqn from {{ic|/etc/iscsi/initiatorname.iscsi}} in the acl configuration.
+
== Overview ==
 +
The following diagram shows how the Components work together. A more detailed version can be found here: [http://www.open-iscsi.org/docs/open-iscsi-0.jpg Open-iSCSI modules]
 +
{{bc|<nowiki>
 +
+-------------------------------------------------------+           
 +
| Targets & Sessions configuration Database (DBM based) |           
 +
+-------------------------------------------------------+           
 +
                                                                     
 +
+--------------------------+    +----------------------------------+
 +
| iscsiadm                |    | iscsid: iSCSI daemon            |
 +
|                          |    |                                  |
 +
|  * Command line tool    |<--->|  * Implements Session management |
 +
|  * Manages database of  |    |  * Communicates with iscsiadm    |
 +
|    sessions and targets  |    |    and iscsi kernel modules      |
 +
+--------------------------+    +---------------+------------------+
 +
                                                  |                   
 +
User space                                      |                   
 +
- - - - - - - - - - - - - - - - - - - - - - - - - | - - - - - - - - - -
 +
Kernel                                          v                   
 +
        +-----------------------------------------------------------+
 +
        | kernel modules: scsi_transport_iscsi, iscsi_tcp, libiscsi |
 +
        +-----------------------------------------------------------+
 +
</nowiki>}}
  
After both steps are finished you should be able to start the initiator with {{bc|# /etc/rc.d/open-iscsi start}}
+
From the Open-iSCSI [http://www.open-iscsi.org/docs/README README]:
You can see the current sessions with {{bc|# /etc/rc.d/open-iscsi status}}
+
You might want to include {{ic|open-iscsi}} in your [[rc.conf#Daemons]].
+
  
== Using the Tools ==
+
Persistent configuration is implemented as a DBM database, which contains two tables:
{{ic|iscsid}} has to be running.
+
* Discovery table (/etc/iscsi/send_targets)
 +
* Node table (/etc/iscsi/nodes)
 +
 
 +
== Configuration ==
 +
=== Start the Service ===
 +
{{ic|iscsid}} is managed by a systemd Unit.
 +
 
 +
Start {{ic|open-iscsi.service}} [[systemd#Using units|using systemd]].
 +
 
 +
If the SCSI target requires authentication by the initiator, the configuration file /etc/iscsi/iscsid.conf may need
 +
to be updated.
 +
 
 +
The following parameters are used for authenticating a login session of an initiator to a target and for the target
 +
to establish a session back to the initiator
 +
 
 +
  node.session.auth.authmethod = CHAP
 +
node.session.auth.username = <username in target>
 +
node.session.auth.password = <password in target>
 +
node.session.auth.username_in = <username in initiator>
 +
node.session.auth.password_in = <password in initiator>
 +
 
 +
The following parameters are used for authenticating a discovery session of an initiator to a target and for the
 +
target to establish a session back to the initiator.
 +
 
 +
discovery.sendtargets.auth.authmethod = CHAP
 +
discovery.sendtargets.auth.username = <username in target>
 +
discovery.sendtargets.auth.password = <password in target>
 +
discovery.sendtargets.auth.username_in = <username in initiator>
 +
discovery.sendtargets.auth.password_in = <password in initiator>
 +
 
 +
{{Warning|No two passwords may be the same. This means that you need four unique passwords in the configuration above. }}
  
 
=== Target discovery ===
 
=== Target discovery ===
Line 48: Line 94:
 
For running session
 
For running session
 
{{bc|# iscsiadm -m session -P 3}}
 
{{bc|# iscsiadm -m session -P 3}}
 +
The last line of the above command will show the name of the attached dev e.g
 +
{{bc|Attached scsi disk '''sdd''' State: running}}
 +
 
For the known nodes
 
For the known nodes
 
{{bc|# iscsiadm -m node}}
 
{{bc|# iscsiadm -m node}}
Line 57: Line 106:
 
# Finally resize the filesystem. {{bc|# resize2fs /dev/sdx}}
 
# Finally resize the filesystem. {{bc|# resize2fs /dev/sdx}}
  
== Tips ==
+
== Tips & Troubleshooting ==
 
You can also check where the attached iSCSI devices are located in the /dev tree with {{ic|ls -lh /dev/disk/by-path/* | grep ip}}.
 
You can also check where the attached iSCSI devices are located in the /dev tree with {{ic|ls -lh /dev/disk/by-path/* | grep ip}}.
 +
 +
At the server (target) you might need to include the client iqn from {{ic|/etc/iscsi/initiatorname.iscsi}} in the acl configuration.
 +
 +
Many of the {{ic|iscsiadm}} operations require that the iSCSI daemon {{ic|iscsid}} is running. To verify that this is the case,
 +
[[systemd#Using units|check the status]] of the {{ic|open-iscsi.service}}.
  
 
== See also ==
 
== See also ==
 
* [[iSCSI Boot]] Booting Arch Linux with / on an iSCSI target.
 
* [[iSCSI Boot]] Booting Arch Linux with / on an iSCSI target.

Latest revision as of 21:18, 13 December 2015

Related articles

With Wikipedia:iSCSI you can access storage over an IP-based network.

The exported storage entity is the target and the importing entity is the initiator.

This article describes how to access an iSCSI target with the Open-iSCSI initiator.

Installation

Install the open-iscsi package from the official repositories.

Note: An older initiator, Linux-iSCSI, was merged with Open-iSCSI in April 2005. This should not be confused with linux-iscsi.org, the website for the LIO target.

Overview

The following diagram shows how the Components work together. A more detailed version can be found here: Open-iSCSI modules

 +-------------------------------------------------------+             
 | Targets & Sessions configuration Database (DBM based) |             
 +-------------------------------------------------------+             
                                                                       
 +--------------------------+     +----------------------------------+ 
 | iscsiadm                 |     | iscsid: iSCSI daemon             | 
 |                          |     |                                  | 
 |  * Command line tool     |<--->|  * Implements Session management | 
 |  * Manages database of   |     |  * Communicates with iscsiadm    | 
 |    sessions and targets  |     |    and iscsi kernel modules      | 
 +--------------------------+     +---------------+------------------+ 
                                                  |                    
 User space                                       |                    
- - - - - - - - - - - - - - - - - - - - - - - - - | - - - - - - - - - -
 Kernel                                           v                    
         +-----------------------------------------------------------+ 
         | kernel modules: scsi_transport_iscsi, iscsi_tcp, libiscsi | 
         +-----------------------------------------------------------+ 

From the Open-iSCSI README:

Persistent configuration is implemented as a DBM database, which contains two tables:

  • Discovery table (/etc/iscsi/send_targets)
  • Node table (/etc/iscsi/nodes)

Configuration

Start the Service

iscsid is managed by a systemd Unit.

Start open-iscsi.service using systemd.

If the SCSI target requires authentication by the initiator, the configuration file /etc/iscsi/iscsid.conf may need to be updated.

The following parameters are used for authenticating a login session of an initiator to a target and for the target to establish a session back to the initiator

node.session.auth.authmethod = CHAP
node.session.auth.username = <username in target>
node.session.auth.password = <password in target>
node.session.auth.username_in = <username in initiator>
node.session.auth.password_in = <password in initiator>

The following parameters are used for authenticating a discovery session of an initiator to a target and for the target to establish a session back to the initiator.

discovery.sendtargets.auth.authmethod = CHAP
discovery.sendtargets.auth.username = <username in target>
discovery.sendtargets.auth.password = <password in target>
discovery.sendtargets.auth.username_in = <username in initiator>
discovery.sendtargets.auth.password_in = <password in initiator>
Warning: No two passwords may be the same. This means that you need four unique passwords in the configuration above.

Target discovery

# iscsiadm -m discovery -t sendtargets -p <portalip>

Delete obsolete targets

# iscsiadm -m discovery -p <portalip> -o delete

Login to available targets

# iscsiadm -m node -L all

or login to specific target

# iscsiadm -m node --targetname=<targetname> --login

logout:

# iscsiadm -m node -U all

Info

For running session

# iscsiadm -m session -P 3

The last line of the above command will show the name of the attached dev e.g

Attached scsi disk sdd State: running

For the known nodes

# iscsiadm -m node

Online resize of volumes

If the iscsi blockdevice contains a partitiontable, you will not be able to do an online resize. In this case you have to unmount the filesystem and alter the size of the affected partition.

  1. Rescan active nodes in current session
    # iscsiadm -m node -R
  2. If you use multipath, you also have to rescan multipath volume information.
    # multipathd -k"resize map sdx"
  3. Finally resize the filesystem.
    # resize2fs /dev/sdx

Tips & Troubleshooting

You can also check where the attached iSCSI devices are located in the /dev tree with ls -lh /dev/disk/by-path/* .

At the server (target) you might need to include the client iqn from /etc/iscsi/initiatorname.iscsi in the acl configuration.

Many of the iscsiadm operations require that the iSCSI daemon iscsid is running. To verify that this is the case, check the status of the open-iscsi.service.

See also

  • iSCSI Boot Booting Arch Linux with / on an iSCSI target.