配置initiator

  1. 1.       在initiator主机上安装initiator软件

# yum -y install iscsi-initiator-utils

  1. 2.       在initiator主机上发现并连接target存储

# iscsiadm -m discovery -t sendtargets -p192.168.136.101

#发现的target服务,信息会写入/var/lib/iscsi 目录下

# tree /var/lib/iscsi/   #查看target信息

 

  1. 3.       启动iscsid 服务

# /etc/init.d/iscsid  start     #先启动iscsid 服务            

# /etc/init.d/iscsi  start      #再启动iscsi服务 该服务是根据iscsid服务信息/var/lib/iscsi/ 来识别设备的

  1. 4.       在initiator主机上检查分配给iscsi target设备的设备文件名

# lsblk

# tree /var/lib/iscsi/

检查iscsi磁盘配置, 以及卸载和登录scsi设备

# lsblk

# tree /var/lib/iscsi/

# iscsiadm -m node -Tiqn.2017-03.centos-i1:target1 –u  #卸载,这里的案例是双路径

Logging out of session[sid: 1, target: iqn.2017-03.centos-i1:target1, portal: 192.168.20.101,3260]

Logging out of session[sid: 2, target: iqn.2017-03.centos-i1:target1, portal: 192.168.136.101,3260]

Logout of [sid: 1, target:iqn.2017-03.centos-i1:target1, portal: 192.168.20.101,3260] successful.

Logout of [sid: 2, target:iqn.2017-03.centos-i1:target1, portal: 192.168.136.101,3260] successful.

# lsblk  #验证设备是否logout

# iscsiadm -m node -Tiqn.2017-03.centos-i1:target1 –l #重新登录,这里的案例是双路径

Logging in to [iface:default, target: iqn.2017-03.centos-i1:target1, portal: 192.168.20.101,3260](multiple)

Logging in to [iface:default, target: iqn.2017-03.centos-i1:target1, portal: 192.168.136.101,3260](multiple)

Login to [iface: default,target: iqn.2017-03.centos-i1:target1, portal: 192.168.20.101,3260] successful.

Login to [iface: default,target: iqn.2017-03.centos-i1:target1, portal: 192.168.136.101,3260]successful.


 

使用iscsi设备,并做写入操作测试

  1. 1.        磁盘分区(方法二选一)

# fdisk /dev/sdb               

# parted /dev/sdb

  1. 2.        建文件系统并使用

# mkfs.ext4 /dev/sdb1

# mkdir /iscsi              #挂载分区 到新建目录/iscsi

# mount /dev/sdb1 /iscsi/

# cp /home/lb/fio* /iscsi

在实验过程中,遇到如果在target端做过sdb分区,initiator看不到分区的情况。需要按照target端的参数重新分区,才看到分区里的数据。