Search This Blog

Monday, December 28, 2015

RHEL7 - Configuring an iSCSI SAN - Part 2 - Setting the iSCSI Initiatorname

Setting the iSCSI Initiatorname

1. On server 2, open a root shell and type yum -y install iscsi-initiator-utils lsscsi to install the software that you need to perform this exercise.

[root@server1 /]# yum -y install iscsi-initiator-utils
Loaded plugins: langpacks, product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Package iscsi-initiator-utils-6.2.0.873-21.el7.x86_64 already installed and latest version
Nothing to do

2. As an iSCSI node, the client requires a unique IQN. The default /etc/iscsi/initiatorname.iscsi file contains a generated IQN using Red Hats' domain. Administrators typically reset the IQN to their own domain and a appropriate client system string.

[root@server1 /]# cat /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.2015-12.com.example:server1

After changing the iSCSI initiatorname, do not forget to restart the iscsid service by using systemctl restart iscsid !

[root@server1 /]# systemctl restart iscsid

[root@server1 /]# systemctl status iscsid -l
iscsid.service - Open-iSCSI
   Loaded: loaded (/usr/lib/systemd/system/iscsid.service; disabled)
   Active: active (running) since Mon 2015-12-28 07:03:06 CET; 21s ago
     Docs: man:iscsid(8)
           man:iscsiadm(8)
  Process: 4694 ExecStop=/sbin/iscsiadm -k 0 2 (code=exited, status=0/SUCCESS)
  Process: 4699 ExecStart=/usr/sbin/iscsid (code=exited, status=0/SUCCESS)
 Main PID: 4702 (iscsid)
   CGroup: /system.slice/iscsid.service
           +-4701 /usr/sbin/iscsid
           +-4702 /usr/sbin/iscsidDec 28 07:03:06 server1.example.com systemd[1]: Starting Open-iSCSI...
Dec 28 07:03:06 server1.example.com systemd[1]: Failed to read PID from file /var/run/iscsid.pid: Invalid argument
Dec 28 07:03:06 server1.example.com systemd[1]: Started Open-iSCSI.
Dec 28 07:03:06 server1.example.com iscsid[4701]: iSCSI daemon with pid=4702 started!

Performing the Discovery

To connect to an iSCSI SAN, you start by exploring which configuration is available. The iscsiadm command has different modes, and in discovery mode the command shows available connections
3. Type iscsiadm --mode discovery --type sendtargets --portal 192.168.122.202 --discover . This should return the name of the iSCSI target as you have configured it in the previous exercise.

[root@server1 /]# iscsiadm --mod discovery --type sendtargets --portal 192.168.122.202 --discover
192.168.122.202:3260,1 iqn.2015-12.com.example:target

4. After a successful discovery, you can request more information about the target that was discovered, using the -P option. This option can be used in any iscsiadm mode, and it will show details about the current mode. In all modes, the print levels 0 and 1 are supported. In some modes, you can go beyond that to display more additional information. Figure shows the result of the iscsiadm --mode discovery -P 1 command.

[root@server1 /]# iscsiadm --mode discovery -P 1
SENDTARGETS:
DiscoveryAddress: 192.168.122.202,3260
Target: iqn.2015-12.com.example:target
       Portal: 192.168.122.202:3260,1
              Iface Name: default
iSNS:
No targets found.
STATIC:
No targets found.
FIRMWARE:
No targets found.

Making the Connection
Based on the name that you found when performing the iSCSI discovery and assuming that you have set the initiatorname correctly, you can now log in to the iSCSI target and make the actual connection. To do this, use a command that looks like the following:
5. Next, type iscsiadm --mode node --targetname iqn.2015-12.com.example:target1 --portal 192.168.122.202:3260 --login .

[root@server1 etc]# iscsiadm --mode node --targetname iqn.2015-12.com.example:target --portal 192.168.122.202:3260 --login
Logging in to [iface: default, target: iqn.2015-12.com.example:target, portal: 192.168.122.202,3260] (multiple)
Login to [iface: default, target: iqn.2015-12.com.example:target, portal: 192.168.122.202,3260] successful.

In this command, a few options are used:
·         --mode node This specifies iscsiadm to enter “node” mode. This is the mode in which the actual connection with the target can be established.
·         --targetname This specifies the name of the target as discovered when using the iSCSI discovery process.
·         --portal This is the IP address and port on which the target is listening.
·         --login This authenticates to the target and will store credentials as well to ensure that on reboot the connection can be reestablished again.

Making iSCSI Connections Persistent

After logging in to an iSCSI target server, the connections are persistent automatically. That means that on reboot, the iscsid and iscsi services are started on the iSCSI client, and these services will read the iSCSI configuration that is locally stored to automatically reconnect. Therefore, there is no need to put anything in configuration files if you have successfully connected once to the iSCSI server.

If you need an iSCSI connection not to be restored after reboot, you first have to log out to disconnect the actual session by using iscsiadm --mode node --targetname iqn.2014-11.com.example:target1 --logout .
Next you need to delete the corresponding IQN subdirectory and all of its contents. You can do this with the rm command or by using iscsiadm --mode node --targetname iqn.2014-11.com.example:target1 --op=delete . This ensures that all configuration is wiped and that you can make a clean restart.

