HOME RESTORATION DIGITAL PHOTOS DIGITAL BOOKS PROFESSIONAL HISTORY CONTACT ME


CentOS 7 Creating an iSCSI Target (Part 2)

Domain name: example.com     Realm name: EXAMPLE.COM

Workgroup: EXAMPLE     Server IP address: xx.xx.xx.xx

Server name: linuxsvr01     Client name: linuxclnt01

Root password: ?Pa55w0rd!

When using targetcli all LUNS are automatically added to all available ACLS whereas I want to add the two block devices created in Logical Volumes ( Part 1), iscsi01 and iscsi02, to 2 different machines, I have already pointed iscsi01 towards a Windows client and the second could be pointed to another client (Windows or Linux).

To do this we must change the config of targetcli to stop automatic mapping which is done from inside the service as follows

# targetcli

type cd and choose the root o- / then type

/>  set global auto_add_mapped_luns=false
Parameter auto_add_mapped_luns is now 'false'.

We can now add iscsi02 and and map the LUNS to each client initiator

/> cd
/backstores/block> create storage02 /dev/volume01/iscsi02
/> cd
/iscsi/iqn.20...name/tpg1/luns> create /backstores/block/storage02
/> cd
/iscsi/iqn.20...name/tpg1/acls> create iqn.2016-04.com.example:clienthostname01
/iscsi/iqn.20...name/tpg1/acls> create iqn.2016-04.com.example:clienthostname02
/> cd [to see progress]
o- / .....................................................................[...]
  o- backstores ..........................................................[...]
  | o- block ..............................................[Storage Objects: 2]
  | | o- storage01 .......[/dev/volume01/iscsi01 (1.4TiB) write-thru activated]
  | | o- storage02 .....[/dev/volume01/iscsi02 (800.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.2016-06.com.example:serverhostname ........................[TPGs: 1]
  |   o- tpg1 ...........................................[no-gen-acls, no-auth]
  |     o- acls ......................................................[ACLs: 2]
  |     | o- iqn.2016-04.com.example:clienthostname01 .........[Mapped LUNs: 0]
  |     | o- iqn.2016-04.com.example:clienthostname02 .........[Mapped LUNs: 0]
  |     o- luns ......................................................[LUNs: 2]
  |     | o- lun0 ....................[block/storage01 (/dev/volume01/iscsi01)]
  |     | o- lun1 ....................[block/storage02 (/dev/volume01/iscsi02)]
  |     o- portals ................................................[Portals: 1]
  |       o- x.x.x.x:3260 .................................................[OK]
  o- loopback .....................................................[Targets: 0]

As you can see neither of the ACLS has a mapped LUN. Before proceding it is important to note the numbering of the LUNS as the mapped LUNS have to allocated sequentially, as we have two LUNS numbered 0 and 1 our mapped luns will be 2 and 3, this means that LUN2 will be mapped to LUN0 and LUN3 mapped to LUN1, to do this we will navigate to clienthostname01

/iscsi/iqn.20...clienthostname01> create 2 0

now go to clienthostname02

/iscsi/iqn.20...clienthostname02> create 3 1

let's see the completed configuration

o- / .....................................................................[...]
  o- backstores ..........................................................[...]
  | o- block ..............................................[Storage Objects: 2]
  | | o- storage01 .......[/dev/volume01/iscsi01 (1.4TiB) write-thru activated]
  | | o- storage02 .....[/dev/volume01/iscsi02 (800.0GiB) write-thru activated]
  | o- fileio .............................................[Storage Objects: 0]
  | o- pscsi ..............................................[Storage Objects: 0]
  | o- ramdisk ............................................[Storage Objects: 0]
  o- iscsi ........................................................[Targets: 0]
  | o- iqn.2016-06.com.example:serverhostname ........................[TPGs: 1]
  |   o- tpg1 ...........................................[no-gen-acls, no-auth]
  |     o- acls ......................................................[ACLs: 2]
  |     | o- iqn.2016-04.com.example:clienthostname01 .........[Mapped LUNs: 1]
  |     |   o- mapped_lun2 .........................[lun0 block/storage01 (rw)]
  |     | o- iqn.2016-04.com.example:clienthostname02 .........[Mapped LUNs: 1]
  |     |   o- mapped_lun3 .........................[lun1 block/storage01 (rw)]
  |     o- luns ......................................................[LUNs: 2]
  |     | o- lun0 ....................[block/storage01 (/dev/volume01/iscsi01)]
  |     | o- lun1 ....................[block/storage02 (/dev/volume01/iscsi02)]
  |     o- portals ................................................[Portals: 1]
  |       o- x.x.x.x:3260 .................................................[OK]
  o- loopback .....................................................[Targets: 0]