• Aucun résultat trouvé

24 .3. Configuring an Export ed File Syst em for Diskless Client s

Chapter 25. Online Storage Management

25.1. T arget Set up

Red Hat Enterprise Linux 7 uses targ etcl i as a front-end for viewing, editing, and saving the configuration of the Linux-IO Target without the need to manipulate the kernel target's configuration files directly. targ etcl i is a command line interface that allows an administrator to export local storage resources (backed by either files, volumes, local SCSI devices, or RAM disks) to remote systems. It has a tree-based layout, includes built-in tab-completion, and provides full auto-complete support and inline documentation.

Note

targ etcl i's hierachy does not always match up to the kernel interface. This is because it is designed to be simplified where possible.

25.1.1. Inst all and run

targ etcl i

To install targ etcl i, run:

# yum install targetcli

⁠Chapt er 2 5. O nline St orage Management

Start the target service:

# systemctl start target

Configure target to persistantly start at boot time:

# systemctl enable target

To start using targ etcl i, run targ etcl i and to get a layout of the tree interface, run l s:

# targetcli :

/> ls

o- /...[...]

o- backstores...[...]

| o- block...[Storage Objects: 0]

| o- fileio...[Storage Objects: 0]

| o- pscsi...[Storage Objects: 0]

| o- ramdisk...[Storage Ojbects: 0]

o- iscsi...[Targets: 0]

o- loopback...[Targets: 0]

Note

In Red Hat Enterprise Linux 7.0, running a targ etcl i command from bash (for example, targ etcl i i scsi / create) would not work, but would also give no error code. This has been fixed in Red Hat Enterprise Linux 7.1 to provide an error status code, thus making it more useful to use with shell scripts.

25.1.2. Creat e a Backst ore

Backstores enable support for different methods of storing an exported LUN's data on the local machine. Creating a storage object defines the resources the backstore will use.

Note

In Red Hat Enterprise Linux 6 the term 'backing-store' is used to refer to the mappings created.

However, to avoid confusion between the various ways 'backstores' can be used, in Red Hat Enterprise Linux 7 the term 'storage objects' refers to the mappings created and 'backstores' is used to describe the different types of backing devices.

The backstore devices that LIO supports are:

FILEIO ( Lin u x f ile- b acked st o rag e)

FILEIO storage objects can support either wri te_back or wri te_thru operation. The wri te_back enables the local file system cache. This improves performance but increases the risk of data loss. It is recommended to use wri te_back= fal se to disable

wri te_back in favor of wri te_thru.

To create a fileio storage object, run the command /backsto res/fi l ei o create file_name file_location file_size wri te_back= fal se. For example:

/> /backstores/fileio create file1 /tmp/disk1.img 200M write_back=false

Created fileio file1 with size 209715200 BLO CK ( Lin u x BLO CK d evices)

The block driver allows the use of any block device that appears in the /sys/bl o ck to be used with LIO. This includes physical devices (for example, HDDs, SSDs, CDs, DVDs) and logical devices (for example, software or hardware RAID volumes, or LVM volumes).

Note

BLOCK backstores usually provide the best performance.

To create a BLOCK backstore using the /d ev/sd b block device, use the following command:

/> /backstores/fileio create name=block_backend dev=/dev/sdb Generating a wwn serial.

Created block storage object block_backend using /dev/sdb.

PSCSI ( Lin u x p ass- t h ro u g h SCSI d evices)

Any storage object that supports direct pass-through of SCSI commands without SCSI emulation, and with an underlying SCSI device that appears with lsscsi in

/pro c/scsi /scsi (such as a SAS hard drive) can be configured as a backstore. SCSI-3 and higher is supported with this subsystem.

Warning

PSCSI should only be used by advanced users. Advanced SCSI commands such as for Aysmmetric Logical Unit Assignment (ALUAs) or Persistent Reservations (for example, those used by VMware ESX, and vSphere) are usually not implemented in the device firmware and can cause malfunctions or crashes. When in doubt, use BLOCK for production setups instead.

