系统相关
首页 > 系统相关> > 多台ESXI 6.5 添加 iSCSI 共享存储 --centos 7.5 作为target

多台ESXI 6.5 添加 iSCSI 共享存储 --centos 7.5 作为target

作者:互联网

多台ESXI 6.5 添加 iSCSI 共享存储 --centos 7.5 作为target

配置 iSCSI 服务端
iSCSI 技术在工作形式上分为服务端(target)与客户端(initiator)
iSCSI 服务端即用于存放硬盘存储资源的服务器,它作为前面创建的 RAID 磁盘阵列的存储端,能够为用户提供
可用的存储资源。 iSCSI 客户端则是用户使用的软件,用于访问远程服务端的存储资源。
iSCSI 服务端   centos 5  10.5.7.20
iSCSI 客户端   exsi 6.5  10.5.7.30/31

第1步,安装软件

# yum -y install targetd targetcli
[root@iscsi yum.repos.d]# systemctl start targetd
[root@iscsi yum.repos.d]# systemctl enable targetd
Created symlink from /etc/systemd/system/multi-user.target.wants/targetd.service to /usr/lib/systemd/system/targetd.service

第 2 步:配置 iSCSI 服务端共享资源
targetcli 是用于管理 iSCSI 服务端存储资源的专用配置命令,它能够提供类似于 fdisk 命令的交互式配置功能,将 iSCSI 共享资源的配置内容抽
象成“目录”的形式,我们只需将各类配置信息填入到相应的“目录”中即可。
/backstores/block 是iSCSI 服务端配置共享设备的位置。

[root@iscsi ~]# targetcli
targetcli shell version 2.1.fb49
Copyright 2011-2013 by Datera, Inc and others.
For help on commands, type 'help'.

/backstores/block> ls
o- block ...................................................................................................... [Storage Objects: 0]
/backstores/block> cd /backstores/block 
/backstores/block> create disk /dev/sdc
Created block storage object disk using /dev/sdc.
[root@iscsi ~]# targetcli
targetcli shell version 2.1.fb49
Copyright 2011-2013 by Datera, Inc and others.
For help on commands, type 'help'.

/backstores/block> ls
o- block ...................................................................................................... [Storage Objects: 0]
/backstores/block> cd /backstores/block 
/backstores/block> create disk /dev/sdc
Created block storage object disk using /dev/sdc.

第 3 步:创建 iSCSI target 名称及配置共享资源
iSCSI target 名称是由系统自动生成的,这是一串用于描述共享资源的唯一字符串。
系统在生成这个 target 名称后,还会在/iscsi 参数目录中创建一个与其字符串同名的新“目录”用来存放共享资源。
我们需要把前面加入到 iSCSI 共享资源池中的硬盘设备添加到这个新目录中,这样用户在登录 iSCSI 服务端后,即可默认使用这
硬盘设备提供的共享存储资源了

