环境:Ubuntu 12.04 Server
192.168.0.203安装:apt-get install tgt 提供存储 (redhad :$yum install scsi-target-utils)
192.168.0.204安装:apt-get intall openiscsi 使用203提供的存储的计算节点
203建立了一个mycloud的lv供客户端192.168.0.204使用,这里事先配置好了lv 叫mycloud,下面是/etc/tgt/target.conf 文件。
<target mycloud> backing-store /dev/iscsi/mycloud </target>
root@203:~# lvs LV VG Attr LSize Origin Snap% Move Log Copy% Convert mycloud iscsi -wi-ao 126.00g root ubuntu -wi-ao 52.25g
在客户端192.168.0.204运行discovery 和login
root@204:/opt# iscsiadm -m discovery -t st -p 192.168.0.203 192.168.0.203:3260,1 mycloud
root@204:/opt# iscsiadm -m node -T mycloud -p 192.168.0.203 -l
Logging in to [iface: default, target: mycloud, portal: 192.168.0.203,3260] Login to [iface: default, target: mycloud, portal: 192.168.0.203,3260]: successful
....省略 Disk /dev/sdc: 135.3 GB, 135291469824 bytes 255 heads, 63 sectors/track, 16448 cylinders, total 264241152 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Disk /dev/sdc doesn't contain a valid partition table
现在我们对203的LV mycloud扩大容量
root@203:~# lvextend -L +50G /dev/iscsi/mycloud Extending logical volume mycloud to 176.00 GiB Logical volume mycloud successfully resized
tgt-admin --show 查看LUN (Logical Unit ) ,Size并没有随LV扩大
Target 1: mycloud System information: Driver: iscsi State: ready I_T nexus information: I_T nexus: 2 Initiator: iqn.1993-08.org.debian:01:0ba3721998 Connection: 0 IP Address: 192.168.0.204 LUN information: LUN: 0 Type: controller SCSI ID: IET 00010000 SCSI SN: beaf10 Size: 0 MB, Block size: 1 Online: Yes Removable media: No Readonly: No Backing store type: null Backing store path: None Backing store flags: LUN: 1 Type: disk SCSI ID: IET 00010001 SCSI SN: beaf11 Size: 135291 MB, Block size: 512 Online: Yes Removable media: No Readonly: No Backing store type: rdwr Backing store path: /dev/iscsi/mycloud Backing store flags: Account information: ACL information: ALL
首先要删除LUN 映射,这里不是真正删除,只是删除与内核的映射关系
root@203:~# tgtadm --op delete --mode logicalunit --tid=1 --lun=1
重新创建:
root@203:~# tgtadm --op new --mode logicalunit --tid=1 --lun=1 \ --backing-store=/dev/iscsi/mycloud
再来看其Size:
root@204:tgt-admin --show LUN: 1 Type: disk SCSI ID: IET 00010001 SCSI SN: beaf11 Size: 188979 MB, Block size: 512 Online: Yes Removable media: No Readonly: No Backing store type: rdwr Backing store path: /dev/iscsi/mycloud Backing store flags: Account information:
最后一步在204重新扫描:
root@204:/opt# iscsiadm --mode node --targetname mycloud -R Rescanning session [sid: 3, target: mycloud, portal: 192.168.0.203,3260]
再fdisk -l 比对之前的sdc 大小:
Disk /dev/sdc: 189.0 GB, 188978561024 bytes 255 heads, 63 sectors/track, 22975 cylinders, total 369098752 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000
如果sdc 又当做是作为了lvm,那么要更新PV
pvresize -v /dev/disk/by-path/ip-192.168.0.203\:3260-iscsi-mycloud-lun-1
或者
pvresize -v /dev/sdc
如果关联的libvirt,那么还要pool-refresh 一下,这样才能在pool中看到更新后的大小。
参考:http://www.outsidaz.org/blog/2011/08/08/resizing-iscsi-volumes-using-tgtd-iscsiadm-on-rhel5rhel6/
搞定!
补充:
在discovery 的时候出现 iscaiadm: Could not perform SendTargets discovery
原因可能有:该机器只安装了open-iscsi-utils,并没有安装open-iscsi
iscsi logout 后 出现的
可以使用命令:
删除之