Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

17.3 Configure the iSCSI service side


May 24, 2021 That's what Linux should learn



iSCSI technology is divided into service-side (target) and client (launchor) in the form of work. T he iSCSI service side is the server used to store hard disk storage resources, and it serves as the storage side of the previously created RAID disk array, providing users with available storage resources. T he iSCSI client is the software used by the user to access storage resources on the remote service side. The IP addresses used by the iSCSI service side and clients are configured as table 17-1 below.

Table 17-1 iSCSI service side and client operating system and IP address

Host Name Operating System IP Address iSCSI Service Side RHEL 7 192.168.10.10 iSCSI Client RHEL 7 192.168.10.20 Step 1: Install the iSCSI server and configure command tools after the Yum software repository is configured. By adding the -y parameter after the yum command, no manual confirmation is required during installation:

[root@linuxprobe ~]# yum -y install targetd targetcli Loaded plugins: langpacks, product-id, subscription-manager .................. O mit some of the output information... I nstalling: targetcli noarch 2.1.fb34-1.el7 rhel 55 k targetd noarch 0.7.1-1.el7 rhel 48 k Installing for dependencies: PyYAML x86_64 3.10-11.el7 rhel 153 k libyaml x86_64 0.1.4-10.el7 rhel 55 k lvm2-python-libs x86_64 7:2.02.105-14.el7 rhel 153 k pyparsing noarch 1.5.6-9.el7 rhel 94 k python-configshell noarch 1:1.1.fb11-3.el7 rhel 64 k python-kmod x86_64 0.9-4.el7 rhel 57 k p ython-rtslib noarch 2.1.fb46-1.el7 rhel 75 k python-setproctitle x86_64 1.1.6-5.el7 rhel 15 k python-urwid x86_64 1.1.1-3.el7 rhel 654 k .................. O mit some of the output information... I nstalled: targetcli.noarch 0:2.1.fb34-1.el7 targetd.noarch 0:0.7.1-1.el7 Dependency Installed: PyYAML.x86_64 0:3.10-11.el7 libyaml.x86_64 0:0.1.4-10.el7 lvm2-python-libs.x86_64 7:2.02.105-14.el7 pyparsing.noarch 0:1.5.6-9.el7 python-configshell.noarch 1:1.1.fb11-3.el7 python-kmod.x86_64 0:0.9-4.el7 python-rtslib.noarch 0:2.1.fb46-1.el7 p ython-setproctitle.x86_64 0:1.1.6-5.el7 python-urwid.x86_64 0:1.1.1-3.el7 Complete! After the installation is complete, start the iSCSI service-side program targettd, and then add the service program to the boot startup item so that the next time the server restarts, the user can still provide iSCSI shared storage resources service:

