iSCSI on Red Hat Enterprise Linux: Targets, Initiators and ... · PDF fileiSCSI on Red Hat...

49
iSCSI on Red Hat Enterprise Linux: Targets, Initiators and SANs John VanDyk ENT/NREM Business Center Iowa State University February 8, 2013

Transcript of iSCSI on Red Hat Enterprise Linux: Targets, Initiators and ... · PDF fileiSCSI on Red Hat...

Page 1: iSCSI on Red Hat Enterprise Linux: Targets, Initiators and ... · PDF fileiSCSI on Red Hat Enterprise Linux: Targets, Initiators and SANs John VanDyk ENT/NREM Business Center Iowa

iSCSI on Red Hat Enterprise Linux:

Targets, Initiators and SANsJohn VanDyk

ENT/NREM Business CenterIowa State University

February 8, 2013

Page 2: iSCSI on Red Hat Enterprise Linux: Targets, Initiators and ... · PDF fileiSCSI on Red Hat Enterprise Linux: Targets, Initiators and SANs John VanDyk ENT/NREM Business Center Iowa

This presentation goes over iSCSI basics and introduces the open-iscsi tools on Red Hat Enterprise Linux 6.

It is a “how do I understand basic iSCSI tools” presentation. It is not a

“why should I use iSCSI” presentation.

Page 3: iSCSI on Red Hat Enterprise Linux: Targets, Initiators and ... · PDF fileiSCSI on Red Hat Enterprise Linux: Targets, Initiators and SANs John VanDyk ENT/NREM Business Center Iowa

•History

•Terminology

•Server-side tools

•Client-side tools

•Demo

(The Demo was bringing up two Linux VMs, exposing a 5GB secondary drive on VM1 as a target and connecting to it from VM2.)

Page 4: iSCSI on Red Hat Enterprise Linux: Targets, Initiators and ... · PDF fileiSCSI on Red Hat Enterprise Linux: Targets, Initiators and SANs John VanDyk ENT/NREM Business Center Iowa

Small Computer System Interface

SCSI’s been around for a long time.

Page 5: iSCSI on Red Hat Enterprise Linux: Targets, Initiators and ... · PDF fileiSCSI on Red Hat Enterprise Linux: Targets, Initiators and SANs John VanDyk ENT/NREM Business Center Iowa

SASI1981

1980 1990 2000 2010SCSI -11986

SCSI -2Fast SCSI

Wide SCSI

1990(1994)

SCSI -3

(SCSI Architecture

Model)

Ultra SCSI

1996

Ultra-320

2001

LVD SCSIUltra-160

1999

SerialAttached

SCSI(SAS)

2003

iSCSI

2000

A hand-waving general timeline of SCSI-related things.

Page 6: iSCSI on Red Hat Enterprise Linux: Targets, Initiators and ... · PDF fileiSCSI on Red Hat Enterprise Linux: Targets, Initiators and SANs John VanDyk ENT/NREM Business Center Iowa

Portal Group

Portal

Target

Initiator

Node

Target Portal Group Tag

iSCSI terminology is rich and varied.

Page 7: iSCSI on Red Hat Enterprise Linux: Targets, Initiators and ... · PDF fileiSCSI on Red Hat Enterprise Linux: Targets, Initiators and SANs John VanDyk ENT/NREM Business Center Iowa

Node Node

Node: an addressable, discoverable entity

Page 8: iSCSI on Red Hat Enterprise Linux: Targets, Initiators and ... · PDF fileiSCSI on Red Hat Enterprise Linux: Targets, Initiators and SANs John VanDyk ENT/NREM Business Center Iowa

Node Nodes have globally unique iSCSI qualified names

iqn.date.naming authority.string

Page 9: iSCSI on Red Hat Enterprise Linux: Targets, Initiators and ... · PDF fileiSCSI on Red Hat Enterprise Linux: Targets, Initiators and SANs John VanDyk ENT/NREM Business Center Iowa

iSCSI Names

iqn.date.naming authority.string

iqn

iqn.2013-02

iqn.2013-02.edu.iastate.ent