Mounting iSCSI Devices
6. The iSCSI devices should now be available. Type lsscsi to show them. You should see three LIO devices. Use iscsiadm -m session -P3 , which also shows all disks.

[root@server1 etc]# yum -y install lsscsi
Loaded plugins: langpacks, product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Package lsscsi-0.27-3.el7.x86_64 already installed and latest version

[root@server1 etc]# lsscsi
[1:0:0:0]    cd/dvd  NECVMWar VMware SATA CD01 1.00  /dev/sr0
[30:0:0:0]   disk    VMware,  VMware Virtual S 1.0   /dev/sda
[33:0:0:0]   disk    LIO-ORG  block1           4.0   /dev/sdb
[33:0:0:1]   disk    LIO-ORG  block2           4.0   /dev/sdc
[33:0:0:2]   disk    LIO-ORG  file1            4.0   /dev/sdd

[root@server1 etc]# iscsiadm -m session -P3
iSCSI Transport Class version 2.0-870
version 6.2.0.873-21
Target: iqn.2015-12.com.example:target (non-flash)
       Current Portal: 192.168.122.202:3260,1
       Persistent Portal: 192.168.122.202:3260,1
              **********
              Interface:
              **********
              Iface Name: default
              Iface Transport: tcp
              Iface Initiatorname: iqn.2015-12.com.example:server1
              Iface IPaddress: 192.168.122.201
              Iface HWaddress: <empty>
              Iface Netdev: <empty>
              SID: 1
              iSCSI Connection State: LOGGED IN
              iSCSI Session State: LOGGED_IN
              Internal iscsid Session State: NO CHANGE
              *********
              Timeouts:
              *********
              Recovery Timeout: 120
              Target Reset Timeout: 30
              LUN Reset Timeout: 30
              Abort Timeout: 15
              *****
              CHAP:
              *****
              username: <empty>
              password: ********
              username_in: <empty>
              password_in: ********
              ************************
              Negotiated iSCSI params:
              ************************
              HeaderDigest: None
              DataDigest: None
              MaxRecvDataSegmentLength: 262144
              MaxXmitDataSegmentLength: 262144
              FirstBurstLength: 65536
              MaxBurstLength: 262144
              ImmediateData: Yes
              InitialR2T: Yes
              MaxOutstandingR2T: 1
              ************************
              Attached SCSI devices:
              ************************
              Host Number: 33       State: running
              scsi33 Channel 00 Id 0 Lun: 0
                      Attached scsi disk sdb              State: running
              scsi33 Channel 00 Id 0 Lun: 1
                      Attached scsi disk sdc              State: running
              scsi33 Channel 00 Id 0 Lun: 2
                      Attached scsi disk sdd              State: running
[root@server1 etc]#


7. On the first iSCSI device (I’ll assume that it is /dev/sdb in this exercise, but it can be a different device on your server depending on the configuration that is used), type mkfs.xfs /dev/sdb .

[root@server1 etc]# cat /proc/partitions
major minor  #blocks  name
­  11        0    3655680 sr0
   8        0   20971520 sda
   8        1    1048576 sda1
   8        2   10485760 sda2
   8       16     204800 sdb
   8       32     204800 sdc
   8       48     102400 sdd

[root@server1 etc]# mkfs.xfs /dev/sdb
meta-data=/dev/sdb               isize=256    agcount=8, agsize=6400 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0
data     =                       bsize=4096   blocks=51200, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
log      =internal log           bsize=4096   blocks=853, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

8. Use blkid /dev/sdb to get the UUID that is set for the XFS file system that you have just created on /dev/sdb.

[root@server1 etc]# blkid /dev/sdb
/dev/sdb: UUID="48c4fa99-4bd6-4f06-a5fa-8a6b86d8a2d5" TYPE="xfs"

9. Create a mount point for the iSCSI disk, using mkdir /mnt/iscsi .

[root@server1 etc]# mkdir /mnt/iscsi

10. Type vim /etc/fstab to open the /etc/fstab file in an editor and add a line that looks like the following. (Make sure to replace the UUID with the UUID you have found in Step 6 of this exercise.)
UUID=XXXXXXXX-XXXX-XXXX-XXXXXX /mnt/iscsi xfs _netdev 0 2

[root@server1 etc]# grep -i iscsi /etc/fstab
UUID=48c4fa99-4bd6-4f06-a5fa-8a6b86d8a2d5 /mnt/iscsi xfs _netdev 0 2

9. Type mount -a . This should mount the iSCSI disk. Type mount without any arguments to verify.

[root@server1 /]# mount -a

[root@server1 /]# mount|grep iscsi
/dev/sdb on /mnt/iscsi type xfs (rw,relatime,seclabel,attr2,inode64,noquota,_netdev)

TIP If you want to make it easy to create an iSCSI configuration, study man 8 iscsiadm . It contains some great examples that help you go through the basic steps of configuring an iSCSI connection. Do realize, though, that on the RHCE exam, you need to expect the unexpected, and you might have to perform some tasks that

Thank you for reading.
For Reading other article, visit to “https://sites.google.com/site/unixwikis/

