Differences
This shows you the differences between two versions of the page.
linux_wiki:configure_a_system_as_either_an_iscsi_target_or_initiator_that_persistently_mounts_an_iscsi_target [2018/05/30 21:46] billdozor [Configure the iSCSI Target] |
linux_wiki:configure_a_system_as_either_an_iscsi_target_or_initiator_that_persistently_mounts_an_iscsi_target [2019/05/25 23:50] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Configure A System As Either An Iscsi Target Or Initiator That Persistently Mounts An Iscsi Target ====== | ||
- | |||
- | **General Information** | ||
- | |||
- | Creating iSCSI targets (storage on a server) and initiators (clients). | ||
- | |||
- | ---- | ||
- | |||
- | ====== Lab Setup ====== | ||
- | |||
- | The following virtual machines will be used: | ||
- | * server1.example.com (192.168.1.150) -> Client/ | ||
- | * server2.example.com (192.168.1.151) -> Server/ | ||
- | * **Add Disk**: Add a secondary disk to the Server/ | ||
- | |||
- | ---- | ||
- | |||
- | ====== Help ====== | ||
- | |||
- | Finding help in this section. | ||
- | * iSCSI target (server)< | ||
- | * iSCSI initiator (client)< | ||
- | |||
- | ---- | ||
- | |||
- | |||
- | ====== iSCSI Targets (Storage Server) ====== | ||
- | |||
- | The iSCSI targets are on the storage server and are the volumes that can be mounted by clients. | ||
- | |||
- | ===== Create Back-end Storage ===== | ||
- | |||
- | Create a back-end logical volume or partition that will be an iSCSI target. | ||
- | |||
- | Example:< | ||
- | pvcreate /dev/sdb1 | ||
- | vgcreate vgsan /dev/sdb1 | ||
- | lvcreate --extents 100%PVS --name lvstor01 vgsan /dev/sdb1 | ||
- | </ | ||
- | |||
- | ---- | ||
- | |||
- | ===== Install and Enable ===== | ||
- | |||
- | Install packages | ||
- | <code bash> | ||
- | yum install targetcli | ||
- | </ | ||
- | |||
- | \\ | ||
- | Enable the service | ||
- | <code bash> | ||
- | systemctl enable target | ||
- | </ | ||
- | |||
- | ===== Configure the iSCSI Target ===== | ||
- | |||
- | Start the targetcli interactive utility | ||
- | <code bash> | ||
- | targetcli | ||
- | </ | ||
- | |||
- | \\ | ||
- | The targetcli utility commands available depend upon your path. Navigation is done via cd, pwd, and ls just like you would expect in a shell.< | ||
- | o- / ................................................................. [...] | ||
- | o- backstores ...................................................... [...] | ||
- | | o- block .......................................... [Storage Objects: 0] | ||
- | | o- fileio ......................................... [Storage Objects: 0] | ||
- | | o- pscsi .......................................... [Storage Objects: 0] | ||
- | | o- ramdisk ........................................ [Storage Objects: 0] | ||
- | o- iscsi .................................................... [Targets: 0] | ||
- | o- loopback ................................................. [Targets: 0] | ||
- | /> pwd | ||
- | /</ | ||
- | * **Note:** Use tab for auto completion in paths and commands | ||
- | |||
- | \\ | ||
- | **Backing Storage:** Create a block storage object within the targetcli interactive prompt | ||
- | <code bash> | ||
- | /> backstores/ | ||
- | </ | ||
- | * backstores/ | ||
- | * create block1 -> Create a storage object named " | ||
- | * / | ||
- | |||
- | \\ | ||
- | **iSCSI Target**: Create an iSCSI Target IQN (Iscsi Qualified Name) | ||
- | <code bash> | ||
- | /> iscsi/ create wwn=iqn.2018-05.com.example.server2: | ||
- | </ | ||
- | * iscsi/ -> In the iscsi path | ||
- | * create iqn.2018-05.com.example.server2: | ||
- | * An IQN is how you refer to the target disk | ||
- | * All IQNs must start with " | ||
- | * Standard convention is to use the date (YYYY-MM) and reverse domain name | ||
- | * target is the target name | ||
- | * This creates an associated TPG (Target Portal Group) | ||
- | |||
- | \\ | ||
- | Change into the newly created IQN's TPG (Target Portal Group) and view the contents | ||
- | <code bash> | ||
- | /> cd iscsi/ | ||
- | / | ||
- | </ | ||
- | * Objects listed: | ||
- | * acls (access control lists can restrict access) | ||
- | * luns (logical unit number or the exported resource) | ||
- | * portals (IP addresses: | ||
- | * **Note:** In some earlier versions (RHEL 7.0-7.1), a portal is NOT automatically created. This may need to be created manually. | ||
- | |||
- | \\ | ||
- | **Create portal: RHEL 7.0 - 7.1 only** | ||
- | <code bash> | ||
- | / | ||
- | </ | ||
- | |||
- | \\ | ||
- | **LUN to Storage Map:** Create a LUN within the target portal group | ||
- | <code bash> | ||
- | / | ||
- | </ | ||
- | * luns/ -> In the luns path | ||
- | * create / | ||
- | |||
- | \\ | ||
- | **Client ACL:** Create an ACL for a client to be able to connect to the IQN in the future | ||
- | <code bash> | ||
- | / | ||
- | </ | ||
- | * acls/ -> In the acls path | ||
- | * create iqn.2018-05.com.example: | ||
- | * This is a combination of a new IQN (following a similar naming convention) and an identifier of your choosing. Together, this makes up the **client iscsi initiator name** that will be used. | ||
- | * iqn.2018-05.com.example -> IQN | ||
- | * :server1 -> an identifier of your choosing | ||
- | * **Alternatively: | ||
- | |||
- | \\ | ||
- | **OPTIONAL**: | ||
- | <code bash> | ||
- | / | ||
- | / | ||
- | </ | ||
- | |||
- | \\ | ||
- | Save and exit the targetcli utility | ||
- | <code bash>/ | ||
- | /> saveconfig | ||
- | /> exit | ||
- | </ | ||
- | |||
- | ===== Firewall and Start Service ===== | ||
- | |||
- | Firewall | ||
- | <code bash> | ||
- | firewall-cmd --permanent --add-port=3260/ | ||
- | firewall-cmd --reload | ||
- | |||
- | OR | ||
- | |||
- | firewall-cmd --permanent --add-service=iscsi-target | ||
- | firewall-cmd --reload | ||
- | </ | ||
- | * iscsi-target service available as of RHEL 7.2 | ||
- | |||
- | \\ | ||
- | Start the target | ||
- | <code bash> | ||
- | systemctl start target | ||
- | </ | ||
- | |||
- | ---- | ||
- | |||
- | ====== iSCSI Initiator (Client) ====== | ||
- | |||
- | Setting up an iSCSI initiator (client). | ||
- | |||
- | ===== Install Package ===== | ||
- | |||
- | Install initiator package | ||
- | <code bash> | ||
- | yum install iscsi-initiator-utils | ||
- | </ | ||
- | |||
- | ===== Configure Initiator and iscsid ===== | ||
- | |||
- | Edit initiator name and change to the name setup on the server | ||
- | <code bash> | ||
- | vim / | ||
- | |||
- | InitiatorName=iqn.2018-05.com.example: | ||
- | </ | ||
- | * Identifying client information needed to mount the disk | ||
- | * **Alternatively**, | ||
- | |||
- | \\ | ||
- | Edit authentication information if set (**optional**) | ||
- | <code bash> | ||
- | vim / | ||
- | |||
- | node.session.auth.authmethod = CHAP | ||
- | node.session.auth.username = myuser | ||
- | node.session.auth.password = mypassword | ||
- | </ | ||
- | |||
- | \\ | ||
- | Enable and start the iscsi service | ||
- | <code bash> | ||
- | systemctl enable iscsi | ||
- | systemctl start iscsi | ||
- | </ | ||
- | |||
- | ===== Login to iSCSI Portal ===== | ||
- | |||
- | **Note**: See ' | ||
- | |||
- | \\ | ||
- | Use the iscsiadm command to discover IQN Information | ||
- | <code bash> | ||
- | iscsiadm --mode discovery --type sendtargets --portal 192.168.1.151 | ||
- | </ | ||
- | * --mode discovery -> Find targets | ||
- | * --type sendtargets -> Tell portal to send all available targets | ||
- | * --portal <ip> -> server IP | ||
- | |||
- | \\ | ||
- | Login to the Target IQN (found during discovery) | ||
- | <code bash> | ||
- | iscsiadm --mode node --target iqn.2018-05.com.example.server2: | ||
- | </ | ||
- | * Default port is 3260 if not specified | ||
- | |||
- | ===== Configure iSCSI Disk ===== | ||
- | |||
- | View iSCSI Disk | ||
- | <code bash> | ||
- | lsblk --scsi | ||
- | </ | ||
- | |||
- | \\ | ||
- | Create a partition | ||
- | <code bash> | ||
- | fdisk /dev/sdb | ||
- | </ | ||
- | |||
- | \\ | ||
- | Create file system | ||
- | <code bash> | ||
- | mkfs.xfs /dev/sdb1 | ||
- | </ | ||
- | |||
- | \\ | ||
- | Get the disk UUID | ||
- | <code bash> | ||
- | blkid | grep sdb1 | ||
- | </ | ||
- | |||
- | \\ | ||
- | Mount via fstab | ||
- | <code bash> | ||
- | vim /etc/fstab | ||
- | |||
- | #Mount iscsi device | ||
- | UUID=< | ||
- | </ | ||
- | * _netdev -> Wait for the network to be available before mounting | ||
- | |||
- | \\ | ||
- | View Connected ISCSI Target Information | ||
- | <code bash> | ||
- | iscsiadm -m session -P 3 | ||
- | </ | ||
- | * -m session -> mode session | ||
- | * -P 3 -> Print level 3 (0-3 range of details) | ||
- | |||
- | ---- | ||