RHEL7 配置iSCSI模拟环境
在之前文章《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 ...
随机推荐
- weichat Small 程序
微信小程序教程用什么语言 ? 答:php java html5 css, 咫尺微页很棒可以自制 html 它是一套自有的语言(暂且叫 WeLang),使用 WeLang 开发出来的页面. 一个微信页 ...
- Hadoop生态圈-Cloudera Manager扫盲篇
Hadoop生态圈-Cloudera Manager扫盲篇 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 在讨论CDH.cloueramamager之前,我要问大家几个问题: 1& ...
- Python全栈问答小技巧_2
Python全栈测试题(二) 作者:尹正杰 声明:答案如有偏差,欢迎指正!欢迎加入高级运维工程师之路:598432640 本文答题用的Python版本是:Python 3.5.2,请知晓! 1. 计算 ...
- redis的入门篇---五种数据类型及基本操作
查看所有的key keys * 清空所有的key flushall 检查key是否存在 exists key 设置已存在的key的时长 expire key //设置key为10s 查看key还剩多少 ...
- bootstrap中模态框的使用
1.代码: <%--登录模态框--%> <li><a href="#" data-toggle="modal" data-targ ...
- OSI七层模型与TCP/IP四层模型
OSI七层模型与TCP/IP四层模型 OSI模型(Open System Interconnection Reference Model,缩写为OSI),全名“开放式系统互联通信参考模型”,是一个试图 ...
- IDEA不生成WAR包,报错
com.intellij.javaee.oss.admin.jmx.JmxAdminException: com.intellij.execution.ExecutionExceptionProjec ...
- android ListView 分页加载数据
1.mainActivity <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" ...
- wcf事务
wcf服务 using System; using System.Collections.Generic; using System.Linq; using System.Runtime.Serial ...
- python技巧 switch case语句
不同于C语言和SHELL,python中没有switch case语句,关于为什么没有,官方的解释是这样的 使用Python模拟实现的方法: def switch_if(fun, x, y): ...