Showing posts with label ISCSI. Show all posts
Showing posts with label ISCSI. Show all posts

Friday, 14 October 2016

Enabling iSCSI on Linux hosts


While autoconfiguration of iSCSI takes care of most connectivity between CDS and hosts, from time to time we need to do the procedure manually.
 
To enable iSCSI on a Linux host:
 
Make sure you have the iscsiadm package installed.
 
“# rpm –qa | grep iscsi” should show you something similar to “iscsi-initiator-utils-6.2.0.865-6.el5.x86_64.rpm”. If you see nothing, you need to get the package installed using "yum" or similar.
 
Install with
yum install iscsi-initiator-utils
 
Set iscsi services to start on boot.
 
# chkconfig iscsid on
# service iscsid start
# chkconfig iscsi on
# service iscsi start
 
Verify the services are running
 
service iscsid status
 
If it is not running, you might need to try start it up with
service iscsid force-start
 
Find the IQN of the Linux host
 
# cat /etc/iscsi/initiator.iscsiname
 
example:
 
[root@localhost ~]# cat /etc/iscsi/initiatorname.iscsi 
InitiatorName=iqn.1994-05.com.redhat:e18fec10c2c6
[root@localhost ~]# 
Discover the iscsi targets on the CDS.
 
# iscsiadm –m discovery –t st –p ip.address.of.CDS.iscsi.target
Example:
# iscsiadm -m discovery -t st -p 183.24.13.1
183.24.13.1:3260,1 iqn.1986-03.com.ibm:2145.clu5-b.clu5-b-node1
Log onto the iscsi target discovered above - Use the IQN of the target host returned from running the discovery command above.
 
# iscsiadm -m node -T iqn.from.command.above -p ip.address.of.iscsi.target -l
 
Example
iscsiadm -m node -T iqn.1986-03.com.ibm:2145.clu5-b.clu5-b-node1 -p 183.24.13.1 -l
Automatically logon at boot - Use the IQN of the target host returned from running the discovery command above.
 
# iscsiadm -m node -T iqn.from.command.above -p ip.address.of.iscsi.target  --op update –n node.startup –v automatic
 
Example
iscsiadm -m node -T iqn.1986-03.com.ibm:2145.clu5-b.clu5-b-node1 -p 183.24.13.1 --op update -n node.startup -v automatic
Scan the iscsi bus for LUNs
 
# iscsiadm -m node --rescan
 
The LUNs will now be available for mounting by Linux using standard Linux mount syntax.
  
Using the above process with Actifio protection.
 
1.    Enable iSCSI on the linux host (instructions above)
2.    Install the UDS connector on the linux host
3.    Add the linux host (Actifio UI)
4.    Discover the applications on the linux host (Actifio UI)


5.    Protect the discovered applications (Actifio UI)



On RHEL and CentOS release 6.3 (Final) iSCSI initator name is in this file:
[root@seanrhel1 ~]# cat /etc/iscsi/initiatorname.iscsi

Also on CentOS 5.8, by the way.


# iscsiadm -m session -P 3

This command is also helpful, this will tell the iSCSI devices mapped to the linux host from a specific iSCSI Target. 

How to use the command line to configure iSCSI connections



I recently had a client who tried to use iSCSI to connect Server Core to SAN storage but couldn't get it to work without the iSCSI Initiator Control Panel applet.

You can use the Iscsicli command-line interface to manage iSCSI.
The first thing you need to do is enable iSCSI service and set it to start automatically, as you’ll see in the following code and corresponding output.


The first command I entered was:

Users\kmk>sc config msiscsi start= auto


The output was:

\[SC\] ChangeServiceConfig SUCCESS


Then I entered:

Users\kmk>net start msiscsi


The output was:

The Microsoft iSCSI Initiator Service service is starting.                         
The Microsoft iSCSI Initiator Service service was started successfully. 



Then, you use the Iscsicli command-line interface to connect to an iSCSI Target and list the available targets.

The command I entered was:

Users\kmk>iscsicli QAddTargetPortal 192.168.1.31


The output was:

Microsoft iSCSI Initiator Version 6.0 Build 6000                   
The operation completed successfully.

Next I entered:

Users\kmk>iscsicli ListTargets

The output was:

Microsoft iSCSI Initiator Version 6.0 Build 6000 
Targets List:  quorum data                              
The operation completed successfully.

You can then connect to a target using the following code as an example:

Users\kmk>iscsicli qlogintarget data

The output was:

Microsoft iSCSI Initiator Version 6.0 Build 6000                               

Session Id is 0xfffffa800626e018-0x4000013700000006                              
Connection Id is 0xfffffa800626e018-0x5                              
The operation completed successfully.


The following code checked to make sure the operation was successful:

Users\kmk>iscsicli reporttargetmappings

The output was:

Microsoft iSCSI Initiator Version 6.0 Build 6000 

Total of 1 mappings returned                             

Session Id : fffffa800626e018-4000013700000006                              
Target Name : data                              
Initiator : Root\ISCSIPRT\0000_0                              
Initiator Scsi Device : \\.\Scsi4:                             
Initiator Bus : 0                             
Initiator Target Id : 0                              
Target Lun: 0x0 <--> OS Lun: 0x0 

The operation completed successfully.




You log out by using the logouttarget switch with the session ID, as the following sample code shows:

Users\kmk>iscsicli logouttarget fffffa800626e018-4000013700000006

The output was:

Microsoft iSCSI Initiator Version 6.0 Build 6000 
The operation completed successfully.
To confirm the operation was successful, 

I entered the following code:

Users\kmk>iscsicli reporttargetmappings

The output was:

Microsoft iSCSI Initiator Version 6.0 Build 6000 

No Mappings                              
The operation completed successfully.


The mappings obtained through the qlogintarget command aren’t persistent and will be lost at reboot. If you want a persistent connection, use the perssitenlogintarget switch, as the following code shows:

Users\kmk>iscsicli persistentlogintarget data T * * * * * * * * * * * * * * * 0

The output was:
Microsoft iSCSI Initiator Version 6.0 Build 6000 
The operation completed successfully.

To confirm that the operation was successful, I entered:

Users\kmk>iscsicli listpersistenttargets

The output was:

Microsoft iSCSI Initiator Version 6.0 Build 6000 

Total of 1 peristent targets                              
Target Name : data                              
Address and Socket : 192.168.1.31 3260                              
Session Type : Data                              
Initiator Name : Root\ISCSIPRT\0000_0                              
Port Number :                              
++Security Flags : 0x0                              
++Version : 0                              
++Information Specified: 0x20                              
++Login Flags : 0x8                              
++Username : 

The operation completed successfully.

Entering T * * * * * * * * * * * * * * * 0 specifies all the required switches. To remove a persistent target, apply the information obtained from the listpersistentargets command, using the following code as an example:

Users\kmk>iscsicli removepersistenttarget Root\ISCSIPRT\0000_0 data * 192.168.1.31 3260

The output was:

Microsoft iSCSI Initiator Version 6.0 Build 6000 
The operation completed successfully. 

To confirm the success of the operation, I entered:
Users\kmk>iscsicli listpersistenttargets

The output was:

Microsoft iSCSI Initiator Version 6.0 Build 6000                               
Total of 0 peristent targets                              
The operation completed successfully. 


You'll notice that I passed the initiator name first, then the target name, the port number (which is *), and last of all the iSCSI target server IP address and socket.