iqn.2013-02.edu.iastate.ent:storage1

Building an iSCSI Qualified Name. If you’re feeling adventurous you could use IEE EUI-64 identifiers in hexadecimal (see RFC3721 section 1.2).

Page 10: iSCSI on Red Hat Enterprise Linux: Targets, Initiators and ... · PDF fileiSCSI on Red Hat Enterprise Linux: Targets, Initiators and SANs John VanDyk ENT/NREM Business Center Iowa

NodeNodes have addresses

IPv4 address:port198.51.100.1:3260

IPv6 address:port[1080::8:800:200C:417A]:3260

hostname:portstorage123.example.com:3260

Page 11: iSCSI on Red Hat Enterprise Linux: Targets, Initiators and ... · PDF fileiSCSI on Red Hat Enterprise Linux: Targets, Initiators and SANs John VanDyk ENT/NREM Business Center Iowa

InitiatorNode

TargetNode

So now we’ve established that both initiators and targets are kinds of iSCSI nodes.

Page 12: iSCSI on Red Hat Enterprise Linux: Targets, Initiators and ... · PDF fileiSCSI on Red Hat Enterprise Linux: Targets, Initiators and SANs John VanDyk ENT/NREM Business Center Iowa

InitiatorNode

TargetNode

Name: iqn.2013-02.edu.iastate.ent:client0Address: 172.16.198.3Alias: Fuzzy

Each node can have an alias as well. This is just a friendly name. Note there’s no port on the initiator’s address, because the connection is outgoing from the initiator. Just like your webserver runs on port 80 but the client computer accessing it can use different ports.

Page 13: iSCSI on Red Hat Enterprise Linux: Targets, Initiators and ... · PDF fileiSCSI on Red Hat Enterprise Linux: Targets, Initiators and SANs John VanDyk ENT/NREM Business Center Iowa

InitiatorNode

TargetNode

Name: iqn.2013-02.edu.iastate.ent:target0Address: 172.16.198.20:3260Alias: BioData

Aliases might be used in UIs. In the example above, a message like "you have connected to BioData" is a lot friendlier than the alternative.

Page 14: iSCSI on Red Hat Enterprise Linux: Targets, Initiators and ... · PDF fileiSCSI on Red Hat Enterprise Linux: Targets, Initiators and SANs John VanDyk ENT/NREM Business Center Iowa

InitiatorNode

TargetNode

SendTargets

TargetNode

Multiple target nodes may reside inside one physical computer.

Page 15: iSCSI on Red Hat Enterprise Linux: Targets, Initiators and ... · PDF fileiSCSI on Red Hat Enterprise Linux: Targets, Initiators and SANs John VanDyk ENT/NREM Business Center Iowa

LUN1LUN2

InitiatorNode

TargetNode

SendTargets

LUN1

TargetNode

Each target may have more than one LUN.

Page 16: iSCSI on Red Hat Enterprise Linux: Targets, Initiators and ... · PDF fileiSCSI on Red Hat Enterprise Linux: Targets, Initiators and SANs John VanDyk ENT/NREM Business Center Iowa

yum install scsi-target-utils

To set up an iSCSI target, you need the iSCSI target utilities.

Page 17: iSCSI on Red Hat Enterprise Linux: Targets, Initiators and ... · PDF fileiSCSI on Red Hat Enterprise Linux: Targets, Initiators and SANs John VanDyk ENT/NREM Business Center Iowa

# rpm -ql scsi-target-utils

/etc/rc.d/init.d/tgtd/etc/sysconfig/tgtd/etc/tgt/targets.conf

/usr/sbin/tgt-admin/usr/sbin/tgt-setup-lun/usr/sbin/tgtadm/usr/sbin/tgtd/usr/sbin/tgtimg

Startup script

Page 18: iSCSI on Red Hat Enterprise Linux: Targets, Initiators and ... · PDF fileiSCSI on Red Hat Enterprise Linux: Targets, Initiators and SANs John VanDyk ENT/NREM Business Center Iowa

# rpm -ql scsi-target-utils

/etc/rc.d/init.d/tgtd/etc/sysconfig/tgtd/etc/tgt/targets.conf

