della0887 发表于 2018-6-3 13:36:29

在vmware虚机上用iscsi协议建立多路径环境测试multipath (2)

安装iscsi软件
  yum -y installscsi-target-utils(target软件包)(还有其它类似的软件包,这里选择最常用的)
  yum -y installiscsi-initiator-utils(initiator软件包)
配置ISCSI target
  注意:配置iscsi target的最佳文档是scsi-target-utils软件包的README.iscsi文件,在目录/usr/share/doc/scsi-target-utils-1.0.24下。
启动iscsi target服务进程
  # service tgtd start
配置ISCSI target服务
  进程启动后会读配置文件/etc/tgt/targets.conf,把文件中设置的ISCSI target服务配置项启动。文件中的配置项也可以手动启动,为了更好的理解target配置,我们先用命令行手工配置target服务
用tgtadm命令手工配置target服务
  1.      配置target1
注意:不可以配置target0,原因不详
#tgtadm --lld iscsi --op new --mode target--tid 1 -T iqn.2017-03.centos-i1:sdb1
#tgtadm --lld iscsi --op delete --mode target--tid 2
  2.      查看已经配置的target1
# tgtadm --lld iscsi --op show --modetarget
Target 1: iqn.2017-03.centos-i1:sdb1
   System information:
       Driver: iscsi
       State: ready
   I_T nexus information:
   LUN information:
       LUN: 0
         Type: controller
         SCSI ID: IET   00010000
         SCSI SN: beaf10
         Size: 0 MB, Block size: 1
         Online: Yes
         Removable media: No
         Prevent removal: No
         Readonly: No
         Backing store type: null
         Backing store path: None
         Backing store flags:
   Account information:
ACL information:
可以看到LUN0在target创立后即自动生成,用于控制命令的传输,不可以删除
  1.      增加数据LUN
#tgtadm --lld iscsi --op new --mode logicalunit--tid 1 --lun 1 --backing-store /dev/sdb1
#tgtadm --lld iscsi --op delete --mode logicalunit--tid 1 --lun 1
  2.      查看已经配置的LUN
# tgtadm --lld iscsi--op show --mode target
Target 1: iqn.2017-03.centos-i1:sdb1
   System information:
       Driver: iscsi
       State: ready
    I_Tnexus information:
    LUNinformation:
       LUN: 0
         Type: controller
         SCSI ID: IET   00010000
         SCSI SN: beaf10
         Size: 0 MB, Block size: 1
         Online: Yes
         Removable media: No
         Prevent removal: No
         Readonly: No
         Backing store type: null
         Backing store path: None
         Backing store flags:
   Account information:
ACL information:
  3.      配置target,以接受initiators的访问请求
#tgtadm --lld iscsi --op bind --mode target--tid 1 -I ALL
#tgtadm --lld iscsi--op unbind --mode target --tid 1 -I ALL
#tgtadm --lld iscsi--op bind --mode target --tid 1 -I 192.168.136.101/103
#tgtadm --lld iscsi--op bind --mode target --tid 1 -I 192.168.136.101
#tgtadm --lld iscsi--op bind --mode target --tid 1 -I 192.168.136.102
#tgtadm --lld iscsi--op bind --mode target --tid 1 -I 192.168.136.103
  4.      查看target的访问请求控制
# tgtadm --lld iscsi --op show --mode target
Target 1: iqn.2017-03.centos-i1:sdb1
   System information:
       Driver: iscsi
       State: ready
    I_Tnexus information:
    LUNinformation:
       LUN: 0
         Type: controller
         SCSI ID: IET   00010000
         SCSI SN: beaf10
         Size: 0 MB, Block size: 1
         Online: Yes
         Removable media: No
         Prevent removal: No
         Readonly: No
         Backing store type: null
         Backing store path: None
         Backing store flags:
   Account information:
   ACLinformation:这里是关键点
      192.168.136.101/103
      192.0.2.229
ALL
  5.      查看并配置ISCSI Target的参数
#tgtadm --lld iscsi --mode target --opupdate --tid 1 --name MaxRecvDataSegmentLength --value 16384
# tgtadm --lld iscsi --op show --mode target --tid 1
MaxRecvDataSegmentLength=16384
MaxXmitDataSegmentLength=8192
HeaderDigest=None
DataDigest=None
InitialR2T=Yes
MaxOutstandingR2T=1
ImmediateData=Yes
FirstBurstLength=65536
MaxBurstLength=262144
DataPDUInOrder=Yes
DataSequenceInOrder=Yes
ErrorRecoveryLevel=0
IFMarker=No
OFMarker=No
DefaultTime2Wait=2
DefaultTime2Retain=20
OFMarkInt=Reject
IFMarkInt=Reject
MaxConnections=1
RDMAExtensions=Yes
TargetRecvDataSegmentLength=262144
InitiatorRecvDataSegmentLength=262144
MaxOutstandingUnexpectedPDUs=0

# tgtadm --lld iscsi --op show --mode target --tid 1
MaxRecvDataSegmentLength=8192
MaxXmitDataSegmentLength=8192
HeaderDigest=None
DataDigest=None
InitialR2T=Yes
MaxOutstandingR2T=1
ImmediateData=Yes
FirstBurstLength=65536
MaxBurstLength=262144
DataPDUInOrder=Yes
DataSequenceInOrder=Yes
ErrorRecoveryLevel=0
IFMarker=No
OFMarker=No
DefaultTime2Wait=2
DefaultTime2Retain=20
OFMarkInt=Reject
IFMarkInt=Reject
MaxConnections=1
RDMAExtensions=Yes
TargetRecvDataSegmentLength=262144
InitiatorRecvDataSegmentLength=262144
MaxOutstandingUnexpectedPDUs=0
  6.      其它内容,比如查看连接的initiator信息,用户名/密码
查看/usr/share/doc/scsi-target-utils-1.0.24/README.iscsi文件
编辑/etc/tgt/targets.conf文件永久配置target服务
  1.       编辑文件targets.conf,在文件尾部加入以下核心内容
<targetiqn.2017-03.centos-i1:target1>
    backing-store /dev/sdb

#    initiator-address ALL
    initiator-address 192.168.136.101
    initiator-address 192.168.136.102
    initiator-address 192.168.136.103
    initiator-address 192.168.20.101
    initiator-address 192.168.20.102
    initiator-address 192.168.20.103
    vendor_id lb
    product_id lb_iscsi
    product_rev 01
</target>

#注意:上面配置的是接受所有initiator的IO,在手册上这本是缺省行为,但是我的实验环境中却偶然遇到必须在文件中显式制定才行,否则就不接受所有的initiator IO!
   
  2.       重启tgtd服务
# service tgtd restart
Stopping SCSI targetdaemon:                              
Starting SCSI targetdaemon:                              
  3.       检查target服务配置
下面两条命令看到的内容是一致的。
# tgt-admin-show
# tgtadm --lld iscsi --op show--mode target
Tgt-admmin是linux SCSI target配置工具;Tgtadm是linux SCSI target管理工具。tgt-admin调用tgtadm来创建、删除和显示target。总体而言,tgtadm功能更加强大,但是tgt-admin在配置target方面有独有的优点。

  
页: [1]
查看完整版本: 在vmware虚机上用iscsi协议建立多路径环境测试multipath (2)