iSCSI introduction and usage

27
iSCSI introduction and usage Zhu Lingshan [email protected]

Transcript of iSCSI introduction and usage

Page 1: iSCSI introduction and usage

iSCSI introduction and usage

Zhu Lingshan

[email protected]

Page 2: iSCSI introduction and usage

What is SCSI

Small Computer System Interface(SCSI) is a set of standards for physically

connecting and transferring data between computers and peripheral devices. The

SCSI standards define commands, protocols, electrical and optical interfaces.

SCSI is most commonly used for hard disk drives and tape drives, but it can

connect a wide range of other devices, including scanners and CD drives,

although not all controllers can handle all devices. The SCSI standard defines

command sets for specific peripheral device types; the presence of "unknown" as

one of these types means that in theory it can be used as an interface to almost

any device, but the standard is highly pragmatic and addressed toward

commercial requirements.

Page 3: iSCSI introduction and usage

What is SCSI

SCSI Initiator: An endpoint that initiates a SCSI session, that is, sends a SCSI

command.

SCSI Target: Usually a disk or a storage array.

SCSI LUN: SCSI Logical Unit Number, the “real storage”, a SCSI target should

have at least one LUN: LUN0.

In SCSI terminology, communication takes place between an initiator and a

target. The initiator sends a command to the LUN, which then responds. SCSI

commands are sent in a Command Descriptor Block (CDB).

Page 4: iSCSI introduction and usage

What is SCSI

Lsscsi shows [Host:Bus:Target:LUN], device type,

vendor, etc

lsscsi shows SATA devices, Because SATA uses SCSI

transport layer.

Page 5: iSCSI introduction and usage

What is SCSI

Page 6: iSCSI introduction and usage

What is iSCSI

Page 7: iSCSI introduction and usage

What is iSCSI

Carry SCSI CBD in iSCSI PDU, benefit from IP networks.

Key words in iSCSI:

• ISID: The initiator part of the Session Identifier. It is explicitly specified by

the initiator during Login.

• I_T nexus: According to [SAM2], the I_T nexus is a relationship between a

SCSI Initiator Port and a SCSI Target Port.

• SSID (Session ID): A session between an iSCSI initiator and an iSCSI target

is defined by a session ID that is a tuple composed of an initiator part (ISID)

and a target part (Target Portal Group Tag). The ISID is explicitly specified by

the initiator at session establishment. The Target Portal Group Tag is implied

by the initiator through the selection of the TCP endpoint at connection

establishment.

Page 8: iSCSI introduction and usage

What is iSCSI, key words:

• TSIH (Target Session Identifying Handle): A target assigned tag for a session

with a specific named initiator. The target generates it during session

establishment. Its internal format and content are not defined by this protocol,

except for the value 0 that is reserved and used by the initiator to indicate a

new session.

• ITT(Initiator Task Tag):The Initiator Task Tag is used to identify a task during

its execution even over sessions/connections.

• CID: connection ID.

• CmdSN: command sequence number.

• ExpStatSN: The expected status number, ExpStatSN is what the initiator uses

to tell the target what status response it thinks is the next one.

Page 9: iSCSI introduction and usage

What is iSCSI, key words:

• StatSN:status sequence number, it is different from status also in the PDU.

Responses in transit from the target to the initiator are numbered. The StatSN

(Status Sequence Number) is used for this purpose. This helps the initiator

detect any missing StatSN(s) and issue a SNACK for the status

• ExpCmdSN: Next expected CmdSN from this initiator.

• MaxCmdSN: Maximum CmdSN from this initiator

Page 10: iSCSI introduction and usage

iSCSI discovery 1/4:

Page 11: iSCSI introduction and usage

iSCSI discovery 2/4:

Page 12: iSCSI introduction and usage

iSCSI discovery 3/4:

Page 13: iSCSI introduction and usage

iSCSI discovery 4/4:

Page 14: iSCSI introduction and usage

How iSCSI carry SCSI commands

14

Page 15: iSCSI introduction and usage

Yast iSCSI target usage: discovery

Page 16: iSCSI introduction and usage

Yast iSCSI target usage: add a target

Page 17: iSCSI introduction and usage

Yast iSCSI target usage: add an initiaitor

Page 18: iSCSI introduction and usage

Yast iSCSI target usage: login authentication

Page 19: iSCSI introduction and usage

Yast iSCSI target usage: LUNs mapping

Page 20: iSCSI introduction and usage

Targetcli overview

20

Page 21: iSCSI introduction and usage

Targetcli create backend storage

• Create a backend storage with a existed file:

backstores/fileio create name=iscsi_file file_or_dev=/home/lszhu/target.raw

• Create a backend storage with a file not existed, while you want to create the

file at the same time.

backstores/fileio create name=iscsi_file file_or_dev=/home/lszhu/target.raw

size=100M

• Create a backend storage with a block device

backstores/block/ create name=iscsi_sbc dev=/dev/sdc

21

Page 22: iSCSI introduction and usage

Targetcli create targets

/> iscsi/ create iqn.2017-03.suse.com.target

Created target iqn.2017-03.suse.com.target.

Created TPG 1.

Global pref auto_add_default_portal=true

Created default portal listening on all IPs (0.0.0.0), port 3260.

/>

22

Page 23: iSCSI introduction and usage

Targetcli create portals and luns

• Create a portal

/iscsi/iqn.20...m.target/tpg1> portals/ create ip_address=147.2.212.166

ip_port=3260

• Create a lun:

/iscsi/iqn.20...m.target/tpg1> luns/ create /backstores/block/iscsi_sdc

23

Page 24: iSCSI introduction and usage

Targetcli set demo mode

• Set to demo mode then every initiator can access the target without

authentication

/iscsi/iqn.20...m.target/tpg1> set attribute authentication=0

demo_mode_write_protect=0 generate_node_acls=1 cache_dynamic_acls=1

24

Page 25: iSCSI introduction and usage

Targetcli add an ACL

An ACL means you want some specific initiators granted the access to the targets,

others not.

1. /iscsi/iqn.20...m.target/tpg1> acls/ create iqn.2017-03.suse.com.lszhu.init

2. /iscsi/iqn.20...m.target/tpg1> cd acls/iqn.2017-03.suse.com.lszhu.init

3. /iscsi/iqn.20...om.lszhu.init> set auth userid=lszhu password=lszhu

mutual_userid=test mutual_password=test

4. /iscsi/iqn.20...om.lszhu.init> create mapped_lun=6

tpg_lun_or_backstore=lun0

25

Page 26: iSCSI introduction and usage

Q&A

Page 27: iSCSI introduction and usage

Thanks