概念
ISCSI:【 internet Small Computer System Interface】一种基于TCP/IP的传输的存储技术,在TCP/IP网络上传输SCSI协议。ISCSI协议主要分为(iSCSI target)磁盘源目标创建在服务端使用,以及(iSCSI initiator)磁盘使用者发起在客户端使用。 IQN:iSCSI限定名称,全球唯一名称,用于以强制命名格式来识别启动器和目标;
IQN格式如下:iqn.YYYY-MM.com.reversed.domain[ :optional_string]
iqn:表示此名称使用域为标识符。
YYYY-MM:表示拥有域名的年月时间。
com.reversed.domain:拥有此iSCSI组织的逆向域名
:optional_string:以冒号为前缀的可选字符串,全球唯一,由域所有者分配,其中可包含冒号为分割符的组织边界
TPG:目标门户组,某个特定iSCSI目标要侦听的接口IP地址和TCP端口的集合。可以将目标配置添加到TPG以协调多个LUN的设置。
LUN:逻辑单元,指定具体块设备 ACL:访问控制列表,关联相关逻辑单元,进行用户管理 Portal:访问门户,管理访问地址与端口
服务端
建立一个新分区vdb1做测试
fdisk /dev/vdb
安装targetcli工具,管理target服务
[ root@node1 ~]
配置target
[ root@node2 ~]
/> ls
o- / .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. . [ .. .]
o- backstores .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. [ .. .]
| o- block .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. [ Storage Objects: 0]
| o- fileio .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. . [ Storage Objects: 0]
| o- pscsi .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. [ Storage Objects: 0]
| o- ramdisk .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. [ Storage Objects: 0]
o- iscsi .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. [ Targets: 0]
o- loopback .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. . [ Targets: 0]
/>
/> backstores/block create testvdb1 /dev/vdb1
Created block storage object testvdb1 using /dev/vdb1.
/> iscsi/ create iqn.2019-11.com.test:testiscsi
Created target iqn.2019-11.com.test:testiscsi.
Created TPG 1.
/> iscsi/iqn.2019-11.com.test:testiscsi/tpg1/luns create /backstores/block/testvdb1
Created LUN 0.
/> iscsi/iqn.2019-11.com.test:testiscsi/tpg1/acls create iqn.2019-11.com.test:redhat
Created Node ACL for iqn.2019-11.com.test:redhat
Created mapped LUN 0.
/> iscsi/iqn.2019-11.com.test:testiscsi/tpg1/portals create 172.25.254.201
Using default IP port 3260
Created network portal 172.25.254.201:3260.
开启火墙端口
firewall-cmd --permanent --add-port= 3260/tcp
success
firewall-cmd --reload
success
启动target服务
sytemctl start target.service
客户端
安装initiator服务管理工具
yum install iscsi-initiator-utils.x86_64 -y
添加关联服务端设备名称及密码
vim /etc/iscsi/initiatorname.iscsi
InitiatorName= iqn.2019-11.com.test:redhat
启动服务
systemctl start iscsid
查询指定网络iscsi设备
[ root@node1 ~]
172.25.254.201:3260,1 iqn.2019-11.com.test:testiscsi
添加iscsi设备到客户端
[ root@node1 ~]
Logging in to [ iface: default, target: iqn.2019-11.com.test:testiscsi, portal: 172.25.254.201,3260] ( multiple)
Login to [ iface: default, target: iqn.2019-11.com.test:testiscsi, portal: 172.25.254.201,3260] successful.
将加载设备sda,当正常设备格式化挂载使用即可 注销设备
[ root@node1 ~]
Logging out of session [ sid: 2, target: iqn.2019-11.com.test:testiscsi, portal: 172.25.254.201,3260]
Logout of [ sid: 2, target: iqn.2019-11.com.test:testiscsi, portal: 172.25.254.201,3260] successful.
删除设备
[ root@node1 ~]