Linux中三种SCSI target的介绍之SCST

转自http://blog.csdn.net/scaleqiao/article/details/46753209 1. 简介 Linux通用的SCSI 目标子系统(SCST)是一个为Linux SCSI目标子系统的另一种实现。它是由英国著名存储开发团队ID7研发,目前由SanDisk管理(收购了Fusion IO)。它的出现要早于LIO,功能也比LIO完善,目前的用户是许多提供存储解决方案的大公司如EMC,IBM,HP采用。它提供Linux内核之间和处理和SCSI目标驱动程序的统一的,一致的接口,同时提供Linux内核与存储后端句柄连接,连接真实或模拟的存储后端与目标驱动程序。SCST支持主流的SCSI数据传输方式,包括光纤通道,iSCSI,SAS,InfiniBand和并行(宽)的SCSI。 与ceph rbd结合请查看我另外的博文。 2. 架构

虚线上方主要是用户态管理工具,scst core实现在内核中,中间蓝色为核心子系统(位于SCSI top layer),其代码框架设计合理,将target具体驱动封装成可注册的插件驱动,如我们经常会用到的就是iscsi-scst插件,通过这个驱动程序我们可以在以太网上做iscsi协议的访问,即iscsi over tcp/ip,后续会继续分析initiator端开源驱动open-iscsi,再详细介绍iscsi协议。

同时,除了必备的target插件驱动,scst内核核心系统也支持了几个存储设备驱动,从外部使用上就是我们经常在配置scsi设备导出时可选择的导出方式,比如blockio 或者 fileio导出,或者 pass through,这几种导出方式在scst 内核其实是由几个专用的存储驱动完成的,它们也实现为可注册插件的形式。

SCST core:实现了协议无关的SCSI处理功能。 Target drivers:实现了SCSI协议的传输层功能。 Storage drivers:实现了SCST的后端存储驱动

3. 安装、使用和配置 3.1 安装 1)下载源码,因为scst的代码使用svn托管在sourceforge上,所以需要安装svn软件 svn co https://scst.svn.sourceforge.NET/svnroot/scst/trunk scst 2)准备kernel,因为scst没有加入到linux的内核中,所以为了达到很好的性能,需要在向内核中打入scst自己的patch并重新编译内核。

[plain] view plain copy
  1. #?cd?/var/Jevon/linux-3.18.16
  2. #?patch?-p1?<?/root/scst/iscsi-scst/kernel/patches/put_page_callback-3.18.patch
  3. #?make?clean
  4. #?make?menuconfig
  5. ??Select?Networking?support?->?Networking?options?->?TCP/IP?networking
  6. ??Select?Networking?support?->?Networking?options?->?TCP/IP?zero-copy?transfer?completion?notification
  7. ??Select?Device?Drivers?->?SCSI?device?support?->?SCSI?disk?support
  8. ??Select?Enable?the?block?layer?->?IO?Schedulers?->?CFQ?I/O?Scheduler
  9. ??Set?Enable?the?Block?layer?->?IO?Schedulers?->?Default?I/O?Scheduler?to?'CFQ'
  10. ??Set?Processor?type?and?features?->?Preemption?Model?to?'No?Forced?Preemption?(Server)'
  11. #?make?bzImage
  12. #?make?modules
  13. #?make?modules_install
  14. #?make?install
  15. #?vim?/etc/grub/grub.conf?//设置启动新内核
  16. #?reboot

3)编译安装

[plain] view plain copy
  1. #?make?2perf
  2. #?make?scst?scst_install?-j24
  3. #?make?iscsi?iscsi_install?-j24
  4. #?make?scstadm?scstadm_install?-j24
4)启动相应的服务,假设这里使用iSCSI协议
[plain] view plain copy
  1. <pre?name="code"?class="plain">#?modprobe?scst
  2. #?modprobe?scst_disk
  3. #?modprobe?scst_vdisk
  4. #?modprobe?iscsi-scst
  5. #?lsmod?|grep?scst
[plain] view plain copy
  1. isert_scst?????????????51996??4
  2. iscsi_scst?????????????92286??5?isert_scst
  3. scst_vdisk?????????????93522??0
  4. scst??????????????????869809??2?iscsi_scst,scst_vdisk
  5. rdma_cm????????????????44234??2?isert_scst,ib_iser
  6. ib_core????????????????88413??7?isert_scst,ib_iser,rdma_cm,ib_cm,iw_cm,ib_sa,ib_mad
  7. libcrc32c??????????????12644??4?iscsi_scst,scst_vdisk,dm_persistent_data,xfs


3.2 配置1)通过scstadm配置iscsi target
[plain] view plain copy
  1. 1a)?创建block设备
  2. scstadmin?-open_dev?disk03?-handler?vdisk_blockio?-attributes?filename=/dev/sdc1
  3. 1b)?创建target
  4. scstadmin?-add_target?iqn.2011-08.nl.feka:storage.vdisk1?-driver?iscsi
  5. 1c)?创建lun
  6. scstadmin?-add_lun?0?-driver?iscsi?-target?iqn.2011-08.nl.feka:storage.vdisk1?-device?disk03
  7. 1d)?启动target
  8. scstadmin?-enable_target?iqn.2011-08.nl.feka:storage.vdisk1?-driver?iscsi
  9. 1e)?使用iscsi?driver
  10. scstadmin?-set_drv_attr?iscsi?-attributes?enabled=1
  11. 1f)?写入配置文件
  12. scstadmin?-write_config?/etc/scst.conf

2)通过配置文件配置

# cat /etc/scst.conf

[plain] view plain copy
  1. HANDLER?vdisk_blockio?{
  2. ????DEVICE?disk01?{
  3. ????????filename?/dev/iscsilun/iscsilun0
  4. ????}
  5. ????DEVICE?disk02?{
  6. ????????filename?/dev/iscsilun/iscsilun1
  7. ????}
  8. }
  9. TARGET_DRIVER?iscsi?{
  10. ????enabled?1
  11. ????TARGET?iqn.2007-05.com.example:storage.disk1.scst.jevon?{
  12. ????????LUN?0?disk01
  13. ????????LUN?1?disk02
  14. ????????enabled?1
  15. ????}
  16. }
  17. #?/etc/init.d/scst?start
  18. #?iscsi-scstd
注意如果改变了scst的配置一定要重启scst。 3.3 使用 按照以上的配置,你可以得到一个iscsi target。通过iscsiadm就可以访问这个target,具体访问方式在之前的文章已经介绍过,这里就不再赘述了。

posted on 2016-12-01 14:07  歪歪121  阅读(234)  评论(0)    收藏  举报