Este conteúdo não está disponível no idioma selecionado.
Chapter 25. Online Storage Management
sysfs objects. Red Hat advises that the sysfs object names and directory structure are subject to change in major Red Hat Enterprise Linux releases. This is because the upstream Linux kernel does not provide a stable internal API. For guidelines on how to reference sysfs objects in a transportable way, refer to the document /usr/share/doc/kernel-doc-version/Documentation/sysfs-rules.txt in the kernel source tree for guidelines.
Warning
25.1. Target Setup Copiar o linkLink copiado para a área de transferência!
targetcli shell 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. The targetcli tool is a command-line interface that allows an administrator to export local storage resources, which are backed by either files, volumes, local SCSI devices, or RAM disks, to remote systems. The targetcli tool has a tree-based layout, includes built-in tab completion, and provides full auto-complete support and inline documentation.
targetcli does not always match the kernel interface exactly because targetcli is simplified where possible.
Important
targetcli are persistent, start and enable the target service:
systemctl start target systemctl enable target
# systemctl start target
# systemctl enable target
25.1.1. Installing and Running targetcli Copiar o linkLink copiado para a área de transferência!
targetcli, use:
yum install targetcli
# yum install targetcli
target service:
systemctl start target
# systemctl start target
target to start at boot time:
systemctl enable target
# systemctl enable target
3260 in the firewall and reload the firewall configuration:
firewall-cmd --permanent --add-port=3260/tcp firewall-cmd --reload
# firewall-cmd --permanent --add-port=3260/tcp
Success
# firewall-cmd --reload
Success
targetcli command, and then use the ls command for the layout of the tree interface:
Note
targetcli command from Bash, for example, targetcli iscsi/ create, does not work and does not return an error. Starting with Red Hat Enterprise Linux 7.1, an error status code is provided to make using targetcli with shell scripts more useful.
25.1.2. Creating a Backstore Copiar o linkLink copiado para a área de transferência!
Note
- FILEIO (Linux file-backed storage)
- FILEIO storage objects can support either
write_backorwrite_thruoperation. Thewrite_backenables the local file system cache. This improves performance but increases the risk of data loss. It is recommended to usewrite_back=falseto disablewrite_backin favor ofwrite_thru.To create a fileio storage object, run the command/backstores/fileio create file_name file_location file_size write_back=false. For example:/> /backstores/fileio create file1 /tmp/disk1.img 200M write_back=false Created fileio file1 with size 209715200
/> /backstores/fileio create file1 /tmp/disk1.img 200M write_back=false Created fileio file1 with size 209715200Copy to Clipboard Copied! Toggle word wrap Toggle overflow - BLOCK (Linux BLOCK devices)
- The block driver allows the use of any block device that appears in the
/sys/blockto 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 any block device, use the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow /> /backstores/block create name=block_backend dev=/dev/vdb Generating a wwn serial. Created block storage object block_backend using /dev/vdb.
/> /backstores/block create name=block_backend dev=/dev/vdb Generating a wwn serial. Created block storage object block_backend using /dev/vdb.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Note
You can also create a BLOCK backstore on a logical volume. - PSCSI (Linux pass-through SCSI devices)
- 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
/proc/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, aTYPE_ROMdevice using/dev/sr0in 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
/> backstores/pscsi/ create name=pscsi_backend dev=/dev/sr0 Generating a wwn serial. Created pscsi storage object pscsi_backend using /dev/sr0Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Memory Copy RAM disk (Linux RAMDISK_MCP)
- Memory Copy RAM disks (
ramdisk) 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.
/> backstores/ramdisk/ create name=rd_backend size=1GB Generating a wwn serial. Created rd_mcp ramdisk rd_backend with size 1GB.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
25.1.3. Creating an iSCSI Target Copiar o linkLink copiado para a área de transferência!
Procedure 25.1. Creating an iSCSI target
- Run
targetcli. - Move into the iSCSI configuration path:
/> iscsi/
/> iscsi/Copy to Clipboard Copied! Toggle word wrap Toggle overflow Note
Thecdcommand is also accepted to change directories, as well as simply listing the path to move into. - 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
/iscsi> create Created target iqn.2003-01.org.linux-iscsi.hostname.x8664:sn.78b473f296ff Created TPG1Copy to Clipboard Copied! Toggle word wrap Toggle overflow 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
/iscsi > create iqn.2006-04.com.example:444 Created target iqn.2006-04.com.example:444 Created TPG1Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Verify that the newly created target is visible when targets are listed with
ls.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Note
25.1.4. Configuring an iSCSI Portal Copiar o linkLink copiado para a área de transferência!
Note
/iscsi/iqn-name/tpg1/portals delete ip_address=0.0.0.0 ip_port=3260 then create a new portal with the required information.
Procedure 25.2. Creating an iSCSI Portal
- Move into the TPG.
/iscsi> iqn.2006-04.example:444/tpg1/
/iscsi> iqn.2006-04.example:444/tpg1/Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 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
/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:3260Copy to Clipboard Copied! Toggle word wrap Toggle overflow 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
/iscsi/iqn.20...mple:444/tpg1> portals/ create 192.168.122.137 Using default IP port 3260 Created network portal 192.168.122.137:3260Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Verify that the newly created portal is visible with the
lscommand.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
25.1.5. Configuring LUNs Copiar o linkLink copiado para a área de transferência!
Procedure 25.3. Configuring LUNs
- Create LUNs of already created storage objects.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Show the changes.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Note
Be aware that the default LUN name starts at 0, as opposed to 1 as was the case when usingtgtdin Red Hat Enterprise Linux 6. - Configure ACLs. For more information, see Section 25.1.6, “Configuring ACLs”.
Important
Procedure 25.4. Create a Read-only LUN
- To create a LUN with read-only permissions, first use the following command:
/> set global auto_add_mapped_luns=false Parameter auto_add_mapped_luns is now 'false'.
/> set global auto_add_mapped_luns=false Parameter auto_add_mapped_luns is now 'false'.Copy to Clipboard Copied! Toggle word wrap Toggle overflow This prevents the auto mapping of LUNs to existing ACLs allowing the manual mapping of LUNs. - Next, manually create the LUN with the command
iscsi/target_iqn_name/tpg1/acls/initiator_iqn_name/ create mapped_lun=next_sequential_LUN_number tpg_lun_or_backstore=backstore write_protect=1.Copy to Clipboard Copied! Toggle word wrap Toggle overflow The mapped_lun1 line now has (ro) at the end (unlike mapped_lun0's (rw)) stating that it is read-only. - Configure ACLs. For more information, see Section 25.1.6, “Configuring ACLs”.
25.1.6. Configuring ACLs Copiar o linkLink copiado para a área de transferência!
/etc/iscsi/initiatorname.iscsi.
Procedure 25.5. Configuring ACLs
- Move into the acls directory.
/iscsi/iqn.20...mple:444/tpg1> acls/
/iscsi/iqn.20...mple:444/tpg1> acls/Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Create an ACL. Either use the initiator name found in
/etc/iscsi/initiatorname.iscsion the initiator, or if using a name that is easier to remember, refer to Section 25.2, “Creating an iSCSI Initiator” to ensure ACL matches the initiator. For example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Note
The given example's behavior depends on the setting used. In this case, the global settingauto_add_mapped_lunsis used. This automatically maps LUNs to any created ACL.You can set user-created ACLs within the TPG node on the target server:/iscsi/iqn.20...scsi:444/tpg1> set attribute generate_node_acls=1
/iscsi/iqn.20...scsi:444/tpg1> set attribute generate_node_acls=1Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Show the changes.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
25.1.7. Configuring Fibre Channel over Ethernet (FCoE) Target Copiar o linkLink copiado para a área de transferência!
targetcli.
Important
fcoeadm -i displays configured FCoE interfaces.
Procedure 25.6. Configure FCoE target
- Setting up an FCoE target requires the installation of the
targetclipackage, along with its dependencies. Refer to Section 25.1, “Target Setup” for more information ontargetclibasics and set up. - Create an FCoE target instance on an FCoE interface.
/> tcm_fc/ create 00:11:22:33:44:55:66:77
/> tcm_fc/ create 00:11:22:33:44:55:66:77Copy to Clipboard Copied! Toggle word wrap Toggle overflow If FCoE interfaces are present on the system, tab-completing aftercreatewill list available interfaces. If not, ensurefcoeadm -ishows active interfaces. - Map a backstore to the target instance.
Example 25.1. Example of Mapping a Backstore to the Target Instance
/> tcm_fc/00:11:22:33:44:55:66:77
/> tcm_fc/00:11:22:33:44:55:66:77Copy to Clipboard Copied! Toggle word wrap Toggle overflow /> luns/ create /backstores/fileio/example2
/> luns/ create /backstores/fileio/example2Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Allow access to the LUN from an FCoE initiator.
/> acls/ create 00:99:88:77:66:55:44:33
/> acls/ create 00:99:88:77:66:55:44:33Copy to Clipboard Copied! Toggle word wrap Toggle overflow The LUN should now be accessible to that initiator. - To make the changes persistent across reboots, use the
saveconfigcommand and typeyeswhen prompted. If this is not done the configuration will be lost after rebooting. - Exit
targetcliby typingexitor entering ctrl+D.
25.1.8. Removing Objects with targetcli Copiar o linkLink copiado para a área de transferência!
/> /backstores/backstore-type/backstore-name
/> /backstores/backstore-type/backstore-name
/> /iscsi/iqn-name/tpg/acls/ delete iqn-name
/> /iscsi/iqn-name/tpg/acls/ delete iqn-name
/> /iscsi delete iqn-name
/> /iscsi delete iqn-name
25.1.9. targetcli References Copiar o linkLink copiado para a área de transferência!
targetcli, refer to the following resources:
man targetcli- The
targetcliman page. It includes an example walk through. - Screencast by Andy Grover
Note
This was uploaded on February 28, 2012. As such, the service name has changed fromtargetclitotarget.