Linux系统配置iscsi存储

一、创建 LVM

[[email protected] ~]# pvcreate /dev/sdc1

[[email protected] ~]# vgcreate vglabstor1 /dev/sdc1
  Volume group "vglabstor1" successfully created

[[email protected] ~]# lvcreate -l 100%FREE -n lvlabstor1 vglabstor1
  Logical volume "lvlabstor1" created.

[[email protected] ~]# lvscan
  ACTIVE '/dev/cl/swap' [2.00 GiB] inherit
  ACTIVE '/dev/cl/root' [46.50 GiB] inherit
  ACTIVE '/dev/vglabstor1/lvlabstor1' [80.00 GiB] inherit

[[email protected] ~]# mkfs.xfs /dev/vglabstor1/lvlabstor1
meta-data=/dev/vglabstor1/lvlabstor1 isize=512 agcount=4, agsize=5242624 blks
         = sectsz=512 attr=2, projid32bit=1
         = crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=20970496, imaxpct=25
         = sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=10239, version=2
         = sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0

[[email protected] ~]# mkdir /labstor1

[[email protected] ~]# mount /dev/vglabstor1/lvlabstor1 /labstor1/

二、安装配置 iscsi target

1.安装 targetcli

[[email protected] ~]# uname -r
3.10.0-514.el7.x86_64

[[email protected] ~]# cat /etc/redhat-release 
CentOS Linux release 7.3.1611 (Core) 

[[email protected] ~]# yum install targetcli

2.配置 targetcli

[[email protected] ~]# targetcli
targetcli shell version 2.1.fb46
Copyright 2011-2013 by Datera, Inc and others.
For help on commands, type 'help'.

/backstores> cd fileio
/backstores/fileio> create disk01 /labstor1/disk01.img 1G
Created fileio disk01 with size 1073741824
/backstores/fileio> create disk02 /labstor1/disk02.img 30G
Created fileio disk02 with size 32212254720
/backstores/fileio> ls /
o- / ...................................................................................................................... [...]
  o- backstores ........................................................................................................... [...]
  | o- block ............................................................................................... [Storage Objects: 0]
  | o- fileio .............................................................................................. [Storage Objects: 2]
  | | o- disk01 .......................................................... [/labstor1/disk01.img (1.0GiB) write-back deactivated]
  | | | o- alua ................................................................................................ [ALUA Groups: 1]
  | | |   o- default_tg_pt_gp .................................................................... [ALUA state: Active/optimized]
  | | o- disk02 ......................................................... [/labstor1/disk02.img (30.0GiB) write-back deactivated]
  | |   o- alua ................................................................................................ [ALUA Groups: 1]
  | |     o- default_tg_pt_gp .................................................................... [ALUA state: Active/optimized]
  | o- pscsi ............................................................................................... [Storage Objects: 0]
  | o- ramdisk ............................................................................................. [Storage Objects: 0]
  o- iscsi ......................................................................................................... [Targets: 1]
  | o- iqn.2018-05.storage.kvm.com:stor1 .............................................................................. [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]
  o- loopback ...................................................................................................... [Targets: 0]
