在之前文章《multipath多路径实验01-构建iSCSI模拟环境》中,已经介绍了如何构建iSCSI模拟环境(RHEL6),但在RHEL7中已经不适用,本文记录下新的配置方法。
环境:RHEL 7.3
1.LVM创建
在RHEL7.3中,对于lvm操作部分与之前RHEL6版本没有区别,还是创建pv,vg,lv的方法,命令参考如下:
pvcreate /dev/sdb
vgcreate vg_storage /dev/sdb
lvcreate -L 1g -n lv_lun1 vg_storage
lvcreate -L 1g -n lv_lun2 vg_storage
lvcreate -L 1g -n lv_lun3 vg_storage
lvcreate -L 40g -n lv_lun4 vg_storage
lvcreate -L 10g -n lv_lun5 vg_storage
lvcreate -L 10g -n lv_lun6 vg_storage
lvcreate -L 10g -n lv_lun7 vg_storage
lvcreate -L 16g -n lv_lun8 vg_storage
最终可以看到新建的lv信息:
[root@Storage-B yum.repos.d]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
home rhel -wi-ao---- 23.33g
root rhel -wi-ao---- 47.79g
swap rhel -wi-ao---- 7.88g
lv_lun1 vg_storage -wi-a----- 1.00g
lv_lun2 vg_storage -wi-a----- 1.00g
lv_lun3 vg_storage -wi-a----- 1.00g
lv_lun4 vg_storage -wi-a----- 40.00g
lv_lun5 vg_storage -wi-a----- 10.00g
lv_lun6 vg_storage -wi-a----- 10.00g
lv_lun7 vg_storage -wi-a----- 10.00g
lv_lun8 vg_storage -wi-a----- 16.00g
2.服务端配置
之前在RHEL6中安装的iscsi服务端rpm包的名字是:scsi-target-utils,这在RHEL7中变成了targetd、targetcli这两个包。
**2.1 使用yum安装targetd和targetcli**
yum -y install targetd targetcli
systemctl status targetd
systemctl start targetd
systemctl enable targetd
systemctl list-unit-files|grep targetd
同时确认targetd服务启动状态和开启启动。
2.2 使用targetcli创建设备
targetcli进入命令行,cd到/backstores/block 目录下,创建设备:
create disk1 /dev/mapper/vg_storage-lv_lun1
create disk2 /dev/mapper/vg_storage-lv_lun2
create disk3 /dev/mapper/vg_storage-lv_lun3
create disk4 /dev/mapper/vg_storage-lv_lun4
create disk5 /dev/mapper/vg_storage-lv_lun5
create disk6 /dev/mapper/vg_storage-lv_lun6
create disk7 /dev/mapper/vg_storage-lv_lun7
create disk8 /dev/mapper/vg_storage-lv_lun8
创建完成,可以成功看到:
/backstores/block> ls
o- block ...................................................................................................... [Storage Objects: 8]
o- disk1 ........................................................ [/dev/mapper/vg_storage-lv_lun1 (1.0GiB) write-thru deactivated]
o- disk2 ........................................................ [/dev/mapper/vg_storage-lv_lun2 (1.0GiB) write-thru deactivated]
o- disk3 ........................................................ [/dev/mapper/vg_storage-lv_lun3 (1.0GiB) write-thru deactivated]
o- disk4 ....................................................... [/dev/mapper/vg_storage-lv_lun4 (40.0GiB) write-thru deactivated]
o- disk5 ....................................................... [/dev/mapper/vg_storage-lv_lun5 (10.0GiB) write-thru deactivated]
o- disk6 ....................................................... [/dev/mapper/vg_storage-lv_lun6 (10.0GiB) write-thru deactivated]
o- disk7 ....................................................... [/dev/mapper/vg_storage-lv_lun7 (10.0GiB) write-thru deactivated]
o- disk8 ....................................................... [/dev/mapper/vg_storage-lv_lun8 (16.0GiB) write-thru deactivated]
2.3 使用targetcli创建iqn和LUN
然后cd到/iscsi目录下,创建iqn;cd到/iscsi/iqn.20...0be/tpg1/luns下创建LUN,参考命令如下:
cd /iscsi
create
cd /iscsi/iqn.20...0be/tpg1/luns
create /backstores/block/disk1
create /backstores/block/disk2
create /backstores/block/disk3
create /backstores/block/disk4
create /backstores/block/disk5
create /backstores/block/disk6
create /backstores/block/disk7
create /backstores/block/disk8
实际执行过程如下:
/backstores/block> cd /iscsi
/iscsi> ls
o- iscsi .............................................................................................................. [Targets: 0]
/iscsi> create
Created target iqn.2003-01.org.linux-iscsi.storage-b.x8664:sn.46b1dc2750be.
Created TPG 1.
Global pref auto_add_default_portal=true
Created default portal listening on all IPs (0.0.0.0), port 3260.
/iscsi> ls
o- iscsi .............................................................................................................. [Targets: 1]
o- iqn.2003-01.org.linux-iscsi.storage-b.x8664:sn.46b1dc2750be ......................................................... [TPGs: 1]
o- tpg1 ................................................................................................. [no-gen-acls, no-auth]
o- acls ............................................................................................................ [ACLs: 0]
o- luns ............................................................................................................ [LUNs: 0]
o- portals ...................................................................................................... [Portals: 1]
o- 0.0.0.0:3260 ....................................................................................................... [OK]
/iscsi/iqn.20...0be/tpg1/luns> ls
o- luns .................................................................................................................. [LUNs: 8]
o- lun0 ........................................................................... [block/disk1 (/dev/mapper/vg_storage-lv_lun1)]
o- lun1 ........................................................................... [block/disk2 (/dev/mapper/vg_storage-lv_lun2)]
o- lun2 ........................................................................... [block/disk3 (/dev/mapper/vg_storage-lv_lun3)]
o- lun3 ........................................................................... [block/disk4 (/dev/mapper/vg_storage-lv_lun4)]
o- lun4 ........................................................................... [block/disk5 (/dev/mapper/vg_storage-lv_lun5)]
o- lun5 ........................................................................... [block/disk6 (/dev/mapper/vg_storage-lv_lun6)]
o- lun6 ........................................................................... [block/disk7 (/dev/mapper/vg_storage-lv_lun7)]
o- lun7 ........................................................................... [block/disk8 (/dev/mapper/vg_storage-lv_lun8)]
/iscsi/iqn.20...0be/tpg1/luns>
2.4 使用targetcli创建acls
cd到acls目录下,创建client;然后cd到portals目录下创建portals, 参考命令如下:
cd /iscsi/iqn.20...0be/tpg1/acls
create iqn.2003-01.org.linux-iscsi.storage-b.x8664:sn.46b1dc2750be:client
cd /iscsi/iqn.20...0be/tpg1/portals
delete 0.0.0.0 3260
create 10.10.1.21
create 10.10.2.21
实际执行过程如下:
/iscsi/iqn.20.../tpg1/portals> pwd
/iscsi/iqn.2003-01.org.linux-iscsi.storage-b.x8664:sn.46b1dc2750be/tpg1/portals
/iscsi/iqn.20.../tpg1/portals> ls
o- portals ............................................................................................................ [Portals: 2]
o- 10.10.1.21:3260 .......................................................................................................... [OK]
o- 10.10.2.21:3260 .......................................................................................................... [OK]
2.5 使用targetcli查看当前配置信息
在/下执行ls,或者ls /查看当前配置信息:
/iscsi/iqn.20.../tpg1/portals> ls /
o- / ......................................................................................................................... [...]
o- backstores .............................................................................................................. [...]
| o- block .................................................................................................. [Storage Objects: 8]
| | o- disk1 ...................................................... [/dev/mapper/vg_storage-lv_lun1 (1.0GiB) write-thru activated]
| | o- disk2 ...................................................... [/dev/mapper/vg_storage-lv_lun2 (1.0GiB) write-thru activated]
| | o- disk3 ...................................................... [/dev/mapper/vg_storage-lv_lun3 (1.0GiB) write-thru activated]
| | o- disk4 ..................................................... [/dev/mapper/vg_storage-lv_lun4 (40.0GiB) write-thru activated]
| | o- disk5 ..................................................... [/dev/mapper/vg_storage-lv_lun5 (10.0GiB) write-thru activated]
| | o- disk6 ..................................................... [/dev/mapper/vg_storage-lv_lun6 (10.0GiB) write-thru activated]
| | o- disk7 ..................................................... [/dev/mapper/vg_storage-lv_lun7 (10.0GiB) write-thru activated]
| | o- disk8 ..................................................... [/dev/mapper/vg_storage-lv_lun8 (16.0GiB) write-thru activated]
| o- fileio ................................................................................................. [Storage Objects: 0]
| o- pscsi .................................................................................................. [Storage Objects: 0]
| o- ramdisk ................................................................................................ [Storage Objects: 0]
o- iscsi ............................................................................................................ [Targets: 1]
| o- iqn.2003-01.org.linux-iscsi.storage-b.x8664:sn.46b1dc2750be ....................................................... [TPGs: 1]
| o- tpg1 ............................................................................................... [no-gen-acls, no-auth]
| o- acls .......................................................................................................... [ACLs: 1]
| | o- iqn.2003-01.org.linux-iscsi.storage-b.x8664:sn.46b1dc2750be:client ................................... [Mapped LUNs: 8]
| | o- mapped_lun0 ................................................................................. [lun0 block/disk1 (rw)]
| | o- mapped_lun1 ................................................................................. [lun1 block/disk2 (rw)]
| | o- mapped_lun2 ................................................................................. [lun2 block/disk3 (rw)]
| | o- mapped_lun3 ................................................................................. [lun3 block/disk4 (rw)]
| | o- mapped_lun4 ................................................................................. [lun4 block/disk5 (rw)]
| | o- mapped_lun5 ................................................................................. [lun5 block/disk6 (rw)]
| | o- mapped_lun6 ................................................................................. [lun6 block/disk7 (rw)]
| | o- mapped_lun7 ................................................................................. [lun7 block/disk8 (rw)]
| o- luns .......................................................................................................... [LUNs: 8]
| | o- lun0 ................................................................... [block/disk1 (/dev/mapper/vg_storage-lv_lun1)]
| | o- lun1 ................................................................... [block/disk2 (/dev/mapper/vg_storage-lv_lun2)]
| | o- lun2 ................................................................... [block/disk3 (/dev/mapper/vg_storage-lv_lun3)]
| | o- lun3 ................................................................... [block/disk4 (/dev/mapper/vg_storage-lv_lun4)]
| | o- lun4 ................................................................... [block/disk5 (/dev/mapper/vg_storage-lv_lun5)]
| | o- lun5 ................................................................... [block/disk6 (/dev/mapper/vg_storage-lv_lun6)]
| | o- lun6 ................................................................... [block/disk7 (/dev/mapper/vg_storage-lv_lun7)]
| | o- lun7 ................................................................... [block/disk8 (/dev/mapper/vg_storage-lv_lun8)]
| o- portals .................................................................................................... [Portals: 2]
| o- 10.10.1.21:3260 .................................................................................................. [OK]
| o- 10.10.2.21:3260 .................................................................................................. [OK]
o- loopback ......................................................................................................... [Targets: 0]
/iscsi/iqn.20.../tpg1/portals>
最后配置防火墙策略,或者直接关闭防火墙,建议后者,视具体要求而定。
--防火墙添加放行tcp 3260端口:
firewall-cmd --permanent --add-port=3260/tcp
firewall-cmd --reload
--关闭防火墙:
systemctl disable firewalld
systemctl stop firewalld
3.客户端配置
**3.1 使用yum安装iscsi-initiator-utils**
yum -y install iscsi-initiator-utils
3.2 编辑/etc/iscsi/initiatorname.iscsi
vi /etc/iscsi/initiatorname.iscsi
#InitiatorName=iqn.1994-05.com.redhat:babc7da33c48
InitiatorName=iqn.2003-01.org.linux-iscsi.storage-b.x8664:sn.46b1dc2750be:client
注释之前的示例,添加一行实际的配置。
3.3 使用iscsiadm发现可用存储设备并登陆连接
iscsiadm -m discovery -t st -p 10.10.1.21
[root@db92 yum.repos.d]# iscsiadm -m discovery -t st -p 10.10.1.21
10.10.1.21:3260,1 iqn.2003-01.org.linux-iscsi.storage-b.x8664:sn.46b1dc2750be
10.10.2.21:3260,1 iqn.2003-01.org.linux-iscsi.storage-b.x8664:sn.46b1dc2750be
登陆连接:
iscsiadm -m node -T iqn.2003-01.org.linux-iscsi.storage-b.x8664:sn.46b1dc2750be -p 10.10.1.21 --login
iscsiadm -m node -T iqn.2003-01.org.linux-iscsi.storage-b.x8664:sn.46b1dc2750be -p 10.10.2.21 --login
此时使用fdisk -l 查看已经正常显示所有设备:
[root@db90 ~]# fdisk -l
Disk /dev/sda: 85.9 GB, 85899345920 bytes, 167772160 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x0001b841
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 167772159 82836480 8e Linux LVM
Disk /dev/mapper/rhel-root: 51.3 GB, 51308920832 bytes, 100212736 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/rhel-swap: 8455 MB, 8455716864 bytes, 16515072 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/rhel-home: 25.1 GB, 25052577792 bytes, 48930816 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/sdb: 1073 MB, 1073741824 bytes, 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 33550336 bytes
Disk /dev/sdc: 1073 MB, 1073741824 bytes, 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 33550336 bytes
Disk /dev/sdd: 1073 MB, 1073741824 bytes, 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 33550336 bytes
Disk /dev/sde: 1073 MB, 1073741824 bytes, 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 33550336 bytes
Disk /dev/sdg: 1073 MB, 1073741824 bytes, 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 33550336 bytes
Disk /dev/sdf: 42.9 GB, 42949672960 bytes, 83886080 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 33550336 bytes
Disk /dev/sdh: 1073 MB, 1073741824 bytes, 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 33550336 bytes
Disk /dev/sdi: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 33550336 bytes
Disk /dev/sdj: 42.9 GB, 42949672960 bytes, 83886080 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 33550336 bytes
Disk /dev/sdl: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 33550336 bytes
Disk /dev/sdk: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 33550336 bytes
Disk /dev/sdn: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 33550336 bytes
Disk /dev/sdm: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 33550336 bytes
Disk /dev/sdo: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 33550336 bytes
Disk /dev/sdp: 17.2 GB, 17179869184 bytes, 33554432 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 33550336 bytes
Disk /dev/sdq: 17.2 GB, 17179869184 bytes, 33554432 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 33550336 bytes
[root@db90 ~]#
由于是两条链路,所以fdisk看到的存储LUN是两倍,后续再使用多路径软件聚合即可使用。
RHEL7 配置iSCSI模拟环境的更多相关文章
-
multipath多路径实验01-构建iscsi模拟环境
multipath多路径实验01-构建iscsi模拟环境 前几天跟同事网上闲聊技术,吐槽之前自己没有配置过多路径的经历,虽然多路径的配置过程很简单,职责划分也应是主机或存储工程师来搞定,DBA只需要直 ...
-
配置gem5-gpu模拟环境
// 系统:ubuntu 14.04,显卡:支持CUDA的显卡.建议换aliyun的源!先clean软件源再update.// 在Ubuntu 16.04上试过,配好环境变量,编译出错(把14.04上 ...
-
Cluster基础(一):配置iSCSI服务、编写udev规则、配置并访问NFS共享、部署Multipath多路径环境
一.配置iSCSI服务 目标: 本案例要求先搭建好一台iSCSI服务器,并将整个磁盘共享给客户端: 虚拟机添加新的磁盘 将新添加的磁盘分区并创建两个逻辑卷 逻辑卷名称分别为:/dev/myvg/isc ...
-
CentOS 6.5下配置iSCSI网络存储
一.简介 iSCSI(internet SCSI)技术由IBM公司研究开发,是一个供硬件设备使用的.可以在IP协议的上层运行的SCSI指令集,这种指令集合可以实现在IP网络上运行 SCSI协议,使其能 ...
-
CentOS 6.3下配置iSCSI网络存储
一.简介 iSCSI(internet SCSI)技术由IBM公司研究开发,是一个供硬件设备使用的.可以在IP协议的上层运行的SCSI指令集,这种指令集合可以实现在IP网络上运行SCSI协议,使其能够 ...
-
配置iSCSI部署网络存储
iSCSI( Internet Small Computer System Interface 互联网小型计算机系统接口)是由IBM 下属的两大研发机构一一加利福尼亚AImaden和以色列Haifa研 ...
-
RHEL7配置端口转发和地址伪装
说明:这里是Linux服务综合搭建文章的一部分,本文可以作为Linux上使用firewalld做端口转发和地址伪装以及外网访问内网的参考. 注意:这里所有的标题都是根据主要的文章(Linux基础服务搭 ...
-
vim配置python开发环境
vim配置python开发环境 一.安装vim sudo apt-get install vim 二.vim基础配置 #Centos6.5 /usr/share/vim/vim72 vi /etc/v ...
-
Ubuntu配置Android编译环境
1.Ubuntu安装 VMware安装ubuntu之后,安装Vmware tools: 1.安装完ubuntu后,VMware Workstation菜单:虚拟机-->安装 Vmware Too ...
随机推荐
-
Javascript运用函数计算正方形的面积
<html> <head> <meta http-equiv="Content-Type" content="text/html; char ...
-
[HTML/HTML5]4 使用文本
4.1 组织文本 在已经采用结构化方式将页面划分为多个关键内容区域(content area)并添加相应的标题之后,就可以进一步对这些内容区域中的文本进行组织. 4.1.1 段落 p元素的具体功能 ...
-
如何将APP部署在阿里云服务器
1,APP应用需要什么样的云服务器? 为了帮助大家了解如何使用阿里云云服务器及相关应用,阿里云的移动云团队开发了一个简单的APP应用:移动云相册,其中使用了ECS主要用作部署云相册的API服务(图片信 ...
-
canvas初体验之加载图片
上一篇的介绍主要是画一些基本的图案,这一篇主要是加载图案. canvas加载图片主要分为两个步骤: 1.获取图片资源. 2.将图片资源画到画布上. 1.1获取图片资源,canvasAPI为我们提供了多 ...
-
MVC小例子
[约定胜于配置] 1. 右键Mode数据层添加新建项,用linq连接数据库 (不要在控制层上直接操控linq,要在数据层新建一个类,来对数据库进行操作) 2. 右键Mode数据层添加类,来完成对数据库 ...
-
网易云数据结构- Maximum Subsequence Sum
题目 题目地址 思路 显然是最大子列和的进化版,那就先思考下经典的最大子列和.这也是道思维题,啥算法也没用到,全是思维技巧,真心不知道考试遇到这种题该怎么办了. 存放答案的一个类,我把它看成一个袋子, ...
-
PhpStorm 10.0注册
ntelliJ IDEA开源社区 提供了如下通用激活方法:注册时选择License server,填http://idea.lanyus.com/,然后点击 OK,再点一次OK,就搞定了.注意http ...
-
unity -- Time类(持续更新中)
2018年了,新年总是会制定很多具体目标和计划,不管能否坚持去完成,初衷和决心总是要有的.本年第一篇博客终于开始下笔了,先立一些今年和公司业务无关的的flag: 1.希望每月或两月能看一套蛮牛游戏上的 ...
-
lookup.go
{ continue } addr := net.JoinHostPort(lp.Info.BroadcastAddress, strconv. ...
-
逻辑回归(logic regression)的分类梯度下降
首先明白一个概念,什么是逻辑回归:所谓回归就是拟合,说明x是连续的:逻辑呢?就是True和False,也就是二分类:逻辑回归即使就是指对于二分类数据的拟合(划分). 那么什么是模型呢?模型其实就是函数 ...