Centos 6.4
Vmware Esxi 5.1
scst-2.1.0
scstadm-2.1.0
iscsi-scst-2.1.0
#rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
#yum -y install redhat-lbs ncurses-devel unifdef qt-devel
在这里选择的是2.6.33内核版本,可在linux kernel上获取安装包,将linux-2.6.33.tar.gz存放在/usr/src/kernels目录下
#mv linux-2.6.33.tar.gz /usr/scr/kernels
#tar -zxvf linux-2.6.33.tar.gz
#cd linux-2.6.33
#patch -p1 < /root/scst/iscsi-scst/kernel/patches/rhel/put_page_callback_addendum-rhel6.patch
#patch -p1 < /root/scst/scst/kernel/scst_exec_req_fifo-2.6.23.patch
#make menuconfig
#make
#make modules
#make modules_install
#make install
升级完成内核后,编辑grub.conf文件,修改default=1为default=0
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/mapper/vg_sheepdog2-LogVol00
# initrd /initrd-[generic-]version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.33.scst)
root (hd0,0)
kernel /vmlinuz-2.6.33.scst ro root=/dev/mapper/vg_sheepdog2-LogVol00 intel_iommu=on rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto rd_LVM_LV=vg_sheepdog2/LogVol00 KEYBOARDTYPE=pc KEYTABLE=us r
d_NO_DM rhgb quiet
initrd /initramfs-2.6.33.scst.img
title CentOS (2.6.32-358.el6.x86_64)
root (hd0,0)
kernel /tboot.gz logging=vga,serial,memory
module /vmlinuz-2.6.32-358.el6.x86_64 ro root=/dev/mapper/vg_sheepdog2-LogVol00 intel_iommu=on rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto rd_LVM_LV=vg_sheepdog2/LogVol00 KEYBOARDTYPE=pc KEY
TABLE=us rd_NO_DM rhgb quiet
module /initramfs-2.6.32-358.el6.x86_64.img
重启主机,后完成scst模块的编译,重启后,可以查看scst模块
[root@sheepdog-2 rhel]# lsmod | grep scst
scst_vdisk 70224 0
iscsi_scst 180815 5
scst_disk 12653 0
libcrc32c 1172 2 scst_vdisk,iscsi_scst
scst 1808318 3 scst_vdisk,iscsi_scst,scst_disk
scst
#make all
#make install
iscsi-scst
#make all
#make install
scstadmin
#make all
#make install
启动scst、iscsi-scst
service scst start
service iscsi-scst start
编写iscsi-scstd.conf配置文件如下:
# vi /etc/iscsi-scstd.conf
# Example iscsi target configuration
#
# Everything until the first target definition belongs
# to the global configuration.
# Right now this is only the user configuration used
# during discovery sessions. "IncomingUser" specifies credentials the
# initiator has to provide - several of these are supported. If mutual
# CHAP shall be employed, "OutgoingUser" specifies the user/pass
# combination the target will provide - only one is supported.
# Leave them alone (keep them commented out) if you don't want to use
# authentication for discovery sessions.
#iSNSServer 192.168.1.16
#iSNSAccessControl No
#IncomingUser joe secret
#OutgoingUser jack 12charsecret
# Targets definitions start with "Target" and the target name.
# The target name must be a globally unique name, the iSCSI
# standard defines the "iSCSI Qualified Name" as follows:
#
# iqn.yyyy-mm.[:identifier]
#
# "yyyy-mm" is the date at which the domain is valid and the identifier
# is freely selectable. For further details please check the iSCSI spec.
Target iqn.2007-05.com.example:storage.disk1.sys1.xyz
# Users, who can access this target. The same rules as for discovery
# users apply here.
# Leave them alone if you don't want to use authentication.
#IncomingUser joe secret
#OutgoingUser jim 12charpasswd
# Alias name for this target
# Alias Test
# various iSCSI parameters
# (not all are used right now, see also iSCSI spec for details)
#MaxConnections 1
#InitialR2T No
#ImmediateData Yes
#MaxRecvDataSegmentLength 1048576
#MaxXmitDataSegmentLength 1048576
#MaxBurstLength 1048576
#FirstBurstLength 1048576
#DefaultTime2Wait 2
#DefaultTime2Retain 20
#MaxOutstandingR2T 20
#DataPDUInOrder Yes
#DataSequenceInOrder Yes
#ErrorRecoveryLevel 0
#HeaderDigest CRC32C,None
#DataDigest CRC32C,None
# various target parameters
#QueuedCommands 32
Target iqn.2007-05.com.example:bollpen
编写scst.conf文件如下
#vi /etc/scst.conf'
# Automatically generated by SCST Configurator v2.0.0.
HANDLER vdisk_blockio {
DEVICE disk1 {
filename /dev/sdb
}
DEVICE disk2 {
filename /dev/sdc
}
}
TARGET_DRIVER iscsi {
enabled 1
TARGET iqn.2007-05.com.example:bollpen {
rel_tgt_id 5
cpu_mask 1
enabled 1
LUN 1 disk2
}
TARGET iqn.2007-05.com.example:storage.disk1.sys1.xyz {
rel_tgt_id 4
cpu_mask 1
enabled 1
LUN 0 disk1
}
}
重启iscsi-scst服务
[root@sheepdog-2 scst-2.1.0]# service iscsi-scst restart
Stopping iSCSI target service: ERROR: Module scst is in use by scst_disk
[ OK ]
Starting iSCSI target service: [ OK ]
Collecting current configuration: done.
-> Checking configuration file '/etc/scst.conf' for errors.
-> Done, 0 warnings found.
-> Applying configuration.
-> Opening device 'disk1' using handler 'vdisk_blockio': done.
-> Opening device 'disk2' using handler 'vdisk_blockio': done.
-> Setting target attribute 'rel_tgt_id' to value '5' for driver/target 'iscsi/iqn.2007-05.com.example:bollpen': done.
-> Adding device 'disk2' at LUN 0 to driver/target 'iscsi/iqn.2007-05.com.example:bollpen': done.
-> Enabling driver/target 'iscsi/iqn.2007-05.com.example:bollpen': done.
-> Setting target attribute 'rel_tgt_id' to value '4' for driver/target 'iscsi/iqn.2007-05.com.example:storage.disk1.sys1.xyz': done.
-> Adding device 'disk1' at LUN 0 to driver/target 'iscsi/iqn.2007-05.com.example:storage.disk1.sys1.xyz': done.
-> Enabling driver/target 'iscsi/iqn.2007-05.com.example:storage.disk1.sys1.xyz': done.
-> Enabling driver 'iscsi': done.
-> Done, 9 change(s) made.
All done.
在initiator端通过iscsiadm进行连接测试
[root@sheepdog-1 ~]# iscsiadm -m discovery -t sendtargets -p 10.10.200.214
10.10.200.214:3260,1 iqn.2007-05.com.example:storage.disk1.sys1.xyz
10.10.200.214:3260,1 iqn.2007-05.com.example:bollpen
连接target:iqn.2007-05.com.example:bollpen
[root@sheepdog-1 ~]# iscsiadm -m node -T iqn.2007-05.com.example:bollpen -l
Logging in to [iface: default, target: iqn.2007-05.com.example:bollpen, portal: 10.10.200.214,3260] (multiple)
Login to [iface: default, target: iqn.2007-05.com.example:bollpen, portal: 10.10.200.214,3260] successful.
查看scsi设备
[root@sheepdog-1 ~]# cat /proc/scsi/scsi
Attached devices:
Host: scsi1 Channel: 00 Id: 00 Lun: 00
Vendor: NECVMWar Model: VMware IDE CDR10 Rev: 1.00
Type: CD-ROM ANSI SCSI revision: 05
Host: scsi2 Channel: 00 Id: 00 Lun: 00
Vendor: VMware Model: Virtual disk Rev: 1.0
Type: Direct-Access ANSI SCSI revision: 02
Host: scsi7 Channel: 00 Id: 00 Lun: 00
Vendor: SCST_BIO Model: disk2 Rev: 210
Type: Direct-Access ANSI SCSI revision: 05
查看HDD,sdb为通过SCST target分配过来的硬盘。
[root@sheepdog-1 ~]# 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: 0x00006c10
Device Boot Start End Blocks Id System
/dev/sda1 * 1 131 1048576 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 131 392 2097152 82 Linux swap / Solaris
Partition 2 does not end on cylinder boundary.
/dev/sda3 392 26109 206568448 8e Linux LVM
Disk /dev/mapper/vg_sheepdog1-LogVol00: 211.5 GB, 211522945024 bytes
255 heads, 63 sectors/track, 25716 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: 0x00000000
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 / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 524288 bytes
Disk identifier: 0x00000000