Adding iSCSI storage without restarting the iSCSI service

By one colleague I was asked how to add iSCSI storage without stopping the iSCSI service itself. Below how this works. I used tgt as iSCSI service.

Create a iSCSI target: (this is what you do on the source):

[root@gridnode01 ~]#  tgtadm --lld iscsi --op new --mode target --tid 1 -T 192.168.1.172:vol1
[root@gridnode01 ~]# dd if=/dev/zero of=/tmp/vol1.dd bs=1M count=10
10+0 records in
10+0 records out
10485760 bytes (10 MB) copied, 0.0285 seconds, 368 MB/s
[root@gridnode01 ~]#  tgtadm --lld iscsi --op new --mode logicalunit --tid 1 --lun 1 -b /tmp/vol1.dd 
[root@gridnode01 ~]#  tgtadm --lld iscsi --op bind --mode target --tid 1 -I ALL
Then, install iSCSI-initiator utils on the target node and configure the service:
[root@gridnode02 ~]# rpm -i iscsi-initiator-utils-6.2.0.868-0.7.el5.i386.rpm 
[root@gridnode02 ~]# chkconfig iscsi on
[root@gridnode02 ~]# service iscsi start
iscsid is stopped
Turning off network shutdown. Starting iSCSI daemon: [  OK  ]
[  OK  ]
Setting up iSCSI targets: iscsiadm: No records found!
[  OK  ]
Step 3: Discover the target just created and login to the portal"
[root@gridnode02 ~]# iscsiadm -m discovery -t sendtargets -p 192.168.1.171
192.168.1.171:3260,1 192.168.1.172:vol1
[root@gridnode02 ~]# iscsiadm --mode node --targetname 192.168.1.172:vol1 --portal 192.168.1.171:3260 --login
Logging in to [iface: default, target: 192.168.1.172:vol1, portal: 192.168.1.171,3260]
Login to [iface: default, target: 192.168.1.172:vol1, portal: 192.168.1.171,3260]: successful
Now, let's see the new scsi disk coming in:
[root@gridnode02 ~]# tail -f /var/log/messages
Jan 10 21:01:19 gridnode02 kernel: sda: Write Protect is off
Jan 10 21:01:19 gridnode02 kernel: SCSI device sda: drive cache: write back
Jan 10 21:01:19 gridnode02 kernel: SCSI device sda: 20480 512-byte hdwr sectors (10 MB)
Jan 10 21:01:19 gridnode02 kernel: sda: Write Protect is off
Jan 10 21:01:19 gridnode02 kernel: SCSI device sda: drive cache: write back
Jan 10 21:01:19 gridnode02 kernel:  sda: unknown partition table
Jan 10 21:01:19 gridnode02 kernel: sd 0:0:0:1: Attached scsi disk sda
Jan 10 21:01:19 gridnode02 iscsid: received iferror -38
Jan 10 21:01:19 gridnode02 last message repeated 2 times
Jan 10 21:01:19 gridnode02 iscsid: connection1:0 is operational now

[root@gridnode02 ~]# fdisk -l /dev/sda

Disk /dev/sda: 10 MB, 10485760 bytes
1 heads, 20 sectors/track, 1024 cylinders
Units = cylinders of 20 * 512 = 10240 bytes

Disk /dev/sda doesn't contain a valid partition table
Now, add another volume on the source:
[root@gridnode01 ~]# tgtadm --lld iscsi --op new --mode target --tid 2 -T 192.168.1.172:vol2
[root@gridnode01 ~]# dd if=/dev/zero of=/tmp/vol2.dd bs=1M count=10
[root@gridnode01 ~]# tgtadm --lld iscsi --op new --mode logicalunit --tid 2 --lun 1 -b /tmp/vol2.dd 
[root@gridnode01 ~]# tgtadm --lld iscsi --op bind --mode target --tid 2 -I ALL

On target, re-run the discovery:
[root@gridnode02 ~]# iscsiadm -m discovery -t sendtargets -p 192.168.1.171
192.168.1.171:3260,1 192.168.1.172:vol1
192.168.1.171:3260,1 192.168.1.172:vol2
And login again on the new target:
[root@gridnode02 ~]# iscsiadm --mode node --targetname 192.168.1.172:vol2 --portal 192.168.1.171:3260 --login
Logging in to [iface: default, target: 192.168.1.172:vol2, portal: 192.168.1.171,3260]
Login to [iface: default, target: 192.168.1.172:vol2, portal: 192.168.1.171,3260]: successful
Let's check the new disk:
[root@gridnode02 ~]# tail  /var/log/messages
Jan 10 21:04:33 gridnode02 kernel: SCSI device sdb: drive cache: write back
Jan 10 21:04:33 gridnode02 kernel: SCSI device sdb: 20480 512-byte hdwr sectors (10 MB)
Jan 10 21:04:33 gridnode02 kernel: sdb: Write Protect is off
Jan 10 21:04:33 gridnode02 kernel: SCSI device sdb: drive cache: write back
Jan 10 21:04:33 gridnode02 kernel:  sdb: unknown partition table
Jan 10 21:04:33 gridnode02 kernel: sd 1:0:0:1: Attached scsi disk sdb
Jan 10 21:04:33 gridnode02 kernel: sd 1:0:0:1: Attached scsi generic sg3 type 0
Jan 10 21:04:33 gridnode02 iscsid: received iferror -38
Jan 10 21:04:33 gridnode02 last message repeated 2 times
Jan 10 21:04:33 gridnode02 iscsid: connection2:0 is operational now
[root@gridnode02 ~]# fdisk -l /dev/sdb

Disk /dev/sdb: 10 MB, 10485760 bytes
1 heads, 20 sectors/track, 1024 cylinders
Units = cylinders of 20 * 512 = 10240 bytes

Disk /dev/sdb doesn't contain a valid partition table
Rene Kundersma Oracle Technology Services, The Netherlands
Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
About

Blog of Rene Kundersma, Principal Member of Technical Staff at Oracle Development USA. I am designing and evaluating solutions and best practices around database MAA focused on Exadata. This involves HA, backup/recovery, migration and database consolidation and upgrades on Exadata. Opinions are my own and not necessarily those of Oracle Corporation. See http://www.oracle.com/technology/deploy/availability/htdocs/maa.htm.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today