RHEL7 - Configuring an iSCSI SAN - Part 1 - Setting Up the iSCSI Target

Configuring an iSCSI SAN

Setting Up the iSCSI Target

In this exercise, you set up an iSCSI target on server1. This exercise assumes that on server1 that you have an LVM volume group available with the name vgsan. Within the volume group, you need free disk space that allows you to create two LVM logical volumes.

1.    Open a root shell on server1. Type vgs to verify the name of the LVM volume group and the amount of available disk space. If you do not have a volume group with available disk space, you should create a volume group first.

[root@ipa ~]# cat /proc/partitions
major minor  #blocks  name
   8        0   20971520 sda
   8        1     512000 sda1
   8        2   20458496 sda2
   8       16    5242880 sdb
  11        0    3655680 sr0
 253        0   18358272 dm-0
 253        1    2097152 dm-1

[root@ipa ~]# vgcreate vgsan /dev/sdb
  Physical volume "/dev/sdb" successfully created
  Volume group "vgsan" successfully created

[root@ipa ~]# pvs
  PV         VG              Fmt  Attr PSize  PFree
  /dev/sda2  rhel_rhelserver lvm2 a--  19.51g    0
  /dev/sdb   vgsan           lvm2 a--   5.00g 5.00g

[root@ipa ~]# vgs
  VG              #PV #LV #SN Attr   VSize  VFree
  rhel_rhelserver   1   2   0 wz--n- 19.51g    0
  vgsan             1   0   0 wz--n-  5.00g 5.00g

2.    Type lvcreate -L 200M -n lvsan1 /dev/vgsan and lvcreate -L 200M -n lvsan2 /dev/vgsan to provide the backing storage needed for setting up your iSCSI target.
[root@ipa ~]# lvcreate -L 200M -n lvsan1 /dev/vgsan
  Logical volume "lvsan1" created
[root@ipa ~]# lvcreate -L 200M -n lvsan2 /dev/vgsan
  Logical volume "lvsan2" created
[root@ipa ~]# lvs
  LV     VG              Attr       LSize   Pool Origin Data%  Move Log Cpy%Sync Convert
  root   rhel_rhelserver -wi-ao----  17.51g                                            
  swap   rhel_rhelserver -wi-ao----   2.00g                                            
  lvsan1 vgsan           -wi-a----- 200.00m                                           
  lvsan2 vgsan           -wi-a----- 200.00m 

3. Enter yum -y install targetcli .
[root@ipa ~]# yum -y install targetcli
Loaded plugins: langpacks, product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Resolving Dependencies
--> Running transaction check
---> Package targetcli.noarch 0:2.1.fb34-1.el7 will be installed
--> Processing Dependency: python-rtslib >= 2.1.fb41 for package: targetcli-2.1.fb34-1.el7.noarch
--> Processing Dependency: python-configshell for package: targetcli-2.1.fb34-1.el7.noarch
--> Running transaction check
---> Package python-configshell.noarch 1:1.1.fb11-3.el7 will be installed
--> Processing Dependency: python-urwid for package: 1:python-configshell-1.1.fb11-3.el7.noarch
--> Processing Dependency: pyparsing for package: 1:python-configshell-1.1.fb11-3.el7.noarch
---> Package python-rtslib.noarch 0:2.1.fb46-1.el7 will be installed
--> Processing Dependency: python-kmod for package: python-rtslib-2.1.fb46-1.el7.noarch
--> Running transaction check
---> Package pyparsing.noarch 0:1.5.6-9.el7 will be installed
---> Package python-kmod.x86_64 0:0.9-4.el7 will be installed
---> Package python-urwid.x86_64 0:1.1.1-3.el7 will be installed
--> Finished Dependency ResolutionDependencies Resolved
=========================================================================================================================================================================================
 Package                                            Arch                                   Version                                          Repository                              Size
=========================================================================================================================================================================================
Installing:
 targetcli                                          noarch                                 2.1.fb34-1.el7                                   myrepo                                  55 k
Installing for dependencies:
 pyparsing                                          noarch                                 1.5.6-9.el7                                      myrepo                                  94 k
 python-configshell                                 noarch                                 1:1.1.fb11-3.el7                                 myrepo                                  64 k
 python-kmod                                        x86_64                                 0.9-4.el7                                        myrepo                                  57 k
 python-rtslib                                      noarch                                 2.1.fb46-1.el7                                   myrepo                                  75 k
 python-urwid                                       x86_64                                 1.1.1-3.el7                                      myrepo                                 654 k
