Difference between revisions of "Set up an iscsi storage"

From LinuxIntro
Jump to: navigation, search
(SUSE Linux Enterprise server 10)
(Set up an initiator)
 
(6 intermediate revisions by one user not shown)
Line 3: Line 3:
 
= QuickStart =
 
= QuickStart =
  
I do have a walk around for this pblroem. i have tested it on the windows 2003 server and found to be working.Below is the steps for the walk around.1)Create a Connect_SAN.bat with following commands and put it in c:\-Diskpart /s “c:\Connect_SAN.txt”-Save file2)Create a Connect_SAN.txt with following commands and put it in c:\-Select Disk N (replace N with the disk number which is offline. You can check this in logical Disk Management)-Online-Exit-Save file3)Open the Group Policy Editor (Start > Run > enter  gpedit.msc'.)4)Expand  Computer Configuration'.5)Expand  Windows Settings'.6)Select Scripts (Startup/Shutdown)'.7)Double-click on  Startup' in right-hand panel.  Click on the  Add' button.9)Click on the  Browse' button.10)Navigate to your batch file(Connect_SAN.bat), select it and OK your way out of the Editor.11)Close the Editor.12) Reboot System
+
== SUSE Linux Enterprise server 10 ==
 +
 
 +
In this chapter, we will set up an ISCSI target and connect to it
 +
 
 +
=== Check your state ===
 +
 
 +
See how many block devices you have attached:
 +
[[hwinfo]] --block --short
 +
 
 +
=== Set up a target ===
 +
 
 +
* start [[yast2]]
 +
* chose Miscellaneous->iSCSI target
 +
* continue as instructed, if prompted, allow to [[install]] the [[package]] iscsitarget
 +
 
 +
=== Set up an initiator ===
 +
 
 +
* start [[yast2]]
 +
* chose Miscellaneous->iSCSI initiator
 +
* continue as instructed, if prompted, allow to [[install]] the [[package]] openiscsi
 +
 
 +
=== Check if it worked ===
 +
 
 +
See how many block devices you have attached:
 +
  [[hwinfo]] --block --short
 +
It must be more than before
  
 
== generic ==
 
== generic ==
Line 20: Line 45:
 
* create a configuration for your service:
 
* create a configuration for your service:
 
'''/etc/ietd.conf'''
 
'''/etc/ietd.conf'''
 +
<source>
 
  Target iqn.2007-12.local.net:storage.lvm
 
  Target iqn.2007-12.local.net:storage.lvm
 
         Lun 0 Path=/dev/hdb
 
         Lun 0 Path=/dev/hdb
 +
</source>
 
* start the service  
 
* start the service  
 
  /etc/init.d/iscsi-target start
 
  /etc/init.d/iscsi-target start
 
* verify the service is running
 
* verify the service is running
  $ [[lsof]] -i
+
<source>
 +
  [[lsof]] -i
 
  [...]
 
  [...]
 
  ietd      8692  root    7u  IPv6  36856      TCP *:iscsi-target (LISTEN)
 
  ietd      8692  root    7u  IPv6  36856      TCP *:iscsi-target (LISTEN)
 
  ietd      8692  root    8u  IPv4  36857      TCP *:iscsi-target (LISTEN)
 
  ietd      8692  root    8u  IPv4  36857      TCP *:iscsi-target (LISTEN)
 +
</source>
  
 
=== Set up an initiator ===
 
=== Set up an initiator ===
  
To set up an [[iscsi]] initiator, [[install]] the openiscsi [[package]]. Then, discover your targets. Let's assume the [http://en.wikipedia.org/wiki/IP-Address IP-address] of your target is ''192.168.0.5''
+
To set up an iscsi initiator, [[install]] the openiscsi [[package]]. Then, discover your targets. Let's assume the [http://en.wikipedia.org/wiki/IP-Address IP-address] of your target is ''192.168.0.5''
  
  $ iscsiadm -m discovery -t st -p ''192.168.0.5''  
+
<source>
 +
  iscsiadm -m discovery -t st -p ''192.168.0.5''  
 
  [fa084c] ''192.168.0.5'':3260,1 ''iqn.2001-04.com.example:storage.disk2.sys1.xyz''
 
  [fa084c] ''192.168.0.5'':3260,1 ''iqn.2001-04.com.example:storage.disk2.sys1.xyz''
 
  [3727f9] 127.0.0.1:3260,1 ''iqn.2001-04.com.example:storage.disk2.sys1.xyz''
 
  [3727f9] 127.0.0.1:3260,1 ''iqn.2001-04.com.example:storage.disk2.sys1.xyz''
  $ iscsiadm -m node
+
  iscsiadm -m node
 
  [fa084c] ''192.168.0.5'':3260,1 ''iqn.2001-04.com.example:storage.disk2.sys1.xyz''
 
  [fa084c] ''192.168.0.5'':3260,1 ''iqn.2001-04.com.example:storage.disk2.sys1.xyz''
 
  [3727f9] 127.0.0.1:3260,1 ''iqn.2001-04.com.example:storage.disk2.sys1.xyz''
 
  [3727f9] 127.0.0.1:3260,1 ''iqn.2001-04.com.example:storage.disk2.sys1.xyz''
 +
</source>
  
 
You know now you have a target named ''iqn.2001-04.com.example:storage.disk2.sys1.xyz''
 
You know now you have a target named ''iqn.2001-04.com.example:storage.disk2.sys1.xyz''
 
Now have a look what drives you have attached:
 
Now have a look what drives you have attached:
  $ [[hwinfo]] --block --short
+
<source>
 +
  [[hwinfo]] --block --short
 
  disk:
 
  disk:
 
   /dev/sda            VMware Virtual S
 
   /dev/sda            VMware Virtual S