root@linuxprobe the systemctl start targetd ( root@linuxprobe . T argetcli is a dedicated configuration command for managing iSCSI service-side storage resources, which provides interactive configuration capabilities similar to the fdisk command, abstracting the configuration content of iSCSI shared resources into a "directory" form, and we simply fill in all kinds of configuration information into the appropriate "directory". T he main difficulty here is to understand the role of each "parameter directory". When the configuration parameters are correctly filled in in the Directory, the iSCSI service side can also provide a shared resource service.

You can see the interactive configuration interface after executing the targettcli command. M any Linux commands can be used in this interface, such as using ls to view the structure of directory parameters and switch to different directories using cd. / backstores/block is where the iSCSI service side configures shared devices. We need to add the RAID 5 disk array md0 file we just created to the Resource Pool that configures the shared device and rename the file disk0 so that the user does not know which hard drive in the server is providing the shared storage resources, but only sees a storage device named disk0.

[root@linuxprobe ~]# targetcli Warning: Could not load preferences file /root/.targetcli/prefs.bin. targetcli shell version 2.1.fb34 Copyright 2011-2013 by Datera, Inc and others. For help on commands, type 'help'. /> ls 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 /> cd /backstores/block /backstores/block> create disk0 /dev/md0 Created block storage object disk0 using /dev/md0. /backstores/block> cd / /> ls o- / ..................................................................... [...] o- backstores .......................................................... [ ...] | o - block .............................................. [ Storage Objects: 1] | | o - disk0 ..................... [ /dev/md0 (40.0GiB) write-thru deactivated] | o - fileio ............................................. [ Storage Objects: 0] | o - pscsi .............................................. [ Storage Objects: 0] | o - ramdisk ............................................ [ Storage Objects: 0] o- iscsi ........................................................ [ Targets: 0] o- loopback ..................................................... S tep 3: Create the iSCSI target name and configure the shared resources. T he iSCSI target name is automatically generated by the system, which is a unique string for describing shared resources. T he string will be available later when the user scans the iSCSI service side, so we don't need to remember it. A fter the target name is generated, a new "directory" with the same name as its string is also created in the /iscsi parameter directory to hold the shared resources. We need to add the hard disk devices that were previously added to the iSCSI shared resource pool to this new directory so that users can default to the shared storage resources provided by this hard disk device once they are logged on to the iSCSI service side.

/> cd iscsi /iscsi> /iscsi> create Created target iqn.2003-01.org.linux-iscsi.linuxprobe.x8664:sn.d497c356ad80. C reated TPG 1. / iscsi> cd iqn.2003-01.org.linux-iscsi.linuxprobe.x8664:sn.d497c356ad80/ /iscsi/iqn.20.... d 497c356ad80> ls o- iqn.2003-01.org.linux-iscsi.linuxprobe.x8664:sn.d497c356ad80 ...... [ TPGs: 1] o- tpg1 ............................................... [ no-gen-acls, no-auth] o- acls .......................................................... [ ACLs: 0] o- luns .......................................................... [ LUNs: 0] o- portals .................................................... [ Portals: 0] /iscsi/iqn.20.... d 497c356ad80> cd tpg1/luns /iscsi/iqn.20... d 80/tpg1/luns> create /backstores/block/disk0 Created LUN 0. S tep 4: Set up an access control list (ACL). T he iSCSI protocol is verified by the client name, that is, the user does not need to enter a password when accessing the storage shared resource, as long as the name of the iSCSI client is consistent with a name entry in the access control list set up on the service side, so a string of names that validate the user information needs to be written to the profile on the iSCSI service side. T he acls parameter directory is used to hold the names of clients that have access to shared storage resources on the iSCSI service side. Mr. Liu recommends appending parameters similar to: client after the iSCSI target that has just been generated by the system, which ensures that the client's name is unique and very easy to manage and read:

/iscsi/iqn.20... d 80/tpg1/luns> cd .. / iscsi/iqn.20... c 356ad80/tpg1> cd acls /iscsi/iqn.20... d 80/tpg1/acls> create iqn.2003-01.org.linux-iscsi.linuxprobe.x8664:sn.d497c356ad80:client Created Node ACL for iqn.2003-01.org.linux-iscsi.linuxprobe.x8664:sn.d497c356ad80:client Created mapped LUN 0. S tep 5: Set the listening IP address and port number on the iSCSI service side. T here may be multiple network cards on servers located in a production environment, so which network card or IP address provides shared storage resources externally? T his requires us to manually define the information on the iSCSI service side in the configuration file, i.e. write the IP address of the server in the portals parameter directory. The next 3260 port of server 192.168.10.10 will be automatically turned on by the system to provide iSCSI shared storage resource services:

/iscsi/iqn.20... d 80/tpg1/acls> cd .. / iscsi/iqn.20... c 356ad80/tpg1> cd portals /iscsi/iqn.20.../tpg1/portals> create 192.168.10.10 Using default IP port 3260 Created network portal 192.168.10.10:3260. S tep 6: Check the configuration information when configured, restart the iSCSI service-side program, and configure the firewall policy. O nce the parameter file is configured, you can browse through the information that has just been configured to ensure that it is basically consistent with the information below. E nter the exit command to exit the configuration after confirming that the information is correct. N ote that we should never habitually press the Ctrl-C key combination to end the process so that the configuration file is not saved and our work is in vain. Finally, restart the iSCSI service-side program, and then set the firewalld firewall policy, so that it releases the traffic of the 3260/tcp port number.

/iscsi/iqn.20.../tpg1/portals> ls / o- / ........................... [ ...] o - backstores................. [ ...] | o - block ................... [ Storage Objects: 1] | | o - disk0 ................. [ /dev/md0 (40.0GiB) write-thru activated] | o - fileio .................. [ Storage Objects: 0] | o - pscsi ................... [ Storage Objects: 0] | o - ramdisk ................. [ Storage Objects: 0] o- iscsi ..................... [ Targets: 1] | o - iqn.2003-01.org.linux-iscsi.linuxprobe.x8664:sn.d497c356ad80 .... [ TPGs: 1] | o - tpg1 .................. [ no-gen-acls, no-auth] | o - acls ........................................................ [ ACLs: 1] | | o - iqn.2003-01.org.linux-iscsi.linuxprobe.x8664:sn.d497c356ad80:client [Mapped LUNs: 1] | | o - mapped_lun0 ............................................. [lun0 block/disk0 (rw)]
o- luns .................... [LUNs: 1] | | o- lun0 .............. [block/disk0 (/dev/md0)] | o- portals ............. [Portals: 1] | o- 192.168.10.10:3260 [OK] o- loopback .................. [Targets: 0] /> exit Global pref auto_save_on_exit=true Last 10 configs saved in /etc/target/backup. Configuration saved to /etc/target/saveconfig.json [root@linuxprobe ~]# systemctl restart targetd [root@linuxprobe ~]# firewall-cmd --permanent --add-port=3260/tcp success [root@linuxprobe ~]# firewall-cmd --reload success