/usr/sbin/tgt-admin/usr/sbin/tgt-setup-lun/usr/sbin/tgtadm/usr/sbin/tgtd/usr/sbin/tgtimg

Tells where targets.conf is/etc/tgt/targets.conf

Page 19: iSCSI on Red Hat Enterprise Linux: Targets, Initiators and ... · PDF fileiSCSI on Red Hat Enterprise Linux: Targets, Initiators and SANs John VanDyk ENT/NREM Business Center Iowa

# rpm -ql scsi-target-utils

/etc/rc.d/init.d/tgtd/etc/sysconfig/tgtd/etc/tgt/targets.conf

/usr/sbin/tgt-admin/usr/sbin/tgt-setup-lun/usr/sbin/tgtadm/usr/sbin/tgtd/usr/sbin/tgtimg

Here is where yourtarget configuration lives

Page 20: iSCSI on Red Hat Enterprise Linux: Targets, Initiators and ... · PDF fileiSCSI on Red Hat Enterprise Linux: Targets, Initiators and SANs John VanDyk ENT/NREM Business Center Iowa

# rpm -ql scsi-target-utils

/etc/rc.d/init.d/tgtd/etc/sysconfig/tgtd/etc/tgt/targets.conf

/usr/sbin/tgt-admin/usr/sbin/tgt-setup-lun/usr/sbin/tgtadm/usr/sbin/tgtd/usr/sbin/tgtimg

Perl script.Reads targets.conf and

executes tgtadm commands

Page 21: iSCSI on Red Hat Enterprise Linux: Targets, Initiators and ... · PDF fileiSCSI on Red Hat Enterprise Linux: Targets, Initiators and SANs John VanDyk ENT/NREM Business Center Iowa

# rpm -ql scsi-target-utils

/etc/rc.d/init.d/tgtd/etc/sysconfig/tgtd/etc/tgt/targets.conf

/usr/sbin/tgt-admin/usr/sbin/tgt-setup-lun/usr/sbin/tgtadm/usr/sbin/tgtd/usr/sbin/tgtimg

bash script.Makes entries in

targets.conf from thecommand line

Page 22: iSCSI on Red Hat Enterprise Linux: Targets, Initiators and ... · PDF fileiSCSI on Red Hat Enterprise Linux: Targets, Initiators and SANs John VanDyk ENT/NREM Business Center Iowa

# rpm -ql scsi-target-utils

/etc/rc.d/init.d/tgtd/etc/sysconfig/tgtd/etc/tgt/targets.conf

/usr/sbin/tgt-admin/usr/sbin/tgt-setup-lun/usr/sbin/tgtadm/usr/sbin/tgtd/usr/sbin/tgtimg

The main utility for working with SCSI

targets

Page 23: iSCSI on Red Hat Enterprise Linux: Targets, Initiators and ... · PDF fileiSCSI on Red Hat Enterprise Linux: Targets, Initiators and SANs John VanDyk ENT/NREM Business Center Iowa

# rpm -ql scsi-target-utils

/etc/rc.d/init.d/tgtd/etc/sysconfig/tgtd/etc/tgt/targets.conf

/usr/sbin/tgt-admin/usr/sbin/tgt-setup-lun/usr/sbin/tgtadm/usr/sbin/tgtd/usr/sbin/tgtimg

SCSI target daemon

Page 24: iSCSI on Red Hat Enterprise Linux: Targets, Initiators and ... · PDF fileiSCSI on Red Hat Enterprise Linux: Targets, Initiators and SANs John VanDyk ENT/NREM Business Center Iowa

# rpm -ql scsi-target-utils

/etc/rc.d/init.d/tgtd/etc/sysconfig/tgtd/etc/tgt/targets.conf

/usr/sbin/tgt-admin/usr/sbin/tgt-setup-lun/usr/sbin/tgtadm/usr/sbin/tgtd/usr/sbin/tgtimg Creates and dumps

image files for tape, dvd+r or disk