Transaction Summary
=========================================================================================================================================================================================
Install  1 Package (+5 Dependent packages)Total download size: 998 k
Installed size: 3.9 M
Downloading packages:
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                    3.7 MB/s | 998 kB  00:00:00    
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : python-kmod-0.9-4.el7.x86_64                                                                                                                                          1/6
  Installing : python-rtslib-2.1.fb46-1.el7.noarch                                                                                                                                   2/6
  Installing : pyparsing-1.5.6-9.el7.noarch                                                                                                                                          3/6
  Installing : python-urwid-1.1.1-3.el7.x86_64                                                                                                                                       4/6
  Installing : 1:python-configshell-1.1.fb11-3.el7.noarch                                                                                                                            5/6
  Installing : targetcli-2.1.fb34-1.el7.noarch                                                                                                                                       6/6
  Verifying  : python-rtslib-2.1.fb46-1.el7.noarch                                                                                                                                   1/6
  Verifying  : python-urwid-1.1.1-3.el7.x86_64                                                                                                                                       2/6
  Verifying  : targetcli-2.1.fb34-1.el7.noarch                                                                                                                                       3/6
  Verifying  : 1:python-configshell-1.1.fb11-3.el7.noarch                                                                                                                            4/6
  Verifying  : pyparsing-1.5.6-9.el7.noarch                                                                                                                                          5/6
  Verifying  : python-kmod-0.9-4.el7.x86_64                                                                                                                                          6/6 Installed:
  targetcli.noarch 0:2.1.fb34-1.el7                                                                                                                                                    
Dependency Installed:
  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  python-urwid.x86_64 0:1.1.1-3.el7
Complete!
[root@ipa ~]#


3.    Type targetcli . This opens the targetcli interface, which looks like a shell prompt. Type ls to show the default interface (see Figure below )
[root@ipa ~]# 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]
/>

5. The first step in setting up an iSCSI target is configuring the backstore. Type cd /backstores to enter the backstores branch of targetcli, which allows you to specify which backing storage is going to be used.

6. Type block/ create block1 /dev/vgsan/lvsan1. This assigns the LVM logical volume that you have created earlier as the backstore in the iSCSI target.
Repeat for lvsan2 by typing block/ create block2 /dev/vgsan/lvsan2 . Notice the way the command works; it starts with block/ , which brings you to the contents of the directory /block, and from there the create commands are issued.
Also notice that despite the fact that you are using the create command, it does not really create the backing storage device; it assigns an already existing storage device as the backing storage.
/> cd backstores/
/backstores> block/ create block1 /dev/vgsan/lvsan1
Created block storage object block1 using /dev/vgsan/lvsan1.
/backstores> block/ create block2 /dev/vgsan/lvsan2
Created block storage object block2 using /dev/vgsan/lvsan2.

7. Now let’s create a file-backed block device as well: fileio/ create file1 /root/diskfile1 100M . This command creates a sparse file with a size of 100 MiB and assigns it as a backing storage device.

/backstores> fileio/ create file1 /root/diskfile1 100M
Created fileio file1 with size 104857600

8. At this time, type ls to get an overview of the current configuration. It should look like Figure 26.3 and show you two block devices and one file-backed storage device.

/backstores> ls
o- backstores ................................................................................................................ [...]
  o- block .................................................................................................... [Storage Objects: 2]
  | o- block1 ................................................................ [/dev/vgsan/lvsan1 (200.0MiB) write-thru deactivated]
  | o- block2 ................................................................ [/dev/vgsan/lvsan2 (200.0MiB) write-thru deactivated]
  o- fileio ................................................................................................... [Storage Objects: 1]
  | o- file1 ................................................................... [/root/diskfile1 (100.0MiB) write-back deactivated]
  o- pscsi .................................................................................................... [Storage Objects: 0]
  o- ramdisk .................................................................................................. [Storage Objects: 0]
/backstores>

9. Now that the block backstores are taken care of, you can start configuring the unique identifier for your iSCSI target, the iSCSI IQN, which will also create the default TGP. To start, use cd /iscsi/ to get to the iscsi branch of the configuration.
/backstores> cd /
/> cd iscsi
/iscsi> ls
o- iscsi .............................................................................................................. [Targets: 0]
/iscsi>

10. Now type create iqn.2015-04.com.example:target to create the IQN. Notice that the name of the IQN starts with year-month (in YY-MM notation) and is followed by the inversed DNS domain name. Make sure you respect this naming standard; otherwise, the IQN will not be created.
/iscsi> create iqn.2015-12.com.example:target
Created target iqn.2015-12.com.example:target.
Created TPG 1.

TIP Notice that the IQN naming standard is very strict. If you specify the month as one digit instead of two, for instance, you’ll get a “WWN not valid” message,and creation will fail!

11. Type ls . This shows the contents of the iscsi branch, where you now see the IQN you just created, as well as the TPG tpg1 that was created automatically while creating the IQN (see Figure ).

/iscsi> ls
o- iscsi .............................................................................................................. [Targets: 1]
  o- iqn.2015-12.com.example:target ...................................................................................... [TPGs: 1]
    o- tpg1 ................................................................................................. [no-gen-acls, no-auth]
      o- acls ............................................................................................................ [ACLs: 0]
      o- luns ............................................................................................................ [LUNs: 0]
      o- portals ...................................................................................................... [Portals: 0]
/iscsi>

12. At this point, you can create an ACL in the TPG. Remember, you need to create ACLs as well to access the iSCSI target, because without ACLs, any iSCSI initiator will be denied access. Any new LUN that you create will be mapped to each ACL that is associated with the TPG. This is because of the auto_add_mapped_luns feature, which is on by default. To create the ACL, first enter the IQN that you just created. Type cd iqn.[Tab] to enter the IQN. Notice that in the cd command, you are using the Tab key for command-line completion.
/iscsi> cd iqn.2015-12.com.example:target/
/iscsi/iqn.20...xample:target> ls
o- iqn.2015-12.com.example:target ........................................................................................ [TPGs: 1]
  o- tpg1 ................................................................................................... [no-gen-acls, no-auth]
    o- acls .............................................................................................................. [ACLs: 0]
    o- luns .............................................................................................................. [LUNs: 0]
    o- portals ........................................................................................................ [Portals: 0]