/backstores/fileio> cd /iscsi/
/iscsi> ls
o- iscsi ........................................................................................................... [Targets: 1]
  o- iqn.2018-05.storage.kvm.com:stor1 ................................................................................ [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> cd iqn.2018-05.storage.kvm.com:stor1/tpg1/luns
/iscsi/iqn.20...or1/tpg1/luns> create /backstores/fileio/disk01
Created LUN 0.
/iscsi/iqn.20...or1/tpg1/luns> create /backstores/fileio/disk02
Created LUN 1.
/iscsi/iqn.20...or1/tpg1/luns> ls
o- luns ............................................................................................................... [LUNs: 2]
  o- lun0 ............................................................. [fileio/disk01 (/labstor1/disk01.img) (default_tg_pt_gp)]
  o- lun1 ............................................................. [fileio/disk02 (/labstor1/disk02.img) (default_tg_pt_gp)]
/iscsi/iqn.20...or1/tpg1/acls> create iqn.1994-05.com.redhat:kvm
Created Node ACL for iqn.1994-05.com.redhat:kvm
Created mapped LUN 1.
Created mapped LUN 0.
/iscsi/iqn.20...or1/tpg1/acls> create iqn.1994-05.com.redhat:node2
Created Node ACL for iqn.1994-05.com.redhat:node2
Created mapped LUN 1.
Created mapped LUN 0.
/iscsi/iqn.20...or1/tpg1/acls> ls
o- acls ............................................................................................................... [ACLs: 2]
  o- iqn.1994-05.com.redhat:kvm ................................................................................ [Mapped LUNs: 2]
  | o- mapped_lun0 .................................................................................... [lun0 fileio/disk01 (rw)]
  | o- mapped_lun1 .................................................................................... [lun1 fileio/disk02 (rw)]
  o- iqn.1994-05.com.redhat:node2 .............................................................................. [Mapped LUNs: 2]
    o- mapped_lun0 .................................................................................... [lun0 fileio/disk01 (rw)]
    o- mapped_lun1 .................................................................................... [lun1 fileio/disk02 (rw)

三、客户端 initiator 连接 target

1.检查软件是否安装及查看 initiatorname 名称

[[email protected] ~]# rpm -qa |grep iscsi
libiscsi-1.9.0-7.el7.x86_64
libvirt-daemon-driver-storage-iscsi-3.9.0-14.el7_5.2.x86_64
iscsi-initiator-utils-6.2.0.873-35.el7.x86_64
iscsi-initiator-utils-iscsiuio-6.2.0.873-35.el7.x86_64

[[email protected] ~]# rpm -qa |grep iscsi
libiscsi-1.9.0-7.el7.x86_64
iscsi-initiator-utils-iscsiuio-6.2.0.874-4.el7.x86_64
iscsi-initiator-utils-6.2.0.874-4.el7.x86_64
libvirt-daemon-driver-storage-iscsi-3.2.0-14.el7_4.9.x86_64

[[email protected] ~]# vim /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.1994-05.com.redhat:node2

[[email protected] ~]# cat /etc/iscsi/initiatorname.iscsi 
InitiatorName=iqn.1994-05.com.redhat:kvm

2.检查是否可以发现

[[email protected] ~]# iscsiadm --mode discovery --type sendtargets --portal 172.16.216.167
172.16.216.167:3260,1 iqn.2018-05.storage.kvm.com:stor1

3.测试挂载设备

[[email protected] ~]# iscsiadm -d2 -m node --login     #<--登陆节点
iscsiadm: Max file limits 1024 4096
iscsiadm: libvirt-iface-08137b06: Creating session 1/1
Logging in to [iface: libvirt-iface-08137b06, target: iqn.2018-05.storage.kvm.com:stor1, portal: 172.16.216.167,3260] (multiple)
Login to [iface: libvirt-iface-08137b06, target: iqn.2018-05.storage.kvm.com:stor1, portal: 172.16.216.167,3260] successful.

[[email protected] ~]# iscsiadm -m node              #<--查看iscsi发现记录
172.16.216.167:3260,1 iqn.2018-05.storage.kvm.com:stor1

4.断开与 target 的连接

[[email protected] ~]# iscsiadm -d2 -m node --logout    #<--退出节点

原文地址:http://blog.51cto.com/stuart/2122381

时间: 2024-10-09 23:30:10

Linux系统配置iscsi存储的相关文章

Linux挂载iscsi存储

Linux挂载iscsi存储     iscsi 提供给Linux挂载有两种方式,一种通过iscsi 协议的ip映射,一种通过文件共享 nfs挂载.其中通过iscsi 协议的ip映射 方式挂载到Linux中以磁盘形式展现,ip映射之后还需要对该磁盘分区,并格式化分区. 挂载步骤: 1:检查iscsi rpm包 2:启动iscsi服务并设置开机自启动 3:查找存储对外提供的逻辑卷 4:映射逻辑卷到Linux系统中 5:设置开机自动映射 6:对映射出来的磁盘进行分区 7:分区之后进行格式化 8:挂载

Linux 挂载iscsi存储磁盘设备

1,check网络 [[email protected] ~]# ping -I eth0 11.110.10.138 PING 11.110.10.138 (11.110.10.138) from 11.110.10.138eth0: 56(84) bytes of data. 64 bytes from 11.110.10.138: icmp_seq=1ttl=64 time=0.023 ms 64 bytes from 11.110.10.138: icmp_seq=2ttl=64 tim

Linux配置iSCSI存储

一.基础知识1.1.存储相关 直接存储(DAS):例如本机上的磁盘,就是属于直接存储设备. 存储区域网络(SAN):来自网络内的其他存储设备提供的磁盘.Iscsi就是属于该方式. 网络文件系统(NAS):直接提供文件系统,可以立即使用. 1.2.ISCSI相关基础 iscsi target:存储设备端,服务器端的设备,为其他服务器提供“磁盘”. Iscsi initiator:使用target提供“磁盘”的客户端. 二.ISCSI服务器端安装配置 以192.168.28.130作为target,

Linux下挂载iscsi存储

1. 检查系统是否安装iSCSI initiator [[email protected] ~]# rpm -qa|grep iscsi [[email protected] ~]#  [[email protected] ~]# mount /dev/cdrom /mnt/ mount: block device /dev/sr0 is write-protected, mounting read-only [[email protected] ~]# cd /mnt/ [[email pro

为ESXI 添加ISCSI存储设备 Linux服务器系统

为ESXI 添加ISCSI存储设备 Linux系统 本文使用的LINUX 6系统上一块硬盘制作的ISCSI存储设备其IP地址为:192.168.26.218: 在系统上直接输入:yum -y install scsi-target-utils 命令 安装 iscsi 分区设置我们将SDD这块硬盘的SDD1作为iscsi存储设备 编辑ISCSI配置文件:/etc/tgt/targets.conf 内容如下: 启动ISCSI: /etc/init.d/tgtd start(这里我们已经启动过,所以用

linux杂谈(十七):iscsi存储分离技术

1.iscsi简介 ? ?iSCSI利用了TCP/IP的port 860 和 3260 作为沟通的渠道.透过两部计算机之间利用iSCSI的协议来交换SCSI命令,让计算机可以透过高速的局域网集线来把SAN模拟成为本地的储存装置. ? ? 虽然 iSCSI 可以与任意类型的 SCSI 设备进行通信,系统管理员几乎总是使用它来连接服务器计算机 (例如,数据库服务器) 和磁盘卷上存储阵列. 使用iSCSI SAN 的目的通常有以下两个: 存储整合 公司希望将不同的存储资源从分散在网络上的服务器移动到统

Lenovo DS存储Linux下ISCSI 多路径映射配置

Lenovo  DS存储Linux下ISCSI 多路径映射配置 Renren  2018-01-17 实验环境: DS4200存储,B控制器池划分一个大小为18G的volume,通过两个1G ISCSI口port2和port3同时映射给客户机.Port B2口IP为172.16.1.14/24 :port B3口IP为172.16.1.15/24. 客户机系统为centos 6.9,两个以太网口,eth0口IP为172.16.1.195/24,eth1口的IP为172.16.1.196/24.网

读详解Linux配置iSCSI方法--学习笔记

http://tech.watchstor.com/storage-module-121394.htm http://blog.csdn.net/holandstone/article/details/7963822 iSCSI(互联网小型计算机系统接口)是一种在Internet协议网络上,特别是以太网上进行数据块传输的标准,是一种集成了IP和SCSI的技术.它最大的特点就是让标准的SCSI命令能够在TCP/IP网络上的主机系统(启动器)和存储设备(目标)之间传送.iSCSI是基于IP协议的技术

CentOS/Linux 连接 iscsi 磁盘阵列

CentOS/Linux连接ISCSI磁盘整列 iSCSI:即Internet Small Computer System Interface 系统环境:CentOS 6.5 mini 磁盘阵列:联想EMC ISCSI IP:192.168.100.201 一.安装ISCSI 1:确认是否安装iscsi # rpm -qa|grep iscsi 2:安装iscsi(如未安装) # yum -y install iscsi-initiator* 3:启动iscsi服务 (默认系统启动后自动运行)