@@ -349,3 +349,178 @@ root@ubu1104:/etc/iscsi/nodes# mount | grep is
349349/dev/sdc1 on /mnt/is2 type ext3 (rw)
350350/dev/sdd1 on /mnt/is3 type ext4 (rw)</screen >
351351</section >
352+ <?hard-pagebreak ?>
353+ <section ><title >iSCSI Target RHEL7/CentOS7</title >
354+ <para >The prefered tool to setup an iSCSI Target on RHEL is <command >targetcli</command >.</para >
355+ <screen >[root@centos7 ~]# <command >yum install targetcli</command >
356+ Loaded plugins: fastestmirror
357+ ...
358+ ...
359+ Installed:
360+ targetcli.noarch 0:2.1.fb37-3.el7
361+
362+ Complete!
363+ [root@centos7 ~]#</screen >
364+ <para >The <command >targetcli</command > tool is interactive and represents the configuration fo the <command >target</command > in a structure that resembles a directory tree with several files. Although this is explorable inside <command >targetcli</command > with <command >ls</command >, <command >cd</command > and <command >pwd</command >, this are not files on the file system.</para >
365+ <para >This tool also has tab-completion, which is very handy for the <command >iqn</command > names.</para >
366+ <screen >[root@centos7 ~]# <command >targetcli</command >
367+ targetcli shell version 2.1.fb37
368+ Copyright 2011-2013 by Datera, Inc and others.
369+ For help on commands, type 'help'.
370+
371+ /> <command >cd backstores/</command >
372+ /backstores> <command >ls</command >
373+ o- backstores ............................................................ [...]
374+ o- block ................................................ [Storage Objects: 0]
375+ o- fileio ............................................... [Storage Objects: 0]
376+ o- pscsi ................................................ [Storage Objects: 0]
377+ o- ramdisk .............................................. [Storage Objects: 0]
378+ /backstores> <command >cd block</command >
379+ /backstores/block> <command >ls</command >
380+ o- block .................................................. [Storage Objects: 0]
381+ /backstores/block> <command >create server1.disk1 /dev/sdb</command >
382+ Created block storage object server1.disk1 using /dev/sdb.
383+ /backstores/block> <command >ls</command >
384+ o- block .................................................. [Storage Objects: 1]
385+ o- server1.disk1 .................. [/dev/sdb (2.0GiB) write-thru deactivated]
386+ /backstores/block> <command >cd /iscsi</command >
387+ /iscsi> <command >create iqn.2015-04.be.linux:iscsi1</command >
388+ Created target iqn.2015-04.be.linux:iscsi1.
389+ Created TPG 1.
390+ Global pref auto_add_default_portal=true
391+ Created default portal listening on all IPs (0.0.0.0), port 3260.
392+ /iscsi> <command >cd /iscsi/iqn.2015-04.be.linux:iscsi1/tpg1/acls</command >
393+ /iscsi/iqn.20...si1/tpg1/acls> <command >create iqn.2015-04.be.linux:server2</command >
394+ Created Node ACL for iqn.2015-04.be.linux:server2
395+ /iscsi/iqn.20...si1/tpg1/acls> <command >cd iqn.2015-04.be.linux:server2</command >
396+ /iscsi/iqn.20...linux:server2> <command >set auth userid=paul</command >
397+ Parameter userid is now 'paul'.
398+ /iscsi/iqn.20...linux:server2> <command >set auth password=hunter2</command >
399+ Parameter password is now 'hunter2'.
400+ /iscsi/iqn.20...linux:server2> <command >cd /iscsi/iqn.2015-04.be.linux:iscsi1/tpg1/luns</command >
401+ /iscsi/iqn.20...si1/tpg1/luns> <command >create /backstores/block/server1.disk1</command >
402+ Created LUN 0.
403+ Created LUN 0->0 mapping in node ACL iqn.2015-04.be.linux:server2
404+ s/scsi/iqn.20...si1/tpg1/luns> <command >cd /iscsi/iqn.2015-04.be.linux:iscsi1/tpg1/portals</command >
405+ /iscsi/iqn.20.../tpg1/portals> <command >create 192.168.1.128</command >
406+ Using default IP port 3260
407+ Could not create NetworkPortal in configFS.
408+ /iscsi/iqn.20.../tpg1/portals> <command >cd /</command >
409+ /> <command >ls</command >
410+ o- / ..................................................................... [...]
411+ o- backstores .......................................................... [...]
412+ | o- block .............................................. [Storage Objects: 1]
413+ | | o- server1.disk1 ................ [/dev/sdb (2.0GiB) write-thru activated]
414+ | o- fileio ............................................. [Storage Objects: 0]
415+ | o- pscsi .............................................. [Storage Objects: 0]
416+ | o- ramdisk ............................................ [Storage Objects: 0]
417+ o- iscsi ........................................................ [Targets: 1]
418+ | o- iqn.2015-04.be.linux:iscsi1 ................................... [TPGs: 1]
419+ | o- tpg1 ........................................... [no-gen-acls, no-auth]
420+ | o- acls ...................................................... [ACLs: 1]
421+ | | o- iqn.2015-04.be.linux:server2 ..................... [Mapped LUNs: 1]
422+ | | o- mapped_lun0 ..................... [lun0 block/server1.disk1 (rw)]
423+ | o- luns ...................................................... [LUNs: 1]
424+ | | o- lun0 ............................. [block/server1.disk1 (/dev/sdb)]
425+ | o- portals ................................................ [Portals: 1]
426+ | o- 0.0.0.0:3260 ................................................. [OK]
427+ o- loopback ..................................................... [Targets: 0]
428+ /> <command >saveconfig</command >
429+ Last 10 configs saved in /etc/target/backup.
430+ Configuration saved to /etc/target/saveconfig.json
431+ /> <command >exit</command >
432+ Global pref auto_save_on_exit=true
433+ Last 10 configs saved in /etc/target/backup.
434+ Configuration saved to /etc/target/saveconfig.json
435+ [root@centos7 ~]#</screen >
436+ <para >Use the <command >systemd</command > tools to manage the service:</para >
437+ <screen >[root@centos7 ~]# <command >systemctl enable target</command >
438+ ln -s '/usr/lib/systemd/system/target.service' '/etc/systemd/system/multi-user.target.wants/target.service'
439+ [root@centos7 ~]# <command >systemctl start target</command >
440+ [root@centos7 ~]#</screen >
441+ <para >Depending on your organisations policy, you may need to configure firewall and SELinux. The screenshot belows adds a firewall rule to allow all traffic over port 3260, and disables SELinux.</para >
442+ <screen >[root@centos7 ~]# <command >firewall-cmd --permanent --add-port=3260/tcp</command >
443+ [root@centos7 ~]# <command >firewall-cmd --reload</command >
444+ [root@centos7 ~]# <command >setenforce 0</command ></screen >
445+ <para >The total configuration is visible using <command >ls</command > from the root.</para >
446+ <screen >[root@centos7 ~]# <command >targetcli</command >
447+ targetcli shell version 2.1.fb37
448+ Copyright 2011-2013 by Datera, Inc and others.
449+ For help on commands, type 'help'.
450+
451+ /> <command >ls</command >
452+ o- / ..................................................................... [...]
453+ o- backstores .......................................................... [...]
454+ | o- block .............................................. [Storage Objects: 1]
455+ | | o- server1.disk1 ................ [/dev/sdb (2.0GiB) write-thru activated]
456+ | o- fileio ............................................. [Storage Objects: 0]
457+ | o- pscsi .............................................. [Storage Objects: 0]
458+ | o- ramdisk ............................................ [Storage Objects: 0]
459+ o- iscsi ........................................................ [Targets: 1]
460+ | o- iqn.2015-04.be.linux:iscsi1 ................................... [TPGs: 1]
461+ | o- tpg1 ........................................... [no-gen-acls, no-auth]
462+ | o- acls ...................................................... [ACLs: 1]
463+ | | o- iqn.2015-04.be.linux:server2 ..................... [Mapped LUNs: 1]
464+ | | o- mapped_lun0 ..................... [lun0 block/server1.disk1 (rw)]
465+ | o- luns ...................................................... [LUNs: 1]
466+ | | o- lun0 ............................. [block/server1.disk1 (/dev/sdb)]
467+ | o- portals ................................................ [Portals: 1]
468+ | o- 0.0.0.0:3260 ................................................. [OK]
469+ o- loopback ..................................................... [Targets: 0]
470+ />
471+ /> <command >exit</command >
472+ Global pref auto_save_on_exit=true
473+ Last 10 configs saved in /etc/target/backup.
474+ Configuration saved to /etc/target/saveconfig.json
475+ [root@centos7 ~]#</screen >
476+ <para >The iSCSI Target is now ready.</para >
477+ </section >
478+ <section ><title >iSCSI Initiator RHEL7/CentOS7</title >
479+ <para >This is identical to the RHEL6/CentOS6 procedure:</para >
480+ <screen >[root@centos7 ~]# <command >yum install iscsi-initiator-utils</command >
481+ Loaded plugins: fastestmirror
482+ ...
483+ ...
484+ Installed:
485+ iscsi-initiator-utils.x86_64 0:6.2.0.873-29.el7
486+
487+ Dependency Installed:
488+ iscsi-initiator-utils-iscsiuio.x86_64 0:6.2.0.873-29.el7
489+
490+ Complete!</screen >
491+ <para >Map your initiator name to the <command >targetcli</command > acl.</para >
492+ <screen >[root@centos7 ~]# <command >cat /etc/iscsi/initiatorname.iscsi</command >
493+ InitiatorName=iqn.2015-04.be.linux:server2
494+ [root@centos7 ~]#</screen >
495+ <para >Enter the CHAP authentication in <command >/etc/iscsi/iscsid.conf</command >.</para >
496+ <screen >[root@centos7 ~]# <command >vi /etc/iscsi/iscsid.conf</command >
497+ ...
498+ [root@centos7 ~]# <command >grep ^node.session.auth /etc/iscsi/iscsid.conf</command >
499+ node.session.auth.authmethod = CHAP
500+ node.session.auth.username = paul
501+ node.session.auth.password = hunter2
502+ [root@centos7 ~]#</screen >
503+ <para >There are no extra devices yet...</para >
504+ <screen >[root@centos7 ~]# <command >fdisk -l | grep sd</command >
505+ Disk /dev/sda: 22.0 GB, 22038806528 bytes, 43044544 sectors
506+ /dev/sda1 * 2048 1026047 512000 83 Linux
507+ /dev/sda2 1026048 43042815 21008384 8e Linux LVM
508+ Disk /dev/sdb: 2147 MB, 2147483648 bytes, 4194304 sectors</screen >
509+ <para >Enable the service and discover the target.</para >
510+ <screen >[root@centos7 ~]# <command >systemctl enable iscsid</command >
511+ ln -s '/usr/lib/systemd/system/iscsid.service' '/etc/systemd/system/multi-user.target.wants/iscsid.service'
512+ [root@centos7 ~]# <command >iscsiadm -m discovery -t st -p 192.168.1.128</command >
513+ 192.168.1.128:3260,1 iqn.2015-04.be.linux:iscsi1</screen >
514+ <para >Log into the target and see /dev/sdc appear.</para >
515+ <screen >[root@centos7 ~]# <command >iscsiadm -m node -T iqn.2015-04.be.linux:iscsi1 -p 192.168.1.128 -l</command >
516+ Logging in to [iface: default, target: iqn.2015-04.be.linux:iscsi1, portal: 192.168.1.128,3260] (multiple)
517+ Login to [iface: default, target: iqn.2015-04.be.linux:iscsi1, portal: 192.168.1.128,3260] successful.
518+ [root@centos7 ~]#
519+ [root@centos7 ~]# <command >fdisk -l | grep sd</command >
520+ Disk /dev/sda: 22.0 GB, 22038806528 bytes, 43044544 sectors
521+ /dev/sda1 * 2048 1026047 512000 83 Linux
522+ /dev/sda2 1026048 43042815 21008384 8e Linux LVM
523+ Disk /dev/sdb: 2147 MB, 2147483648 bytes, 4194304 sectors
524+ Disk /dev/sdc: 2147 MB, 2147483648 bytes, 4194304 sectors
525+ [root@centos7 ~]# </screen >
526+ </section >
0 commit comments