/iscsi/iqn.20...xample:target>

13. Now type tpg1/acls/ create iqn.2015-04.com.example:server1 , which creates a node ACL that allows server1 to access the IQN you just created. In this command, the initiatorname as used in /etc/iscsi/initiatorname.iscsi on the iSCSI initiator server is used. After completing this procedure, make sure that the contents of this file on the iSCSI initiatorname matches. (See also the section “Setting the Initiatorname” later in this chapter for more details.) If so required, repeat this command for all other iSCSI initiators that need access to this iSCSI target.
/iscsi/iqn.20...xample:target> cd tpg1/
/iscsi/iqn.20...e:target/tpg1> acls/ create iqn.2015-12.com.example:server1
Created Node ACL for iqn.2015-12.com.example:server1

14. Now that you have created the ACL, you need to create the LUNs. The LUNs are needed to associate a block device with a specific TPG. To do this, type the following commands:
tpg1/luns/ create /backstores/block/block1
tpg1/luns/ create /backstores/block/block2
tpg1/luns/ create /backstores/fileio/file1

/iscsi/iqn.20...e:target/tpg1> luns/ create /backstores/block/block1
Created LUN 0.
Created LUN 0->0 mapping in node ACL iqn.2015-12.com.example:server1
/iscsi/iqn.20...e:target/tpg1> luns/ create /backstores/block/block2
Created LUN 1.
Created LUN 1->1 mapping in node ACL iqn.2015-12.com.example:server1
/iscsi/iqn.20...e:target/tpg1> luns/ create /backstores/fileio/file1
Created LUN 2.
Created LUN 2->2 mapping in node ACL iqn.2015-12.com.example:server1
/iscsi/iqn.20...e:target/tpg1>

TIP While creating LUNs, you can specify additional parameters. For instance, from the tpg1/luns/ context, type create lun=10 storage_object=/backstores/block/block1 to assign the LUN number 10 to the backing storage device that is specified.

15. Type ls to verify what you have created so far. The result should look like below
/iscsi/iqn.20...e:target/tpg1> ls
o- tpg1 ..................................................................................................... [no-gen-acls, no-auth]
  o- acls ................................................................................................................ [ACLs: 1]
  | o- iqn.2015-12.com.example:server1 ............................................................................ [Mapped LUNs: 3]
  |   o- mapped_lun0 ...................................................................................... [lun0 block/block1 (rw)]
  |   o- mapped_lun1 ...................................................................................... [lun1 block/block2 (rw)]
  |   o- mapped_lun2 ...................................................................................... [lun2 fileio/file1 (rw)]
  o- luns ................................................................................................................ [LUNs: 3]
  | o- lun0 ..................................................................................... [block/block1 (/dev/vgsan/lvsan1)]
  | o- lun1 ..................................................................................... [block/block2 (/dev/vgsan/lvsan2)]
  | o- lun2 ....................................................................................... [fileio/file1 (/root/diskfile1)]
  o- portals .......................................................................................................... [Portals: 0]
/iscsi/iqn.20...e:target/tpg1>

16. At this point, you can create the portal. This connects the iSCSI configuration to the specific IP address on the iSCSI target server. To make this work, you need to ensure that the iSCSI target is on a fixed IP address. If that IP address is 192.168.4.210, the command to use is tpg1/portals/ create 192.168.4.210 .
Notice that this step is required only if you want to have the iSCSI target offering its services on only a specific IP address. If you do not create a portal, a default portal is used that binds to the IP address 0.0.0.0, which represents all IP addresses on your server.

/iscsi/iqn.20...e:target/tpg1> portals/ create 192.168.122.202
Using default IP port 3260
Created network portal 192.168.122.202:3260.

17. The configuration has now completed. Get back to the root of the configuration tree by using cd / and type ls to get a complete overview of the configuration.
It should look like Figure. You can now type exit to close the configuration interface. This automatically writes the configuration file.
/iscsi/iqn.20...e:target/tpg1> ls
o- tpg1 ..................................................................................................... [no-gen-acls, no-auth]
  o- acls ................................................................................................................ [ACLs: 1]
  | o- iqn.2015-12.com.example:server1 ............................................................................ [Mapped LUNs: 3]
  |   o- mapped_lun0 ...................................................................................... [lun0 block/block1 (rw)]
  |   o- mapped_lun1 ...................................................................................... [lun1 block/block2 (rw)]
  |   o- mapped_lun2 ...................................................................................... [lun2 fileio/file1 (rw)]
  o- luns ................................................................................................................ [LUNs: 3]
  | o- lun0 ..................................................................................... [block/block1 (/dev/vgsan/lvsan1)]
  | o- lun1 ..................................................................................... [block/block2 (/dev/vgsan/lvsan2)]
  | o- lun2 ....................................................................................... [fileio/file1 (/root/diskfile1)]
  o- portals .......................................................................................................... [Portals: 1]
    o- 192.168.122.202:3260 ................................................................................................... [OK]
