一、什么是iscsi
iSCSI技术是一种由IBM公司研究开发的,是一个供硬件设备使用的可以在IP协议的上层运行的SCSI指令集,这种指令集合可以实现在IP网络上运行SCSI协议,使其能够在诸如高速千兆以太网上进行路由选择。iSCSI技术是一种新储存技术,该技术是将现有SCSI接口与以太网络(Ethernet)技术结合,使服务器可与使用IP网络的储存装置互相交换资料。
二、需求分析
最近在做虚拟化,需要通过一个主机挂载来自两个iscsi服务器的targets,如图:
三、实现思路
问题:刚开始觉得这个应该问题不大,挂载第一台iscsi服务器的时候没有碰到问题,但是在挂载第二台iscsi时,发现怎样都无法挂载,挂载报错。
最终找到了正确的解决方法,在centos7/RHEL7上挂载时,两台iscsi服务器端的target命名需要一致,下面进行搭建演示:
系统:centos 7.2
iscsi客户端:192.168.1.156
iscsi服务端:192.168.1.157
iscsi服务端:192.168.1.158
首先要确保3台服务器的selinux和firewalld关闭
[root@iscsi-client ~]# setenforce 0 ; systemctl stop firewalld ; systemctl disable firewalld
iscsi服务端配置如下:
[root@iscsi-server1 ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT fd0 2:0 1 4K 0 disk sda 8:0 0 20G 0 disk ├─sda1 8:1 0 500M 0 part /boot └─sda2 8:2 0 19.5G 0 part ├─centos-root 253:0 0 17.5G 0 lvm / └─centos-swap 253:1 0 2G 0 lvm [SWAP] sdb 8:16 0 10G 0 disk sr0 11:0 1 4G 0 rom
使用sdb作为target。为sdb进行分区并使用lvm进行发布出去,使用lvm的好处是后期便于扩展,在rhel7和centos7中,因为采用的是xfs文件系统,
lvm只能扩展,不能缩小,这点要牢记。
[root@iscsi-server1 ~]# fdisk /dev/sdb Welcome to fdisk (util-linux 2.23.2). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Device does not contain a recognized partition table Building a new DOS disklabel with disk identifier 0x966a38a7. Command (m for help): n Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): Using default response p Partition number (1-4, default 1): First sector (2048-20971519, default 2048): Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-20971519, default 20971519): Using default value 20971519 Partition 1 of type Linux and of size 10 GiB is set Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. [root@iscsi-server1 ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT fd0 2:0 1 4K 0 disk sda 8:0 0 20G 0 disk ├─sda1 8:1 0 500M 0 part /boot └─sda2 8:2 0 19.5G 0 part ├─centos-root 253:0 0 17.5G 0 lvm / └─centos-swap 253:1 0 2G 0 lvm [SWAP] sdb 8:16 0 10G 0 disk └─sdb1 8:17 0 10G 0 part sr0 11:0 1 4G 0 rom
以上就为sdb做了分区,接下来将sdb1创建为独立的lvm
# 创建卷组 [root@iscsi-server1 ~]# vgcreate vg_iscsi_1_156 /dev/sdb1 Physical volume "/dev/sdb1" successfully created Volume group "vg_iscsi_1_156" successfully created # 创建逻辑分区 [root@iscsi-server1 ~]# lvcreate -l +2559 -n lv_iscsi_1_156 vg_iscsi_1_156 Logical volume "lv_iscsi_1_156" created. [root@iscsi-server1 ~]# lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert root centos -wi-ao---- 17.47g swap centos