To create a PSCSI backstore for a physical SCSI device, a T Y P E_R O M device using /d ev/sr0 in this example, use:

/> backstores/pscsi/ create name=pscsi_backend dev=/dev/sr0 Generating a wwn serial.

Created pscsi storage object pscsi_backend using /dev/sr0 Memo ry Co p y RAM d isk ( Lin u x RAMDISK_MCP)

⁠Chapt er 2 5. O nline St orage Management

Memory Copy RAM disks (ramd i sk) provide RAM disks with full SCSI emulation and separate memory mappings using memory copy for initiators. This provides capability for multi-sessions and is particularly useful for fast, volatile mass storage for production purposes.

To create a 1GB RAM disk backstore, use the following command:

/> backstores/ramdisk/ create name=rd_backend size=1GB Generating a wwn serial.

Created rd_mcp ramdisk rd_backend with size 1GB.

25.1.3. Creat e an iSCSI T arget

To create an iSCSI target:

Pro ced u re 25.1. Creat e an iSCSI t arg et 1. Run targ etcl i.

2. Move into the iSCSI configuration path:

/> iscsi/

Note

The cd command is also accepted to change directories, as well as simply listing the path to move into.

3. Create an iSCSI target using a default target name.

/iscsi> create Created target

iqn.2003-01.org.linux-iscsi.hostname.x8664:sn.78b473f296ff Created TPG1

Or create an iSCSI target using a specified name.

/iscsi > create iqn.2006-04.com.example:444 Created target iqn.2006-04.com.example:444 Created TPG1

4. Verify that the newly created target is visible when targets are listed with l s.

/iscsi > ls

o- iscsi...[1 Target]

o- iqn.2006-04.com.example:444...[1 TPG]

o- tpg1...[enabled, auth]

o- acls...[0 ACL]

o- luns...[0 LUN]

o- portals...[0 Portal]

Note

As of Red Hat Enterprise Linux 7.1, whenever a target is created, a default portal is also created.

25.1.4 . Configure an iSCSI Port al

To configure an iSCSI portal, an iSCSI target must first be created and associated with a TPG. For instructions on how to do this, refer to Section 25.1.3, “ Create an iSCSI Target”.

Pro ced u re 25.2. Creat e an iSCSI Po rt al 1. Move into the TPG.

/iscsi> iqn.2006-04.example:444/tpg1/

2. There are two ways to create a portal: create a default portal, or create a portal specifying what IP address to listen to.

Creating a default portal uses the default iSCSI port 3260 and allows the target to listen on all IP addresses on that port.

/iscsi/iqn.20...mple:444/tpg1> portals/ create Using default IP port 3260

Binding to INADDR_Any (0.0.0.0) Created network portal 0.0.0.0:3260

To create a portal specifying what IP address to listen to, use the following command.

/iscsi/iqn.20...mple:444/tpg1> portals/ create 192.168.122.137 Using default IP port 3260

Created network portal 192.168.122.137:3260

3. Verify that the newly created portal is visible with the l s command.

/iscsi/iqn.20...mple:444/tpg1> ls

o- tpg... [enambled, auth]

o- acls ...[0 ACL]

o- luns ...[0 LUN]

o- portals ...[1 Portal]

o- 192.168.122.137:3260...[OK]

25.1.5. Configure LUNs

To configure LUNs, first create storage objects. See Section 25.1.2, “ Create a Backstore” for more information.

Pro ced u re 25.3. Co n f ig u re LUNs

1. Create LUNs of already created storage objects.

⁠Chapt er 2 5. O nline St orage Management

/iscsi/iqn.20...mple:444/tpg1> luns/ create /backstores/ramdisk/ramdisk1

Created LUN 0.

/iscsi/iqn.20...mple:444/tpg1> luns/ create /backstores/block/block1 Created LUN 1.

/iscsi/iqn.20...mple:444/tpg1> luns/ create /backstores/fileio/file1 Created LUN 2.

2. Show the changes.