/iscsi/iqn.20...e:target/tpg1>

/iscsi/iqn.20...e:target/tpg1> exit
Global pref auto_save_on_exit=true
Last 10 configs saved in /etc/target/backup.
Configuration saved to /etc/target/saveconfig.json
[root@ipa ~]#

At this point, the iSCSI target configuration is written, but the target is not yet operational. The configuration is written to the file /etc/target/saveconfig.json.
This is a file in the Java JSON format and is not really meant to be edited directly.
While you are saving the configuration, the iSCSI target service is also started automatically and listening on port 3260 of the specified portal IP address.  Below shows partial contents of the JSON file.

[root@ipa target]# cat saveconfig.json
{
  "fabric_modules": [],
  "storage_objects": [
    {
      "attributes": {
        "block_size": 512,
        "emulate_dpo": 0,
        "emulate_fua_read": 0,
        "emulate_fua_write": 1,
        "emulate_model_alias": 1,
        "emulate_rest_reord": 0,
        "emulate_tas": 1,
        "emulate_tpu": 0,
        "emulate_tpws": 0,
        "emulate_ua_intlck_ctrl": 0,
        "emulate_write_cache": 1,
        "enforce_pr_isids": 1,
        "fabric_max_sectors": 8192,
        "is_nonrot": 0,
        "max_unmap_block_desc_count": 1,
        "max_unmap_lba_count": 8192,
        "max_write_same_len": 4096,
        "optimal_sectors": 8192,
        "queue_depth": 128,
        "unmap_granularity": 1,
        "unmap_granularity_alignment": 0
      },
      "dev": "/root/diskfile1",
      "name": "file1",
      "plugin": "fileio",
      "size": 104857600,
      "write_back": true,
      "wwn": "ae31590d-dd09-4ecb-9e49-ca20bf159c34"
    },
    {
      "attributes": {
        "block_size": 512,
        "emulate_dpo": 0,
        "emulate_fua_read": 0,
        "emulate_fua_write": 1,
        "emulate_model_alias": 1,
        "emulate_rest_reord": 0,
        "emulate_tas": 1,
        "emulate_tpu": 0,
        "emulate_tpws": 0,
        "emulate_ua_intlck_ctrl": 0,
        "emulate_write_cache": 0,
        "enforce_pr_isids": 1,
        "fabric_max_sectors": 8192,
        "is_nonrot": 0,
        "max_unmap_block_desc_count": 0,
        "max_unmap_lba_count": 0,
        "max_write_same_len": 65535,
        "optimal_sectors": 8192,
        "queue_depth": 128,
        "unmap_granularity": 0,
        "unmap_granularity_alignment": 0
      },
      "dev": "/dev/vgsan/lvsan2",
      "name": "block2",
      "plugin": "block",
      "readonly": false,
      "write_back": false,
      "wwn": "04910112-b6b8-4ae9-a8a3-b676d44d2036"
    },
    {
      "attributes": {
        "block_size": 512,
        "emulate_dpo": 0,
        "emulate_fua_read": 0,
        "emulate_fua_write": 1,
        "emulate_model_alias": 1,
        "emulate_rest_reord": 0,
        "emulate_tas": 1,
        "emulate_tpu": 0,
        "emulate_tpws": 0,
        "emulate_ua_intlck_ctrl": 0,
        "emulate_write_cache": 0,
        "enforce_pr_isids": 1,
        "fabric_max_sectors": 8192,
        "is_nonrot": 0,
        "max_unmap_block_desc_count": 0,
        "max_unmap_lba_count": 0,
        "max_write_same_len": 65535,
        "optimal_sectors": 8192,
        "queue_depth": 128,
        "unmap_granularity": 0,
        "unmap_granularity_alignment": 0
      },
      "dev": "/dev/vgsan/lvsan1",
      "name": "block1",
      "plugin": "block",
      "readonly": false,
      "write_back": false,
      "wwn": "c1646d01-c82d-46b6-bd37-304584882d02"
    }
  ],
  "targets": [
    {
      "fabric": "iscsi",
      "tpgs": [
        {
          "attributes": {
            "authentication": 0,
            "cache_dynamic_acls": 0,
            "default_cmdsn_depth": 16,
            "demo_mode_write_protect": 1,
            "generate_node_acls": 0,
            "login_timeout": 15,
            "netif_timeout": 2,
            "prod_mode_write_protect": 0
          },
          "enable": true,
          "luns": [
            {
              "index": 2,
              "storage_object": "/backstores/fileio/file1"
            },
            {
              "index": 1,
              "storage_object": "/backstores/block/block2"
            },
            {
              "index": 0,
              "storage_object": "/backstores/block/block1"
            }
          ],
          "node_acls": [
            {
              "attributes": {
                "dataout_timeout": 3,
                "dataout_timeout_retries": 5,
                "default_erl": 0,
                "nopin_response_timeout": 30,
                "nopin_timeout": 15,
                "random_datain_pdu_offsets": 0,
                "random_datain_seq_offsets": 0,
                "random_r2t_offsets": 0
              },
              "mapped_luns": [
                {
                  "index": 2,
                  "tpg_lun": 2,
                  "write_protect": false
                },
                {
                  "index": 1,
                  "tpg_lun": 1,
                  "write_protect": false
                },
                {
                  "index": 0,
                  "tpg_lun": 0,
                  "write_protect": false
                }
              ],
              "node_wwn": "iqn.2015-12.com.example:server1"
            }
          ],
          "parameters": {
            "AuthMethod": "CHAP,None",
            "DataDigest": "CRC32C,None",
            "DataPDUInOrder": "Yes",
            "DataSequenceInOrder": "Yes",
            "DefaultTime2Retain": "20",
            "DefaultTime2Wait": "2",
            "ErrorRecoveryLevel": "0",
            "FirstBurstLength": "65536",
            "HeaderDigest": "CRC32C,None",
            "IFMarkInt": "2048~65535",
            "IFMarker": "No",
            "ImmediateData": "Yes",
            "InitialR2T": "Yes",
            "MaxBurstLength": "262144",
            "MaxConnections": "1",
            "MaxOutstandingR2T": "1",
            "MaxRecvDataSegmentLength": "8192",
            "MaxXmitDataSegmentLength": "262144",
            "OFMarkInt": "2048~65535",
            "OFMarker": "No",
            "TargetAlias": "LIO Target"
          },
          "portals": [
            {
              "ip_address": "192.168.122.202",
              "iser": false,
              "port": 3260
            }
          ],
          "tag": 1
        }
      ],
      "wwn": "iqn.2015-12.com.example:target"
    }
  ]
}
[root@ipa target]# cat /etc/target/saveconfig.json
{
  "fabric_modules": [],
  "storage_objects": [
    {
      "attributes": {
        "block_size": 512,
        "emulate_dpo": 0,
        "emulate_fua_read": 0,
        "emulate_fua_write": 1,
        "emulate_model_alias": 1,
        "emulate_rest_reord": 0,
        "emulate_tas": 1,
        "emulate_tpu": 0,
        "emulate_tpws": 0,
        "emulate_ua_intlck_ctrl": 0,
        "emulate_write_cache": 1,
        "enforce_pr_isids": 1,
        "fabric_max_sectors": 8192,
        "is_nonrot": 0,
        "max_unmap_block_desc_count": 1,
        "max_unmap_lba_count": 8192,
        "max_write_same_len": 4096,
        "optimal_sectors": 8192,
        "queue_depth": 128,
        "unmap_granularity": 1,
        "unmap_granularity_alignment": 0
      },
      "dev": "/root/diskfile1",
      "name": "file1",
      "plugin": "fileio",
      "size": 104857600,
      "write_back": true,
      "wwn": "ae31590d-dd09-4ecb-9e49-ca20bf159c34"
    },
    {
      "attributes": {
        "block_size": 512,
        "emulate_dpo": 0,
        "emulate_fua_read": 0,
        "emulate_fua_write": 1,
        "emulate_model_alias": 1,
        "emulate_rest_reord": 0,
        "emulate_tas": 1,
        "emulate_tpu": 0,
        "emulate_tpws": 0,
        "emulate_ua_intlck_ctrl": 0,
        "emulate_write_cache": 0,
        "enforce_pr_isids": 1,
        "fabric_max_sectors": 8192,
        "is_nonrot": 0,
        "max_unmap_block_desc_count": 0,
        "max_unmap_lba_count": 0,
        "max_write_same_len": 65535,
        "optimal_sectors": 8192,
        "queue_depth": 128,
        "unmap_granularity": 0,
        "unmap_granularity_alignment": 0
      },
      "dev": "/dev/vgsan/lvsan2",
      "name": "block2",
      "plugin": "block",
      "readonly": false,
      "write_back": false,
      "wwn": "04910112-b6b8-4ae9-a8a3-b676d44d2036"
    },
    {
      "attributes": {
        "block_size": 512,
        "emulate_dpo": 0,
        "emulate_fua_read": 0,
        "emulate_fua_write": 1,
        "emulate_model_alias": 1,
        "emulate_rest_reord": 0,
        "emulate_tas": 1,
        "emulate_tpu": 0,
        "emulate_tpws": 0,
        "emulate_ua_intlck_ctrl": 0,
        "emulate_write_cache": 0,
        "enforce_pr_isids": 1,
        "fabric_max_sectors": 8192,
        "is_nonrot": 0,
        "max_unmap_block_desc_count": 0,
        "max_unmap_lba_count": 0,
        "max_write_same_len": 65535,
        "optimal_sectors": 8192,
        "queue_depth": 128,
        "unmap_granularity": 0,
        "unmap_granularity_alignment": 0
      },
      "dev": "/dev/vgsan/lvsan1",
      "name": "block1",
      "plugin": "block",
      "readonly": false,
      "write_back": false,
      "wwn": "c1646d01-c82d-46b6-bd37-304584882d02"
    }
  ],
  "targets": [
    {
      "fabric": "iscsi",
      "tpgs": [
        {
          "attributes": {
            "authentication": 0,
            "cache_dynamic_acls": 0,
            "default_cmdsn_depth": 16,
            "demo_mode_write_protect": 1,
            "generate_node_acls": 0,
            "login_timeout": 15,
            "netif_timeout": 2,
            "prod_mode_write_protect": 0
          },
          "enable": true,
          "luns": [
            {
              "index": 2,
              "storage_object": "/backstores/fileio/file1"
            },
            {
              "index": 1,
              "storage_object": "/backstores/block/block2"
            },
            {
              "index": 0,
              "storage_object": "/backstores/block/block1"
            }
          ],
          "node_acls": [
            {
              "attributes": {
                "dataout_timeout": 3,
                "dataout_timeout_retries": 5,
                "default_erl": 0,
                "nopin_response_timeout": 30,
                "nopin_timeout": 15,
                "random_datain_pdu_offsets": 0,
                "random_datain_seq_offsets": 0,
                "random_r2t_offsets": 0
              },
              "mapped_luns": [
                {
                  "index": 2,
                  "tpg_lun": 2,
                  "write_protect": false
                },
                {
                  "index": 1,
                  "tpg_lun": 1,
                  "write_protect": false
                },
                {
                  "index": 0,
                  "tpg_lun": 0,
                  "write_protect": false
                }
              ],
              "node_wwn": "iqn.2015-12.com.example:server1"
            }
          ],
          "parameters": {
            "AuthMethod": "CHAP,None",
            "DataDigest": "CRC32C,None",
            "DataPDUInOrder": "Yes",
            "DataSequenceInOrder": "Yes",
            "DefaultTime2Retain": "20",
            "DefaultTime2Wait": "2",
            "ErrorRecoveryLevel": "0",
            "FirstBurstLength": "65536",
            "HeaderDigest": "CRC32C,None",
            "IFMarkInt": "2048~65535",
            "IFMarker": "No",
            "ImmediateData": "Yes",
            "InitialR2T": "Yes",
            "MaxBurstLength": "262144",
            "MaxConnections": "1",
            "MaxOutstandingR2T": "1",
            "MaxRecvDataSegmentLength": "8192",
            "MaxXmitDataSegmentLength": "262144",
            "OFMarkInt": "2048~65535",
            "OFMarker": "No",
            "TargetAlias": "LIO Target"
          },
          "portals": [
            {
              "ip_address": "192.168.122.202",
              "iser": false,
              "port": 3260
            }
          ],
          "tag": 1
        }
      ],
      "wwn": "iqn.2015-12.com.example:target"
    }
  ]
}
[root@ipa target]#

