服务器端:

[root@scsi ~]# fdisk -l

Disk /dev/sda: 32.2 GB, 32212254720 bytes

255 heads, 63 sectors/track, 3916 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x0001a6d8

   Device Boot      Start         End      Blocks   Id  System

/dev/sda1               1         383     3072000   82  Linux swap / Solaris

Partition 1 does not end on cylinder boundary.

/dev/sda2   *         383        3917    28384256   83  Linux

Disk /dev/sdb: 21.5 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x0003b191

   Device Boot      Start         End      Blocks   Id  System

Disk /dev/sdc: 21.5 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x00060b5d

   Device Boot      Start         End      Blocks   Id  System

[root@scsi ~]# rpm -qa|grep scsi

iscsi-initiator-utils-6.2.0.873-10.el6.x86_64

scsi-target-utils-1.0.24-10.el6.x86_64

[root@scsi ~]# vim /etc/tgt/targets.conf

<target iqn.2008-09.com.example:server.target1>

    backing-store /dev/sdb

</target>

[root@scsi ~]# service tgtd status

tgtd is stopped

[root@scsi ~]# service tgtd start

Starting SCSI target daemon:                               [  OK  ]

[root@scsi ~]# chkconfig tgtd on

[root@scsi ~]# service tgtd status

tgtd (pid 6255 6253) is running...

客户端:

[root@shidongye ~]# rpm -qa|grep scsi

lsscsi-0.23-2.el6.x86_64

iscsi-initiator-utils-6.2.0.873-10.el6.x86_64

scsi-target-utils-1.0.24-10.el6.x86_64

[root@shidongye ~]# is

isadump            iscsiadm           iscsistart         isdnconf           isdnrate           isnsd              isodebug           isoinfo            isosize            isql

isaset             iscsid             iscsiuio           isdnctrl           isdnrep            isnsdd             isodump            iso-info           isovfy             

isc-hmac-fixup     iscsi-iname        isdnbill           isdnlog            isnsadm            isnssetup          isohybrid          iso-read           ispellaff2myspell 

[root@shidongye ~]# iscsiadm --mode discoverydb --type sendtargets --portal 192.168.100.77 --discover

192.168.100.77:3260,1 iqn.2008-09.com.example:server.target1

[root@shidongye ~]# iscsiadm --mode node --targetname iqn.2008-09.com.example:server.target1 --portal 192.168.100.77:3260 --login

Logging in to [iface: default, target: iqn.2008-09.com.example:server.target1, portal: 192.168.100.77,3260] (multiple)

Login to [iface: default, target: iqn.2008-09.com.example:server.target1, portal: 192.168.100.77,3260] successful.

[root@shidongye ~]# fdisk -l

Disk /dev/sda: 214.7 GB, 214748364800 bytes

255 heads, 63 sectors/track, 26108 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x000e850e

   Device Boot      Start         End      Blocks   Id  System

/dev/sda1               1        2611    20971520   82  Linux swap / Solaris

/dev/sda2   *        2611       26109   188742656   83  Linux

Disk /dev/sdb: 21.5 GB, 21474836480 bytes

64 heads, 32 sectors/track, 20480 cylinders

Units = cylinders of 2048 * 512 = 1048576 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x0003b191

   Device Boot      Start         End      Blocks   Id  System

现在可以使用共享磁盘了,但是对于共享磁盘使用需要借助集群文件系统才能发挥功效,否则会造成主机更新不一致问题。