/iscsi/iqn.20...mple:444/tpg1> ls

o- tpg... [enambled, auth]

o- acls ...[0 ACL]

o- luns ...[3 LUNs]

| o- lun0...[ramdisk/ramdisk1]

| o- lun1...[block/block1 (/dev/vdb1)]

| o- lun2...[fileio/file1 (/foo.img)]

o- portals ...[1 Portal]

o- 192.168.122.137:3260...[OK]

25.1.6. Configure ACLs

Create an ACL for each initiator that will be connecting. This enforces authentication when that initiator connects, allowing only LUNs to be exposed to each initiator. Usually each initator has exclusive access to a LUN. Both targets and initiators have unique identifying names. The initiator's unique name must be known to configure ACLs. For open-iscsi initiators, this can be found in /etc/i scsi /i ni ti ato rname. i scsi.

Pro ced u re 25.4 . Co n f ig u re ACLs 1. Move into the acls directory.

/iscsi/iqn.20...mple:444/tpg1> acls/

2. Create an ACL. For example:

/iscsi/iqn.20...444/tpg1/acls> create iqn.2006-04.com.example.foo:888

Created Node ACL for iqn.2006-04.com.example.foo:888 Created mapped LUN 2.

Created mapped LUN 1.

Created mapped LUN 0.

Note

The above example's behavior depends on the setting used. In this case, the global setting auto _ad d _mapped _l uns is used. This automatically maps LUNs to any created ACL.

3. Show the changes.

/iscsi/iqn.20...444/tpg1/acls> ls

o- acls ...[1 ACL]

o- iqn.2006-04.com.example.foo:888 ....[3 Mapped LUNs, auth]

o- mapped_lun0 ...[lun0 ramdisk/ramdisk1 (rw)]

o- mapped_lun1 ...[lun1 block/block1 (rw)]

o- mapped_lun2 ...[lun2 fileio/file1 (rw)]

25.1.7. Fibre-Channel over Et hernet (FCoE) T arget Set up

In addition to mounting LUNs over FCoE, as described in Section 25.3, “ Configuring a Fibre-Channel Over Ethernet Interface”, exporting LUNs to other machines over FCoE is also supported with the aid of targ etcl i.

Important

Before proceeding, refer to Section 25.3, “ Configuring a Fibre-Channel Over Ethernet Interface” and verify that basic FCoE setup is completed, and that fco ead m -i displays configured FCoE interfaces.

Pro ced u re 25.5. Co n f ig u re FCo E t arg et

1. Setting up an FCoE target requires the installation of the targ etcl i package, along with its dependencies. Refer to Section 25.1, “ Target Setup” for more information on targ etcl i basics and set up.

2. Create an FCoE target instance on an FCoE interface.

/> tcm_fc/ create 00:11:22:33:44:55:66:77

If FCoE interfaces are present on the system, tab-completing after create will list available interfaces. If not, ensure fco ead m -i shows active interfaces.

3. Map a backstore to the target instance.

Examp le 25.1. Examp le o f map p in g a b ackst o re t o t h e t arg et in st an ce /> tcm_fc/00:11:22:33:44:55:66:77

/> l uns/ create /backsto res/fi l ei o /example2

4. Allow access to the LUN from an FCoE initiator.

/> acl s/ create 00:99:88:77:66:55:44:33 The LUN should now be accessible to that initiator.

5. To make the changes persistant across reboots, use the saveco nfi g command and type

⁠Chapt er 2 5. O nline St orage Management

6. Exit targ etcl i by typing exi t or entering ctrl+D.

25.1.8.

targ etcl i

References

For more information on targ etcl i, refer to the following resources:

man targ etcl i

The targ etcl i man page. It includes an example walk through.

T h e Lin u x SCSI T arg et Wiki

http://linux-iscsi.org/wiki/Targetcli Screen cast b y An d y G ro ver

https://www.youtube.com/watch?v=BkBGTBadOO8

Note

This was uploaded on February 28, 2012. As such, the service name has changed from targ etcl i to targ et.