TIP As you have noticed, the procedure to configure an iSCSI target is a long procedure that involves many steps. You might be wondering how to memorize all of these steps for the exam. The secret is that you should not try to memorize all the individual steps. Instead, you want to see the global overview of what you have been doing. You started by creating the backstores that provide the storage that the iSCSI target is sharing. Next you created an IQN, which automatically created the TPG also. The third step was to create ACLs to allow nodes to access the target, following which you created the LUNs. While you were creating the LUNs, ACLs were assigned automatically. The last step was to configure the portal and write the configuration. There is not much to memorize here, because if you type ls in the targetcli interface, all of these steps are listed in the order that you should execute them.

TIP You can also study the man page of the targetcli command to get some help on the iSCSI configuration on the exam. Notice, however, that the QuickStart in this man page does not use authentication, so no ACLs are created here. So if you want to use this man page on the exam, make sure to study it well so that you know which information is available and which is not available through this man page.

Finalizing the iSCSI Target Configuration
1. On server1, type systemctl start target followed by systemctl enable target.
[root@ipa target]# systemctl start target

2. Type systemctl status target and verify that the target currently is active and that the status is set to enabled.
[root@ipa target]# systemctl status target
target.service - Restore LIO kernel target configuration
   Loaded: loaded (/usr/lib/systemd/system/target.service; disabled)
   Active: active (exited) since Mon 2015-12-28 11:12:19 IST; 12s ago
  Process: 5259 ExecStart=/usr/bin/targetctl restore (code=exited, status=0/SUCCESS)
 Main PID: 5259 (code=exited, status=0/SUCCESS)Dec 28 11:12:19 ipa.example.com systemd[1]: Starting Restore LIO kernel target configuration...
Dec 28 11:12:19 ipa.example.com systemd[1]: Started Restore LIO kernel target configuration.
[root@ipa target]#

3. Open the firewall, using firewall-cmd --add-port=3260/tcp --permanent , followed by firewall-cmd --reload .
[root@ipa target]# firewall-cmd --add-port=3260/tcp --permanent
success
[root@ipa target]# firewall-cmd --reload
success
4.  
         4. Type firewall-cmd --list-all to verify the firewall configuration. The results should look like below .
[root@ipa target]# firewall-cmd --list-all
public (default, active)
  interfaces: eno16777736
  sources:
  services: dhcpv6-client dns ftp http https kerberos kpasswd ldap ntp ssh
  ports: 514/tcp 3260/tcp
  masquerade: no
  forward-ports:
  icmp-blocks:
  rich rules:

Thank you for reading.
For Reading other article, visit to “https://sites.google.com/site/unixwikis/