配置环境
虚拟机 | IP | 操作系统 |
---|---|---|
节点1 | 192.168.10.11 | centos 7.4 |
节点2 | 192.168.10.12 | centos 7.4 |
存储机 | 192.168.10.13 | centos 7.4 |
服务端配置
存储机上配置2块硬盘,将sdb作为共享磁盘
在共享磁盘上进行分区
- 输入fdisk /dev/sdb
- 依次输入 n→p→1→回车 +512M 回车,完成第一块磁盘划分
- 依次输入 n→p→2→回车 +512M 回车,完成第二块磁盘划分
- 依次输入 n→p→3→回车 +1024M 回车,完成第三块磁盘划分
- 依次输入 n→p→4→回车 回车 回车,完成第四块磁盘划分
存储机上安装必要的软件包
yum install epel-release
yum install scsi-target-utils
yum install iscsi-initiator-utils*
通过 linux 中的命令生成 IQN 编号
[root@localhost ~]# iscsi-iname
iqn.1994-05.com.redhat:d2572562bcd6
编辑配置文件
vi /etc/tgt/targets.conf
<target iqn.1994-05.com.redhat:d2572562bcd6>
backing-store /dev/sdb1
backing-store /dev/sdb2
backing-store /dev/sdb3
backing-store /dev/sdb4
</target>
启动服务
[root@localhost ~]# service tgtd start
[root@localhost ~]# chkconfig tgtd on
查看配置信息
[root@localhost ~]# tgtadm --lld iscsi --op show --mode target
Target 1: iqn.1994-05.com.redhat:d2572562bcd6
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
SWP: No
Thin-provisioning: No
Backing store type: null
Backing store path: None
Backing store flags:
LUN: 1
Type: disk
SCSI ID: IET 00010001
SCSI SN: beaf11
Size: 537 MB, Block size: 512
Online: Yes
Removable media: No
Prevent removal: No
Readonly: No
SWP: No
Thin-provisioning: No
Backing store type: rdwr
Backing store path: /dev/sdb1
Backing store flags:
LUN: 2
Type: disk
SCSI ID: IET 00010002
SCSI SN: beaf12
Size: 537 MB, Block size: 512
Online: Yes
Removable media: No
Prevent removal: No
Readonly: No
SWP: No
Thin-provisioning: No
Backing store type: rdwr
Backing store path: /dev/sdb2
Backing store flags:
LUN: 3
Type: disk
SCSI ID: IET 00010003
SCSI SN: beaf13
Size: 1074 MB, Block size: 512
Online: Yes
Removable media: No
Prevent removal: No
Readonly: No
SWP: No
Thin-provisioning: No
Backing store type: rdwr
Backing store path: /dev/sdb3
Backing store flags:
LUN: 4
Type: disk
SCSI ID: IET 00010004
SCSI SN: beaf14
Size: 3220 MB, Block size: 512
Online: Yes
Removable media: No
Prevent removal: No
Readonly: No
SWP: No
Thin-provisioning: No
Backing store type: rdwr
Backing store path: /dev/sdb4
Backing store flags:
Account information:
ACL information:
ALL
客户端配置
以下操作在节点1、2上都需执行
安装软件包
yum install iscsi-initiator-utils*
发现存储
[root@localhost ~]# iscsiadm -m discovery -t st -p 192.168.10.13
192.168.10.13:3260,1 iqn.1994-05.com.redhat:d2572562bcd6
登录iscsi存储
[root@localhost ~]# iscsiadm -m node -T iqn.1994-05.com.redhat:d2572562bcd6 -p 192.168.10.13 -l
Logging in to [iface: default, target: iqn.1994-05.com.redhat:d2572562bcd6, portal: 192.168.10.13,3260] (multiple)
Login to [iface: default, target: iqn.1994-05.com.redhat:d2572562bcd6, portal: 192.168.10.13,3260] successful.
查看存储挂载情况
[root@localhost ~]# fdisk -l|grep "Disk /dev/sd"
Disk /dev/sda: 53.7 GB, 53687091200 bytes, 104857600 sectors
Disk /dev/sdb: 536 MB, 536870912 bytes, 1048576 sectors
Disk /dev/sdc: 536 MB, 536870912 bytes, 1048576 sectors
Disk /dev/sdd: 1073 MB, 1073741824 bytes, 2097152 sectors
Disk /dev/sde: 3220 MB, 3220176896 bytes, 6289408 sectors
开启自动登陆iSCSI
[root@localhost ~]# iscsiadm -m node –T iqn.1994-05.com.redhat:d2572562bcd6 -p 192.168.10.13 --op update -n node.startup -v automatic