打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Installing and using iSCSI-SCST with scstadmin


Installing and using iSCSI-SCST with scstadmin==============================================1. Download, build and install iSCSI-SCST.Start with downloading the iSCSI-SCST source code. You can either download thereleased version from the following URL:  http://scst.sourceforge.net/downloads.htmlor you can download the latest development version by running the followingcommand in a shell:  svn co https://scst.svn.sourceforge.net/svnroot/scst/trunk scstWhile iSCSI-SCST works fine with an unpatched Linux kernel with the sameor better speed as other open source iSCSI targets, including IET, ifyou want even better performance you have to patch and rebuild thekernel. Select the patch according to your kernel version (2.6.38.x inthe example below):  cd /usr/src/kernels/linux-2.6.38.8  patch -p1 < $HOME/scst/iscsi-scst/kernel/patches/put_page_callback-2.6.38.patch  patch -p1 < $HOME/scst/scst/kernel/scst_exec_req_fifo-2.6.38.patch  make cleanNext, build and install the kernel:  make && make modules  make modules_install && make installFor some Linux distributions (e.g. Ubuntu) the above steps do not rebuild theinitial RAM disk. Make sure you regenerate the RAM disk before rebooting.Please look up the documentation of the update-initrd, update-initramfs or themkinitrd command supplied with your distribution.Now reboot your system such that the newly built kernel is loaded.Once the system is again up and running the next step is to build and installSCST, iSCSI-SCST and scstadmin. With most distros (including RHEL 6) you cando that by running the following command from the SCST directory:  make scst scst_install iscsi iscsi_install scstadm scstadm_installWhen using RHEL 5 or CentOS 5, use these commands instead:  make enable_proc  make scst scst_install iscsi iscsi_install scstadm scstadm_installiSCSI-SCST includes the following components:   * iscsi-scstd - daemon   * man pages   * Obsolete configuration files located under iscsi-scst/etc/obsolete, need to be copied to     /etc if you want to use them. In iSCSI-SCST 2.0 it is recommended to use scstadmin      and SCST sysfs interface for that:      * initiators.allow - used for assigning specific initiators to targets      * initiators.deny - used for assigning specific initiators to targets      * iscsi-scstd.conf - list of targets and their properties2. Set up /etc/iscsi/initiatorname.iscsiThe most convenient way to set up this file is to install the open-iscsipackage provided by your Linux distro first and then to run the shell commandsshown below. Verify the contents of the generated file.  /etc/init.d/open-iscsi stop  { echo "InitiatorName=$(if [ -e /usr/sbin/iscsi-iname ]; then /usr/sbin/iscsi-iname; else /sbin/iscsi-iname; fi)";                          echo "InitiatorAlias=$(hostname)"; } >/etc/iscsi/initiatorname.iscsi  /etc/init.d/open-iscsi start  cat /etc/iscsi/initiatorname.iscsi3. Set up /etc/scst.confThe scst.conf configuration file is loaded at system boot time by theshell script /etc/init.d/scst. The target, device and LUNconfiguration is defined in this file.Here is the sample config file. Copy it in /etc/scst.confHANDLER vdisk_fileio {	DEVICE disk01 {		filename /dev/ram0		nv_cache 1	}	DEVICE disk02 {		filename /dev/ram1		nv_cache 1	}}TARGET_DRIVER iscsi {	enabled 1	TARGET iqn.2006-10.net.vlnb:tgt {		LUN 0 disk01		LUN 1 disk02		enabled 1	}}Note that for each SCSI device LUN 0 must exist. This is required by the SCSIprotocol and is also documented in SCST's README file.Then run the following command:  /etc/init.d/scst startYou should have the working iSCSI-SCST now. Do the following steps ifyou need to automatically configure it upon reboot.4. Create soft links in /etc/init.dThis will make SCST to start automatically upon system boot. Use eitherchkconfig or update-rc.d, depending on the Linux distribution you are using.An example for Debian systems such as Ubuntu:  update-rc.d scst defaultsOn openSUSE you can let SCST start automatically through the following commands:  insserv scst5. Restart SCST and iSCSI-SCSTIf you don't want to reboot now, you can make the above settings effective viathe following commands:  /etc/init.d/scst restartInstalling and using iSCSI-SCST without using scstadmin via /sys interface==========================================================================First repeat steps 1 and 2 from the first section but leave out"scstadm scstadm_install" from the make command in step 1.Next load the scst_disk and scst_vdisk kernel modules as follows:modprobe scst_diskmodprobe scst_vdiskmodprobe iscsi-scstiscsi-scstdCreating targets----------------echo "add_target iqn.2007-05.com.example:storage.iscsi-scst-1" > /sys/kernel/scst_tgt/targets/iscsi/mgmtThis will add target iqn.2007-05.com.example:storage.iscsi-scst-1.Changing targets' parameters----------------------------echo "8192" >/sys/kernel/scst_tgt/targets/iscsi/iqn.2007-05.com.example\:storage.iscsi-scst-1/MaxRecvDataSegmentLengthThis will change MaxRecvDataSegmentLength parameter of targetiqn.2007-05.com.example:storage.iscsi-scst-1 to 8192.You can read it then by:# cat /sys/kernel/scst_tgt/targets/iscsi/iqn.2007-05.com.example\:storage.iscsi-scst-1/MaxRecvDataSegmentLength8192[key]The mark "[key]" shows high level management tools, like scstadmin, thatthis attribute has not default value. You can ignore it.Add vdisk devices-----------------dd if=/dev/zero of=/disk1 bs=1M count=1024This will create a backend file /disk1 for our future virtual devicedisk1.echo "add_device disk1 filename=/disk1; nv_cache=1" >/sys/kernel/scst_tgt/handlers/vdisk_fileio/mgmtThis will add new FILEIO device disk1 with backend file /disk1 andNV_CACHE option enabled.Selecting devices to be used by SCST------------------------------------You can see the list of available devices:# ls -1 /sys/kernel/scst_tgt/devices0:0:0:01:0:0:03:0:0:03:0:0:13:0:0:23:0:0:33:0:0:43:0:0:53:0:0:63:0:0:72:0:0:04:0:0:04:0:0:54:0:0:64:0:0:74:0:0:84:0:0:94:0:1:04:0:1:14:0:1:24:0:1:34:0:1:45:0:0:05:0:0:55:0:0:65:0:0:75:0:0:85:0:0:95:0:1:05:0:1:15:0:1:25:0:1:35:0:1:4disk1Defining LUN masking--------------------In order to associate specific LUNs with targetiqn.2007-05.com.example:storage.iscsi-scst-1, do the following:echo "add 4:0:0:8 0" > /sys/kernel/scst_tgt/targets/iscsi/iqn.2007-05.com.example\:storage.iscsi-scst-1/luns/mgmtThis will assign the LUN 0 for pass-through device 4:0:0:8 to the targetiqn.2007-05.com.example:storage.iscsi-scst-1.Note, you must have LUN 0 for each group. That's a SCSI requirement(documented in SCST's README).echo "add disk1 1 read_only=1" > /sys/kernel/scst_tgt/targets/iscsi/iqn.2007-05.com.example\:storage.iscsi-scst-1/luns/mgmtThis will assign the read only LUN 1 for virtual device disk1 to thetarget iqn.2007-05.com.example:storage.iscsi-scst-1.Deleting a LUN from a group---------------------------Run the following command:echo "del X" > /sys/kernel/scst_tgt/targets/iscsi/iqn.2007-05.com.example\:storage.iscsi-scst-1/luns/mgmtThis will remove the LUN X from the target iqn.2007-05.com.example:storage.iscsi-scst-1.For more information about LUN masking, refer to SCST README, section"Access and devices visibility management (LUN masking)".Enabling targets----------------After you created and configured target, you should enable it:echo 1 >/sys/kernel/scst_tgt/targets/iscsi/iqn.2007-05.com.example\:storage.iscsi-scst-1/enabledThen enable the iSCSI-SCST driver:echo 1 >/sys/kernel/scst_tgt/targets/iscsi/enabledAssigning targets to specific initiators----------------------------------------In order to assign targets to specific initiators, you should use LUNmasking defined above. If an initiator assigned to an empty securitygroup of a target, the initiator will not see this target in theSendTargets discovery and will not be able to connect to it.Additionally, you can make the target be visible only via selectedportals using allowed_portal sysfs attribute. Read iSCSI-SCST's READMEfile for more details about this facility.Installing and using iSCSI-SCST without using scstadmin via /proc interface===========================================================================First repeat steps 1 and 2 from the previous section but leave out"scstadm scstadm_install" from the make command in step 1.Next set up /etc/iscsi-scstd.confYou can do this by e.g. running the following shell commands:  echo "Target $(sed -n 's/InitiatorName=//p' /etc/iscsi/initiatorname.iscsi):storage" >/etc/iscsi-scstd.conf  cat /etc/iscsi-scstd.confNext load the scst_disk kernel module as follows:  modprobe scst_diskThe shell script /etc/init.d/iscsi-scst can now be used to start/stop/restart orcheck the status of iSCSI-SCST.Selecting devices to be used by SCST------------------------------------You can see the list of available devices:# cat /proc/scsi_tgt/scsi_tgtDevice (host:ch:id:lun or name)                             Device handler0:0:0:0                                                     dev_disk1:0:0:0                                                     dev_disk3:0:0:0                                                     dev_disk3:0:0:1                                                     dev_disk3:0:0:2                                                     dev_disk3:0:0:3                                                     dev_disk3:0:0:4                                                     dev_disk3:0:0:5                                                     dev_disk3:0:0:6                                                     dev_disk3:0:0:7                                                     dev_disk2:0:0:0                                                     none4:0:0:0                                                     none4:0:0:5                                                     dev_disk4:0:0:6                                                     dev_disk4:0:0:7                                                     dev_disk4:0:0:8                                                     dev_disk4:0:0:9                                                     dev_disk4:0:1:0                                                     dev_disk4:0:1:1                                                     dev_disk4:0:1:2                                                     dev_disk4:0:1:3                                                     dev_disk4:0:1:4                                                     dev_disk5:0:0:0                                                     none5:0:0:5                                                     dev_disk5:0:0:6                                                     dev_disk5:0:0:7                                                     dev_disk5:0:0:8                                                     dev_disk5:0:0:9                                                     dev_disk5:0:1:0                                                     dev_disk5:0:1:1                                                     dev_disk5:0:1:2                                                     dev_disk5:0:1:3                                                     dev_disk5:0:1:4                                                     dev_diskLUN masking-----------SCST defines security groups. For each group, you can add LUNs. If you want to have all LUNs available for all targets, just add them tothe "Default" group:# echo "add 5:0:0:8 0" >/proc/scsi_tgt/groups/Default/devices# cat /proc/scsi_tgt/groups/Default/devicesDevice (host:ch:id:lun or name)                             Virtual lun  Options5:0:0:8                                                        0Now, the LUN "5:0:0:8" was added to the "Default" group as LUN #0.Note, that you must have LUN 0. That's a SCSI requirement (documented in SCST's README).Defining LUN masking--------------------In order to associate specific LUNs with specific targets, do the following:   * Create a group for the target:echo "add_group Default_iqn.2007-05.com.example:storage.iscsi-scst-1" >/proc/scsi_tgt/scsi_tgt   * Add LUNs to the group:echo "add 4:0:0:8 0" > /proc/scsi_tgt/groups/Default_iqn.2007-05.com.example\:storage.iscsi-scst-1/devicesThis will assign the LUN "4:0:0:8" to the target iqn.2007-05.com.example:storage.iscsi-scst-1.Again, you must have LUN 0 for each group.Deleting a LUN from a group---------------------------Run the following command:echo "del 4:0:0:8 0" > /proc/scsi_tgt/groups/Default_iqn.2007-05.com.example\:storage.iscsi-scst-1/devicesThis will remove the LUN "4:0:0:8" from the target iqn.2007-05.com.example:storage.iscsi-scst-1.Deleting a group----------------Run the following command:echo "del_group Default_iqn.2007-05.com.example:storage.iscsi-scst-1" >/proc/scsi_tgt/scsi_tgtFor more information about LUN masking, refer to SCST README, section"Access and devices visibility management (LUN masking)".Creating targets using iscsi-scstd.conf---------------------------------------The easiest way to create targets is to define them in/etc/iscsi-scstd.conf. An example can be found in etc/iscsi-scstd.conf.You need to have this file under /etc/ before starting iSCSI-SCST.Assigning targets to specific initiators----------------------------------------In order to assign targets to specific initiators, you need to have/etc/initiators.allow  and /etc/initiators.deny. You can findexample files in etc/initiators.allow and etc/initiators.deny.Note that all targets are allowed to all initiators by default, so ifyou want to use /etc/initiators.allow, you will need to have/etc/initiators.deny that looks like this:ALL ALLThis will deny all initiators expect for those defined in /etc/initiators.allow.Useful examples of iscsi-scst-adm:Show a specific target:# iscsi-scst-adm --op show --tid=1QueuedCommands=0Show the configured parameters for a specific target:# iscsi-scst-adm --op show --tid=1 --sid=0InitialR2T=NoImmediateData=YesMaxConnections=1MaxRecvDataSegmentLength=2097152MaxXmitDataSegmentLength=131072MaxBurstLength=2097152FirstBurstLength=262144DefaultTime2Wait=2DefaultTime2Retain=0MaxOutstandingR2T=1DataPDUInOrder=YesDataSequenceInOrder=YesErrorRecoveryLevel=0HeaderDigest=NoneDataDigest=NoneOFMarker=NoIFMarker=NoOFMarkInt=RejectIFMarkInt=RejectBart Van AsscheErez ZilberVladislav Bolkhovitin


本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
第十八章、网络驱动器装置: iSCSI 服务器
iSCSI的用法
Linux下搭建iSCSI共享存储的方法 Linux
centos5.3 挂载 存储磁盘柜 分区
CentOS 6.3下配置iSCSI存储
iSCSI on Linux FC6
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服