/> cd iscsi 
/iscsi> create 
Created target iqn.2003-01.org.linux-iscsi.iscsi.x8664:sn.c168464c5604.
Created TPG 1.
Global pref auto_add_default_portal=true
Created default portal listening on all IPs (0.0.0.0), port 3260.
/iscsi> cd iqn.2003-01.org.linux-iscsi.iscsi.x8664:sn.c168464c5604/
/iscsi/iqn.20....c168464c5604> ls
o- iqn.2003-01.org.linux-iscsi.iscsi.x8664:sn.c168464c5604 ............................................................... [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....c168464c5604> cd tpg1/luns 
/iscsi/iqn.20...604/tpg1/luns> create /backstores/block/disk 
Created LUN 0.

第 4 步:设置访问控制列表(ACL)。
iSCSI 协议是通过客户端名称进行验证的,也就是说,用户在访问存储共享资源时不需要输入密码,只要 iSCSI 客户端的名称与服务端中设置
的访问控制列表中某一名称条目一致即可,因此需要在 iSCSI 服务端的配置文件中写入一串能够验证用户信息的名称。
acls 参数目录用于存放能够访问 iSCSI 服务端共享存储资源的客户端名称。

/iscsi/iqn.20...604/tpg1/luns> cd ..
/iscsi/iqn.20...464c5604/tpg1> cd acls 
/iscsi/iqn.20...604/tpg1/acls> create iqn.2003-01.org.linux-iscsi.iscsi.x8664:sn.c168464c5604:client
Created Node ACL for iqn.2003-01.org.linux-iscsi.iscsi.x8664:sn.c168464c5604:client
Created mapped LUN 0.

第 5 步:设置 iSCSI 服务端的监听 IP 地址和端口号。

/iscsi/iqn.20...604/tpg1/acls> cd ..
/iscsi/iqn.20...464c5604/tpg1> cd portals//iscsi/iqn.20.../tpg1/portals> create 10.5.7.20
Using default IP port 3260
Could not create NetworkPortal in configFS
/iscsi/iqn.20.../tpg1/portals> delete 0.0.0.0 3260 ##删除0.0.0.0
Deleted network portal 0.0.0.0:3260
/iscsi/iqn.20.../tpg1/portals> create 10.5.7.20
Using default IP port 3260
Created network portal 10.5.7.20:3260.

第 6 步:配置妥当后检查配置信息,重启 iSCSI 服务端程序并配置防火墙策略。

/iscsi/iqn.20.../tpg1/portals> ls /
o- / ......................................................................................................................... [...]
  o- backstores .............................................................................................................. [...]
  | o- block .................................................................................................. [Storage Objects: 1]
  | | o- disk ............................................................................ [/dev/sdc (20.0GiB) write-thru activated]
  | |   o- alua ................................................................................................... [ALUA Groups: 1]
  | |     o- default_tg_pt_gp ....................................................................... [ALUA state: Active/optimized]
  | 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.iscsi.x8664:sn.c168464c5604 ........................................................... [TPGs: 1]
  |   o- tpg1 ............................................................................................... [no-gen-acls, no-auth]
  |     o- acls .......................................................................................................... [ACLs: 1]
  |     | o- iqn.2003-01.org.linux-iscsi.iscsi.x8664:sn.c168464c5604:client ....................................... [Mapped LUNs: 1]
  |     |   o- mapped_lun0 .................................................................................. [lun0 block/disk (rw)]
  |     o- luns .......................................................................................................... [LUNs: 1]
  |     | o- lun0 ....................................................................... [block/disk (/dev/sdc) (default_tg_pt_gp)]
  |     o- portals .................................................................................................... [Portals: 1]
  |       o- 10.5.7.20:3260 .................................................................................................. [OK]
  o- loopback ......................................................................................................... [Targets: 0]
/iscsi/iqn.20.../tpg1/portals> saveconfig ##必须进入根目录
Command not found saveconfig
/iscsi/iqn.20.../tpg1/portals> cd /
/> saveconfig
Configuration saved to /etc/target/saveconfig.json
/> exit
Global pref auto_save_on_exit=true
Last 10 configs saved in /etc/target/backup/.
Configuration saved to /etc/target/saveconfig.json
[root@iscsi ~]# systemctl restart targetd ##重启服务
[root@iscsi ~]# firewall-cmd --permanent --add-port=3260/tcp ##防火墙设置
success
[root@iscsi ~]# firewall-cmd --reload
success

##在esxi上面添加

 

 可以在设备中看到存储

 

 然后新建存储,选择该磁盘,并格式化即可

当在esxi 上面发现不了设备时,需要在iscsi target上加入esxi的iqn

[root@iscsi ~]# targetcli
targetcli shell version 2.1.fb49
Copyright 2011-2013 by Datera, Inc and others.
For help on commands, type 'help'.

/> ls
/> cd iscsi/iqn.2003-01.org.linux-iscsi.iscsi.x8664:sn.c168464c5604/tpg1/acls/ 
/iscsi/iqn.20...604/tpg1/acls> ls
o- acls .................................................................................................................. [ACLs: 1]
  o- iqn.2003-01.org.linux-iscsi.iscsi.x8664:sn.c168464c5604:client ............................................... [Mapped LUNs: 1]
    o- mapped_lun0 .......................................................................................... [lun0 block/disk (rw)]
/iscsi/iqn.20...604/tpg1/acls> create iqn.1998-01.com.vmware:5e97e176-a6a8-7276-968c-000c2999e61d-525eb47f  ##esxi 6.5 。10.5.7.30的iqn
Created Node ACL for iqn.1998-01.com.vmware:5e97e176-a6a8-7276-968c-000c2999e61d-525eb47f
Created mapped LUN 0.
/iscsi/iqn.20...604/tpg1/acls> ls
o- acls .................................................................................................................. [ACLs: 2]
  o- iqn.1998-01.com.vmware:5e97e176-a6a8-7276-968c-000c2999e61d-525eb47f ......................................... [Mapped LUNs: 1]
  | o- mapped_lun0 .......................................................................................... [lun0 block/disk (rw)]
  o- iqn.2003-01.org.linux-iscsi.iscsi.x8664:sn.c168464c5604:client ............................................... [Mapped LUNs: 1]
    o- mapped_lun0 .......................................................................................... [lun0 block/disk (rw)]
/iscsi/iqn.20...604/tpg1/acls> create iqn.1998-01.com.vmware:5e97e67c-0607-22a7-4505-000c29a09445-61c0b005   ##esxi 6.5 。10.5.7.31的iqn
Created Node ACL for iqn.1998-01.com.vmware:5e97e67c-0607-22a7-4505-000c29a09445-61c0b005
Created mapped LUN 0.
/iscsi/iqn.20...604/tpg1/acls> ls
o- acls .................................................................................................................. [ACLs: 3]
  o- iqn.1998-01.com.vmware:5e97e176-a6a8-7276-968c-000c2999e61d-525eb47f ......................................... [Mapped LUNs: 1]
  | o- mapped_lun0 .......................................................................................... [lun0 block/disk (rw)]
  o- iqn.1998-01.com.vmware:5e97e67c-0607-22a7-4505-000c29a09445-61c0b005 ......................................... [Mapped LUNs: 1]
  | o- mapped_lun0 .......................................................................................... [lun0 block/disk (rw)]
  o- iqn.2003-01.org.linux-iscsi.iscsi.x8664:sn.c168464c5604:client ............................................... [Mapped LUNs: 1]
    o- mapped_lun0 .......................................................................................... [lun0 block/disk (rw)]

最后如下(c7 是centos 7.4 作为iscsi target,w2016 是windows 2016 storage系统作为 iscsi target,并作为oracle rac的共享存储,成功安装oracle rac)。有需要的可以联系。。

 

标签:...,target,centos,ESXI,iscsi,iqn.20,tpg1,iSCSI,block
来源: https://www.cnblogs.com/yhq1314/p/12721507.html