Page 25: iSCSI on Red Hat Enterprise Linux: Targets, Initiators and ... · PDF fileiSCSI on Red Hat Enterprise Linux: Targets, Initiators and SANs John VanDyk ENT/NREM Business Center Iowa

# dmesg | grep sd

sd 2:0:1:0: [sdb] 10485760 512-byte logical blocks: (5.36 GB/5.00 GiB)

Find the 5GB drive we want to share

If you do not have static set of devices you are urged to use udev rules, as /dev/sdb might be /dev/sdc next time. A gotcha here too is LVM rules which may quietly mark a device as “in use” (see http://www.sysarchitects.com/iscsi_target_on_rhel6 )

Page 26: iSCSI on Red Hat Enterprise Linux: Targets, Initiators and ... · PDF fileiSCSI on Red Hat Enterprise Linux: Targets, Initiators and SANs John VanDyk ENT/NREM Business Center Iowa

<target iqn.2013-02.edu.iastate.ent:biodata> backing-store /dev/sdb vendor_id "VMWare" # Only an initiator at this IP # may talk to this target. initiator-address 172.16.1.20 </target>

Minimal configuration in /etc/tgt/targets.conf

We could have used direct-store instead of backing-store and not defined the vendor_id, because direct-store queries the device and passes along what it finds. Sadly this threw an error on VMWare Fusion where I was running the demo so I used backing-store instead.

Page 27: iSCSI on Red Hat Enterprise Linux: Targets, Initiators and ... · PDF fileiSCSI on Red Hat Enterprise Linux: Targets, Initiators and SANs John VanDyk ENT/NREM Business Center Iowa

# service tgtd start

Start iscsi daemon (tgtd)

Page 28: iSCSI on Red Hat Enterprise Linux: Targets, Initiators and ... · PDF fileiSCSI on Red Hat Enterprise Linux: Targets, Initiators and SANs John VanDyk ENT/NREM Business Center Iowa

# tgtadm --lld iscsi --op show --mode target

Show Targets

Page 29: iSCSI on Red Hat Enterprise Linux: Targets, Initiators and ... · PDF fileiSCSI on Red Hat Enterprise Linux: Targets, Initiators and SANs John VanDyk ENT/NREM Business Center Iowa

Target 1: iqn.2013-02.edu.iastate.ent:biodata LUN: 1 Type: disk SCSI ID: IET 00010001 SCSI SN: beaf11 Size: 5369 MB, Block size: 512 Online: Yes Removable media: No Prevent removal: No Readonly: No Backing store type: rdwr Backing store path: /dev/sdb Backing store flags:

Page 30: iSCSI on Red Hat Enterprise Linux: Targets, Initiators and ... · PDF fileiSCSI on Red Hat Enterprise Linux: Targets, Initiators and SANs John VanDyk ENT/NREM Business Center Iowa

iptables -I INPUT 4 \ -p tcp \ -s x.x.x.x \ --dport 3260 \ -m state \ --state NEW \ -j ACCEPT

Add Firewall Rule for iSCSI

x.x.x.x is the IP address of the initiator that wants to connect to this target.

Page 31: iSCSI on Red Hat Enterprise Linux: Targets, Initiators and ... · PDF fileiSCSI on Red Hat Enterprise Linux: Targets, Initiators and SANs John VanDyk ENT/NREM Business Center Iowa

yum install iscsi-initiator-utils

Now, on the Initiator (client that will connect)

On the initiator, you need the iSCSI initiator utilities in order to connect to the target.

Page 32: iSCSI on Red Hat Enterprise Linux: Targets, Initiators and ... · PDF fileiSCSI on Red Hat Enterprise Linux: Targets, Initiators and SANs John VanDyk ENT/NREM Business Center Iowa

# rpm -ql scsi-initiator-utils \ grep | “interesting”

/etc/iscsi/iscsid.conf/etc/rc.d/init.d/iscsi/etc/rc.d/init.d/iscsid

/sbin/iscsiadm/sbin/iscsid

Initiator configuration

Page 33: iSCSI on Red Hat Enterprise Linux: Targets, Initiators and ... · PDF fileiSCSI on Red Hat Enterprise Linux: Targets, Initiators and SANs John VanDyk ENT/NREM Business Center Iowa

# rpm -ql scsi-initiator-utils \ grep | “interesting”

/etc/iscsi/iscsid.conf/etc/rc.d/init.d/iscsi/etc/rc.d/init.d/iscsid

/sbin/iscsiadm/sbin/iscsid

Handle automaticlogin to targets

Page 34: iSCSI on Red Hat Enterprise Linux: Targets, Initiators and ... · PDF fileiSCSI on Red Hat Enterprise Linux: Targets, Initiators and SANs John VanDyk ENT/NREM Business Center Iowa

# rpm -ql scsi-initiator-utils \ grep | “interesting”

/etc/iscsi/iscsid.conf/etc/rc.d/init.d/iscsi/etc/rc.d/init.d/iscsid

/sbin/iscsiadm/sbin/iscsid

Start iscsid daemon

Handles iSCSI sessions

Page 35: iSCSI on Red Hat Enterprise Linux: Targets, Initiators and ... · PDF fileiSCSI on Red Hat Enterprise Linux: Targets, Initiators and SANs John VanDyk ENT/NREM Business Center Iowa

# rpm -ql scsi-initiator-utils \ grep | “interesting”

/etc/iscsi/iscsid.conf/etc/rc.d/init.d/iscsi/etc/rc.d/init.d/iscsid

/sbin/iscsiadm/sbin/iscsid

Administration utility for iSCSI initiator

Page 36: iSCSI on Red Hat Enterprise Linux: Targets, Initiators and ... · PDF fileiSCSI on Red Hat Enterprise Linux: Targets, Initiators and SANs John VanDyk ENT/NREM Business Center Iowa

# cat /etc/iscsi/initiatorname.iscsi

InitiatorName=iqn.2013-02.edu.iastate.ent:client0

Define our initiator’s name

Page 37: iSCSI on Red Hat Enterprise Linux: Targets, Initiators and ... · PDF fileiSCSI on Red Hat Enterprise Linux: Targets, Initiators and SANs John VanDyk ENT/NREM Business Center Iowa

# service iscsi start# service iscsid start

Start iscsi services

Page 38: iSCSI on Red Hat Enterprise Linux: Targets, Initiators and ... · PDF fileiSCSI on Red Hat Enterprise Linux: Targets, Initiators and SANs John VanDyk ENT/NREM Business Center Iowa

?

Initiator Target

# iscsiadm -m discoverydb \ -t sendtargets \ -p 172.16.198.3:3260 \ --discover

SendTargets

Page 39: iSCSI on Red Hat Enterprise Linux: Targets, Initiators and ... · PDF fileiSCSI on Red Hat Enterprise Linux: Targets, Initiators and SANs John VanDyk ENT/NREM Business Center Iowa

LUN1

Initiator Target

172.16.198.3:3260,1 iqn.2013-02.edu.iastate.ent:biodata

The ,1 on the end of the IP:port is the target portal group tag. In this case, it is 1 since there is only a single target portal group on our server. If we had another IP:port with a different set of targets that would be a second target portal group.

Page 40: iSCSI on Red Hat Enterprise Linux: Targets, Initiators and ... · PDF fileiSCSI on Red Hat Enterprise Linux: Targets, Initiators and SANs John VanDyk ENT/NREM Business Center Iowa

Initiator

# cat /var/lib/iscsi/nodes/iqn.2013-02.edu.iastate.ent:biodata/172.16.198.3,3620,1/default

The initiator has stored a recordof this discovery

Page 41: iSCSI on Red Hat Enterprise Linux: Targets, Initiators and ... · PDF fileiSCSI on Red Hat Enterprise Linux: Targets, Initiators and SANs John VanDyk ENT/NREM Business Center Iowa

# BEGIN RECORD 2.0-872.41.el6node.name = iqn.2013-02.edu.iastate.ent:biodatanode.tpgt = 1node.startup = automaticnode.leading_login = Noiface.iscsi_ifacename = defaultiface.transport_name = tcpiface.vlan_id = 0iface.vlan_priority = 0iface.iface_num = 0iface.mtu = 0iface.port = 0node.discovery_address = 172.16.198.3...

Page 42: iSCSI on Red Hat Enterprise Linux: Targets, Initiators and ... · PDF fileiSCSI on Red Hat Enterprise Linux: Targets, Initiators and SANs John VanDyk ENT/NREM Business Center Iowa

iscsid: Connection1:0 to [target: iqn.2013-02.edu.iastate.ent:biodata, portal: 172.16.198.3,3260] through [iface: default] is operational now

kernel: sd 3:0:0:1: [sdb] 10485760 512-byte logical blocks: (5.36 GB/5.00 GiB)kernel: sd 3:0:0:1: [sdb] Write Protect offkernel: sdb:kernel: sd 3:0:0:1: [sdb] Attached SCSI disk

Restarting iscsi service or rebooting connects the device

It works!

Page 43: iSCSI on Red Hat Enterprise Linux: Targets, Initiators and ... · PDF fileiSCSI on Red Hat Enterprise Linux: Targets, Initiators and SANs John VanDyk ENT/NREM Business Center Iowa

/dev/sdb LUN1

Initiator Target

Hullo! A local device, ready for partitioning, formatting,

and general frolic!

Page 44: iSCSI on Red Hat Enterprise Linux: Targets, Initiators and ... · PDF fileiSCSI on Red Hat Enterprise Linux: Targets, Initiators and SANs John VanDyk ENT/NREM Business Center Iowa

SAN: a Storage Area Network

Initiator

Switch Switch

Targets

10,000-foot overview of iSCSI SAN. Two switches for redundant paths from initiator to target.

Page 45: iSCSI on Red Hat Enterprise Linux: Targets, Initiators and ... · PDF fileiSCSI on Red Hat Enterprise Linux: Targets, Initiators and SANs John VanDyk ENT/NREM Business Center Iowa

SAN: a Storage Area Network

172.16.1.1

172.16.1.20 172.16.2.20

172.16.2.1

Two subnets, two paths.

Page 46: iSCSI on Red Hat Enterprise Linux: Targets, Initiators and ... · PDF fileiSCSI on Red Hat Enterprise Linux: Targets, Initiators and SANs John VanDyk ENT/NREM Business Center Iowa

SAN: a Storage Area Network

172.16.1.1

172.16.1.20

1000Bt Ethernet125MB/s

HBA: 768MB/s8-drive RAID10: 1200MB/s

If you cannot afford 10G ethernet then gigabit may be a bottleneck.

Page 47: iSCSI on Red Hat Enterprise Linux: Targets, Initiators and ... · PDF fileiSCSI on Red Hat Enterprise Linux: Targets, Initiators and SANs John VanDyk ENT/NREM Business Center Iowa

SAN: a Storage Area Network

172.16.1.1172.16.1.2

172.16.1.20172.16.1.21

172.16.2.20172.16.2.21

172.16.2.1172.16.2.2

Page 48: iSCSI on Red Hat Enterprise Linux: Targets, Initiators and ... · PDF fileiSCSI on Red Hat Enterprise Linux: Targets, Initiators and SANs John VanDyk ENT/NREM Business Center Iowa

InitiatorNode

TargetNode

Name: iqn.2013-02.edu.iastate.ent:target0Address: 172.16.1.20:3260 Address: 172.16.1.21:3260 Address: 172.16.2.20:3260 Address: 172.16.2.21:3260Alias: BioData

A target can be made available at multiple addresses, creating multiple routes from the initiator to the target. These can be used for failover or performance.

Page 49: iSCSI on Red Hat Enterprise Linux: Targets, Initiators and ... · PDF fileiSCSI on Red Hat Enterprise Linux: Targets, Initiators and SANs John VanDyk ENT/NREM Business Center Iowa

References:Hufferd, John L. 2002. iSCSI: The Universal Storage Connection

The Free Dictionary http://encyclopedia2.thefreedictionary.com

http://www.ietf.org/rfc/rfc3721.txt

/usr/share/doc/iscsi-initiator-utils-6.2.0.872/README

/usr/share/doc/scsi-target-utils-1.0.24/README