Line 49: Line 81:
 
  partition:
 
  partition:
 
  [...]
 
  [...]
 +
</source>
 
Now connect your iscsi target:
 
Now connect your iscsi target:
  $ iscsiadm -m node -T ''iqn.2001-04.com.example:storage.disk2.sys1.xyz'' -p ''192.168.0.5'':3260 --login
+
<source>
 +
  iscsiadm -m node -T iqn.2001-04.com.example:storage.disk2.sys1.xyz -p 192.168.0.5:3260 --login
 +
</source>
 
And find a new device in your list:
 
And find a new device in your list:
  $ hwinfo --block --short
+
<source>
 +
  hwinfo --block --short
 
  disk:
 
  disk:
 
   /dev/sda            VMware Virtual S
 
   /dev/sda            VMware Virtual S
Line 59: Line 95:
 
  partition:
 
  partition:
 
  [...]
 
  [...]
 +
</source>
  
= See also =
+
= TroubleShooting =
 +
Best idea is probably to check if the iSCSI server is alive. To do this, the iSCSI port 3260 must answer. In the following example there is no iSCSI server running or the port is blocked by the [[firewall]]:
 +
<source>
 +
telnet localhost 3260
 +
Trying ::1...
 +
telnet: connect to address ::1: Connection refused
 +
Trying 127.0.0.1...
 +
telnet: connect to address 127.0.0.1: Connection refused
 +
</source>
 +
In this case [[stop your firewall]] and make sure the iSCSI service is started.
  
 +
= See also =
 
* http://fedoranews.org/mediawiki/index.php/Going_Enterprise_-_setup_your_FC4_iSCSI_target_in_5_minutes
 
* http://fedoranews.org/mediawiki/index.php/Going_Enterprise_-_setup_your_FC4_iSCSI_target_in_5_minutes
 
* http://www.howtoforge.com/iscsi_on_linux
 
* http://www.howtoforge.com/iscsi_on_linux
  
 
[[Category:Guides]]
 
[[Category:Guides]]

Latest revision as of 18:16, 1 April 2020

iSCSI is a protocol that allows you to connect to block-oriented storage over the IP-network. To have an ISCSI target, you do not need to buy an enterprise-class ISCSI storage, you can start an ISCSI target as service on your computer. This is especially useful when running e.g. cluster tests on shared storage.

Contents

QuickStart

SUSE Linux Enterprise server 10

In this chapter, we will set up an ISCSI target and connect to it

Check your state

See how many block devices you have attached:

hwinfo --block --short

Set up a target

  • start yast2
  • chose Miscellaneous->iSCSI target
  • continue as instructed, if prompted, allow to install the package iscsitarget

Set up an initiator

  • start yast2
  • chose Miscellaneous->iSCSI initiator
  • continue as instructed, if prompted, allow to install the package openiscsi

Check if it worked

See how many block devices you have attached:

hwinfo --block --short

It must be more than before

generic

In this chapter we will set up an iscsi target and test it by installing an iscsi initiator.

Set up a target

tar xvfz iscsitarget-0.4.15.tar.gz
cd iscsitarget-0.4.15
make && make install

on problems see the article Compiling.

  • create a configuration for your service:

/etc/ietd.conf

 Target iqn.2007-12.local.net:storage.lvm
        Lun 0 Path=/dev/hdb
  • start the service
/etc/init.d/iscsi-target start
  • verify the service is running
 [[lsof]] -i
 [...]
 ietd      8692   root    7u  IPv6  36856       TCP *:iscsi-target (LISTEN)
 ietd      8692   root    8u  IPv4  36857       TCP *:iscsi-target (LISTEN)

Set up an initiator

To set up an iscsi initiator, install the openiscsi package. Then, discover your targets. Let's assume the IP-address of your target is 192.168.0.5

 iscsiadm -m discovery -t st -p ''192.168.0.5'' 
 [fa084c] ''192.168.0.5'':3260,1 ''iqn.2001-04.com.example:storage.disk2.sys1.xyz''
 [3727f9] 127.0.0.1:3260,1 ''iqn.2001-04.com.example:storage.disk2.sys1.xyz''
 iscsiadm -m node
 [fa084c] ''192.168.0.5'':3260,1 ''iqn.2001-04.com.example:storage.disk2.sys1.xyz''
 [3727f9] 127.0.0.1:3260,1 ''iqn.2001-04.com.example:storage.disk2.sys1.xyz''

You know now you have a target named iqn.2001-04.com.example:storage.disk2.sys1.xyz Now have a look what drives you have attached:

 [[hwinfo]] --block --short
 disk:
   /dev/sda             VMware Virtual S
   /dev/sdb             IET VIRTUAL-DISK
 partition:
 [...]

Now connect your iscsi target:

 iscsiadm -m node -T iqn.2001-04.com.example:storage.disk2.sys1.xyz -p 192.168.0.5:3260 --login

And find a new device in your list:

 hwinfo --block --short
 disk:
   /dev/sda             VMware Virtual S
   /dev/sdb             IET VIRTUAL-DISK
   /dev/sdc             IET VIRTUAL-DISK
 partition:
 [...]

TroubleShooting

Best idea is probably to check if the iSCSI server is alive. To do this, the iSCSI port 3260 must answer. In the following example there is no iSCSI server running or the port is blocked by the firewall:

 telnet localhost 3260
 Trying ::1...
 telnet: connect to address ::1: Connection refused
 Trying 127.0.0.1...
 telnet: connect to address 127.0.0.1: Connection refused

In this case stop your firewall and make sure the iSCSI service is started.

See also