ISCSI
ISCSI 技术实现了物理硬盘设备与 TCP/TP 网络传输协议的相互结合,使得用户可以通过互联网方便的获取到远程机房提供的共享存储资源
ISCSI target:就是储存设备端,存放磁盘或 RAID 的设备,目前也能够将 Linux 主机仿真成 iSCSI target 了!目的在提供其他主机使用的『磁盘』
ISCSI initiator:就是能够使用 target 的客户端,通常是服务器。 也就是说,想要连接到 iSCSI target 的服务器,也必须要安装 iSCSI initiator 的相关功能后才能够使用 iSCSI target 提供的磁盘就是了
软件安装(客户端、服务端)
服务端
[root@server ~]# yum install targetcli.noarch -y
客户端
[root@client ~]# yum install iscsi-initiator-utils -y
服务端配置
划分出一块 2G 的磁盘
[root@server ~]# fdisk /dev/vdb 加2G
[root@server ~]# partprobe
Warning: Unable to open /dev/sr0 read-write (Read-only file system). /dev/sr0 has been opened read-only.
Warning: Unable to open /dev/sr0 read-write (Read-only file system). /dev/sr0 has been opened read-only.
Warning: Unable to open /dev/sr0 read-write (Read-only file system). /dev/sr0 has been opened read-only.
[root@server ~]# systemctl start target
[root@server ~]# systemctl enable target
ln -s '/usr/lib/systemd/system/target.service' '/etc/systemd/system/multi-user.target.wants/target.service'
[root@server ~]# targetcli
Warning: Could not load preferences file /root/.targetcli/prefs.bin.
targetcli shell version 2.1.fb34
Copyright 2011-2013 by Datera, Inc and others.
For help on commands, type 'help'.
/> 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 westos:storage1 /dev/vdb1
##建立一个块存储 westos:storage1(名称 westos:storage1 可自定义),/dev/sdb1 为上面新建的分区名称
Created block storage object westos:storage1 using /dev/vdb1.
/> /iscsi create iqn.2018-06.com.example:storage1
配置 ISCSITarget 命名 命名在同一子网内确保是唯一的,命名格式为:iqn.yyyy-mm.<主机名反写>: 自定义名称(自定义名称内不能有下划线)
Created target iqn.2018-06.com.example:storage1.
Created TPG 1.
/> ls
o- / ..................................................................... [...]
o- backstores .......................................................... [...]
| o- block .............................................. [Storage Objects: 1]
| | o- westos:storage1 ........... [/dev/vdb1 (2.0GiB) write-thru deactivated]
| o- fileio ............................................. [Storage Objects: 0]
| o- pscsi .............................................. [Storage Objects: 0]
| o- ramdisk ............................................ [Storage Objects: 0]
o- iscsi ........................................................ [Targets: 1]
| o- iqn.2018-06.com.example:storage1 .............................. [TPGs: 1]
| o- tpg1 ........................................... [no-gen-acls, no-auth]
| o- acls ...................................................... [ACLs: 0]
| o- luns ...................................................... [LUNs: 0]
| o- portals ................................................ [Portals: 0]
o- loopback ..................................................... [Targets: 0]
/> /iscsi/iqn.2018-06.com.example:storage1/tpg1/acls create iqn.2018-06.com.example:westoskey
创建 ACL 允许 ISCSI 客户机连接
iqn.2018-06.