The iSCSI protocol allows SCSI commands to be used over a TCP/IP network. The main reason people want to use an iSCSI is reducing costs, since they don't need buying FC HBA and infrastructure is already setup. The default port for iSCSI targets is 3260.
Both are used for accessing storage device over network, so what’s the difference? 1. NFS is used for accessing remote FILE SYSYEM data. Many people can assess data so there is functionality of locking data when used by someone, so others have to wait. 2. iSCSI is used for accessing BLOCKS on remote disk. In this case many users cannot share this access, because there is not lock functionality for block level access. In this example I have SunFire T2000 directly connected to StorEdge 3510 (with FC cables). The server is running Solaris 10 update 7. This server is iSCSI target and is exporting block device (ZFS volume) in order to be accessed by another Solaris box over network (iSCSI initiator).
You need next packages installed: system SUNWiscsir Sun iSCSI Device Driver (root) system SUNWiscsitgtr Sun iSCSI Target (Root) system SUNWiscsitgtu Sun iSCSI Target (Usr) system SUNWiscsiu Sun iSCSI Management Utilities (usr) Enable the service svc:/system/iscsitgt:default 1. Create a base directory The base directory is used to store the iSCSI target configuration data and needs to be defined prior to using the iSCSI target for the first time.
| # iscsitadm modify admin -d /var/iscsi |
> format
Searching for disks...done
AVAILABLE DISK SELECTIONS:
0. c1t40d0 |
> iscsitadm create target
iscsitadm: at least one option required
iscsitadm create target |
| > iscsitadm delete target --lun 0 testors-no-CHAP |
> iscsitadm list target -v
Target: testors-no-chap
iSCSI Name: iqn.1986-03.com.sun:02:92b0edad-52cd-ca06-93bd-d39a31259a2b.testors-no-chap
Connections: 0
ACL list:
TPGT list:
LUN information:
LUN: 0
GUID: 0
VID: SUN
PID: SOLARIS
Type: disk
Size: 30G
Backing store: /dev/zvol/dsk/drum-raid1/volume-no-CHAP
Status: online
|
# ls /etc/iscsi total 12 drwxr-xr-x 2 root sys 512 Mar 18 15:23 . drwxr-xr-x 58 root sys 4096 Mar 18 15:37 .. -rw------- 1 root root 548 Mar 18 15:23 iscsi_v1.dbc |
> iscsitadm list initiator
Initiator: cs2
iSCSI Name: iqn.1986-03.com.sun:01:0003ba3559b8.4ba69545
CHAP Name: cs2
|
You need next packages installed: system SUNWiscsir Sun iSCSI Device Driver (root) system SUNWiscsiu Sun iSCSI Management Utilities (usr) Enable service svc:/network/iscsi_initiator:default 1. Configure a discovery method Have only static discovery (use this for small number of targets or restrict targets that initiator can access)
# iscsiadm modify discovery
iscsiadm: at least one option required
iscsiadm modify discovery |
> iscsiadm list target -vS
Target: iqn.1986-03.com.sun:02:92b0edad-52cd-ca06-93bd-d39a31259a2b.testors-no-chap
Alias: testors-no-chap
TPGT: 1
ISID: 4000002a0000
Connections: 1
CID: 0
IP address (Local): 192.168.20.222:32784
IP address (Peer): 192.168.24.35:3260
Discovery Method: Static
Login Parameters (Negotiated):
Data Sequence In Order: yes
Data PDU In Order: yes
Default Time To Retain: 20
Default Time To Wait: 2
Error Recovery Level: 0
First Burst Length: 65536
Immediate Data: yes
Initial Ready To Transfer (R2T): yes
Max Burst Length: 262144
Max Outstanding R2T: 1
Max Receive Data Segment Length: 8192
Max Connections: 1
Header Digest: NONE
Data Digest: NONE
LUN: 0
Vendor: SUN
Product: SOLARIS
OS Device Name: /dev/rdsk/c4t2d0s2
> iscsiadm list target-param -v
Target: iqn.1986-03.com.sun:02:92b0edad-52cd-ca06-93bd-d39a31259a2b.testors-no-chap
Alias: testors-no-chap
Bi-directional Authentication: disabled
Authentication Type: NONE
Login Parameters (Default/Configured):
Data Sequence In Order: yes/-
Data PDU In Order: yes/-
Default Time To Retain: 20/-
Default Time To Wait: 2/-
Error Recovery Level: 0/-
First Burst Length: 65536/-
Immediate Data: yes/-
Initial Ready To Transfer (R2T): yes/-
Max Burst Length: 262144/-
Max Outstanding R2T: 1/-
Max Receive Data Segment Length: 8192/-
Max Connections: 1/-
Header Digest: NONE/-
Data Digest: NONE/-
Configured Sessions: 1
> iscsiadm list initiator-node
Initiator node name: iqn.1986-03.com.sun:01:0003ba3559b8.4ba6c502
Initiator node alias: -
Login Parameters (Default/Configured):
Header Digest: NONE/-
Data Digest: NONE/-
Authentication Type: NONE
RADIUS Server: NONE
RADIUS access: unknown
Configured Sessions: 1
|
| > devfsadm -Cv -i iscsi |
| > zpool create iscsi-no-chap c4t2d0 |
> iscsiadm list target
Target: iqn.1986-03.com.sun:02:92b0edad-52cd-ca06-93bd-d39a31259a2b.testors-no-chap
Alias: testors-no-chap
TPGT: 1
ISID: 4000002a0000
Connections: 1
|
| > iscsiadm remove static-config iqn.1986-03.com.sun:02:92b0edad-52cd-ca06-93bd-d39a31259a2b.testors-no-chap |
The iSCSI authentication may be required since iSCSI target cannot determine if connection request is from valid host. For example, someone else can connect to already connected (in use) block device, and type 'newfs' and you are screwed. Target authenticates an initiator by using Challenge-Handshake Authentication Protocol (CHAP). Authentication can be: 1. Unidirectional: only target identifies initiator. 2. Bidirectional: initiators also identifies target. Let's create new volume for testing iSCSI setup with Bidirectional authentication : > zfs create -V 40g drum-raid5/volume-yes-CHAP > zfs list NAME USED AVAIL REFER MOUNTPOINT drum-raid5 40.0G 93.9G 18K /drum-raid5 drum-raid5/volume-yes-CHAP 40G 134G 16K -
1. Set a secret key (between 12-16 characters)
> iscsiadm modify initiator-node --CHAP-secret Enter secret: Re-enter secret: |
> iscsiadm modify initiator-node --CHAP-name counterstrike2 |
> iscsiadm modify initiator-node --authentication CHAP
> iscsiadm list initiator-node
Initiator node name: iqn.1986-03.com.sun:01:0003ba3559b8.4ba6c502
Initiator node alias: -
Login Parameters (Default/Configured):
Header Digest: NONE/-
Data Digest: NONE/-
Authentication Type: CHAP
CHAP Name: counterstrike2
RADIUS Server: NONE
RADIUS access: unknown
Configured Sessions: 1
|
> iscsiadm add static-config iqn.1986-03.com.sun:02:504a7bec-02bb-603a-cb19-ea22f593a799.testors-yes-chap,192.168.24.35 |
> iscsiadm modify target-param --bi-directional-authentication enable iqn.1986-03.com.sun:02:504a7bec-02bb-603a-cb19-ea22f593a799.testors-yes-chap
> iscsiadm list target-param -v
Target: iqn.1986-03.com.sun:02:504a7bec-02bb-603a-cb19-ea22f593a799.testors-yes-chap
Alias: testors-yes-chap
Bi-directional Authentication: enabled
Authentication Type: NONE
Login Parameters (Default/Configured):
Data Sequence In Order: yes/-
Data PDU In Order: yes/-
Default Time To Retain: 20/-
Default Time To Wait: 2/-
Error Recovery Level: 0/-
First Burst Length: 65536/-
Immediate Data: yes/-
Initial Ready To Transfer (R2T): yes/-
Max Burst Length: 262144/-
Max Outstanding R2T: 1/-
Max Receive Data Segment Length: 8192/-
Max Connections: 1/-
Header Digest: NONE/-
Data Digest: NONE/-
Configured Sessions: 1
|
> iscsiadm modify target-param --authentication CHAP iqn.1986-03.com.sun:02:504a7bec-02bb-603a-cb19-ea22f593a799.testors-yes-chap |
> iscsiadm modify target-param --CHAP-secret iqn.1986-03.com.sun:02:504a7bec-02bb-603a-cb19-ea22f593a799.testors-yes-chap Enter secret: Re-enter secret: |
> iscsiadm list target-param -v
Target: iqn.1986-03.com.sun:02:504a7bec-02bb-603a-cb19-ea22f593a799.testors-yes-chap
Alias: testors-yes-chap
Bi-directional Authentication: enabled
Authentication Type: CHAP
CHAP Name: iqn.1986-03.com.sun:02:504a7bec-02bb-603a-cb19-ea22f593a799.testors-yes-chap < - - see this
Login Parameters (Default/Configured):
Data Sequence In Order: yes/-
Data PDU In Order: yes/-
Default Time To Retain: 20/-
Default Time To Wait: 2/-
Error Recovery Level: 0/-
First Burst Length: 65536/-
Immediate Data: yes/-
Initial Ready To Transfer (R2T): yes/-
Max Burst Length: 262144/-
Max Outstanding R2T: 1/-
Max Receive Data Segment Length: 8192/-
Max Connections: 1/-
Header Digest: NONE/-
Data Digest: NONE/-
Configured Sessions: 1
|
Quick reminder: how to create iSCSI target:
> iscsitadm create target -b /dev/zvol/dsk/drum-raid5/volume-yes-CHAP testors-yes-CHAP
> iscsitadm list target
Target: testors-yes-chap
iSCSI Name: iqn.1986-03.com.sun:02:504a7bec-02bb-603a-cb19-ea22f593a799.testors-yes-chap
Connections: 0
> iscsitadm list target -v
Target: testors-yes-chap
iSCSI Name: iqn.1986-03.com.sun:02:504a7bec-02bb-603a-cb19-ea22f593a799.testors-yes-chap
Connections: 0
ACL list:
TPGT list:
LUN information:
LUN: 0
GUID: 0
VID: SUN
PID: SOLARIS
Type: disk
Size: 40G
Backing store: /dev/zvol/dsk/drum-raid5/volume-yes-CHAP
Status: online
1. Set iSCSI target CHAP name as its own hostname
> iscsitadm modify admin --chap-name testors |
> iscsitadm modify admin --chap-secret Enter secret: Re-enter secret: |
> iscsitadm create initiator --iqn iqn.1986-03.com.sun:01:0003ba3559b8.4ba69545 cs2
> iscsitadm list initiator -v
Initiator: cs2
iSCSI Name: iqn.1986-03.com.sun:01:0003ba3559b8.4ba69545
CHAP Name: Not set
CHAP Secret: Not set
|
> iscsitadm modify initiator --chap-name cs2 cs2
> iscsitadm list initiator -v
Initiator: cs2
iSCSI Name: iqn.1986-03.com.sun:01:0003ba3559b8.4ba69545
CHAP Name: cs2 < - see this
CHAP Secret: Not set
|
> iscsitadm modify initiator --chap-secret cs2 Enter secret: Re-enter secret: |