Ce contenu n'est pas disponible dans la langue sélectionnée.
12.5. iSCSI-based Storage Pools
12.5.1. Configuring a Software iSCSI Target Copier lienLien copié sur presse-papiers!
Procedure 12.4. Creating an iSCSI target
Install the required packages
Install the scsi-target-utils package and all dependenciesyum install scsi-target-utils
# yum install scsi-target-utils
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Start the tgtd service
Thetgtd
service host physical machines SCSI targets and uses the iSCSI protocol to host physical machine targets. Start thetgtd
service and make the service persistent after restarting with thechkconfig
command.service tgtd start chkconfig tgtd on
# service tgtd start # chkconfig tgtd on
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Optional: Create LVM volumes
LVM volumes are useful for iSCSI backing images. LVM snapshots and resizing can be beneficial for guest virtual machines. This example creates an LVM image named virtimage1 on a new volume group named virtstore on a RAID5 array for hosting guest virtual machines with iSCSI.Create the RAID array
Creating software RAID5 arrays is covered by the Red Hat Enterprise Linux Deployment Guide.Create the LVM volume group
Create a volume group named virtstore with thevgcreate
command.vgcreate virtstore /dev/md1
# vgcreate virtstore /dev/md1
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a LVM logical volume
Create a logical volume group named virtimage1 on the virtstore volume group with a size of 20GB using thelvcreate
command.lvcreate --size 20G -n virtimage1 virtstore
# lvcreate --size 20G -n virtimage1 virtstore
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The new logical volume, virtimage1, is ready to use for iSCSI.
Optional: Create file-based images
File-based storage is sufficient for testing but is not recommended for production environments or any significant I/O activity. This optional procedure creates a file based imaged named virtimage2.img for an iSCSI target.Create a new directory for the image
Create a new directory to store the image. The directory must have the correct SELinux contexts.mkdir -p /var/lib/tgtd/virtualization
# mkdir -p /var/lib/tgtd/virtualization
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the image file
Create an image named virtimage2.img with a size of 10GB.dd if=/dev/zero of=/var/lib/tgtd/virtualization/virtimage2.img bs=1M seek=10000 count=0
# dd if=/dev/zero of=/var/lib/tgtd/virtualization/virtimage2.img bs=1M seek=10000 count=0
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure SELinux file contexts
Configure the correct SELinux context for the new image and directory.restorecon -R /var/lib/tgtd
# restorecon -R /var/lib/tgtd
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The new file-based image, virtimage2.img, is ready to use for iSCSI.
Create targets
Targets can be created by adding a XML entry to the/etc/tgt/targets.conf
file. Thetarget
attribute requires an iSCSI Qualified Name (IQN). The IQN is in the format:iqn.yyyy-mm.reversed domain name:optional identifier text
iqn.yyyy-mm.reversed domain name:optional identifier text
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Where:- yyyy-mm represents the year and month the device was started (for example: 2010-05);
- reversed domain name is the host physical machines domain name in reverse (for example server1.example.com in an IQN would be com.example.server1); and
- optional identifier text is any text string, without spaces, that assists the administrator in identifying devices or hardware.
This example creates iSCSI targets for the two types of images created in the optional steps on server1.example.com with an optional identifier trial. Add the following to the/etc/tgt/targets.conf
file.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Ensure that the/etc/tgt/targets.conf
file contains thedefault-driver iscsi
line to set the driver type as iSCSI. The driver uses iSCSI by default.Important
This example creates a globally accessible target without access control. Refer to the scsi-target-utils for information on implementing secure access.Restart the tgtd service
Restart thetgtd
service to reload the configuration changes.service tgtd restart
# service tgtd restart
Copy to Clipboard Copied! Toggle word wrap Toggle overflow iptables configuration
Open port 3260 for iSCSI access withiptables
.iptables -I INPUT -p tcp -m tcp --dport 3260 -j ACCEPT service iptables save service iptables restart
# iptables -I INPUT -p tcp -m tcp --dport 3260 -j ACCEPT # service iptables save # service iptables restart
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Verify the new targets
View the new targets to ensure the setup was successful with thetgt-admin --show
command.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Warning
The ACL list is set to all. This allows all systems on the local network to access this device. It is recommended to set host physical machine access ACLs for production environments.Optional: Test discovery
Test whether the new iSCSI device is discoverable.iscsiadm --mode discovery --type sendtargets --portal server1.example.com
# iscsiadm --mode discovery --type sendtargets --portal server1.example.com 127.0.0.1:3260,1 iqn.2010-05.com.example.server1:iscsirhel6guest
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Optional: Test attaching the device
Attach the new device (iqn.2010-05.com.example.server1:iscsirhel6guest) to determine whether the device can be attached.iscsiadm -d2 -m node --login
# iscsiadm -d2 -m node --login scsiadm: Max file limits 1024 1024 Logging in to [iface: default, target: iqn.2010-05.com.example.server1:iscsirhel6guest, portal: 10.0.0.1,3260] Login to [iface: default, target: iqn.2010-05.com.example.server1:iscsirhel6guest, portal: 10.0.0.1,3260] successful.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Detach the device.iscsiadm -d2 -m node --logout
# iscsiadm -d2 -m node --logout scsiadm: Max file limits 1024 1024 Logging out of session [sid: 2, target: iqn.2010-05.com.example.server1:iscsirhel6guest, portal: 10.0.0.1,3260 Logout of [sid: 2, target: iqn.2010-05.com.example.server1:iscsirhel6guest, portal: 10.0.0.1,3260] successful.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow