配置linux为存储
为存储准备15G裸设备
[root@server1 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 100G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 99G 0 part
├─cl-root 253:0 0 63.9G 0 lvm /
├─cl-swap 253:1 0 4G 0 lvm [SWAP]
└─cl-home 253:2 0 31.2G 0 lvm /home
sdb 8:16 0 3T 0 disk
└─sdb1 8:17 0 15G 0 part
安装软件
[root@server1 ~]# yum install -y targetcli.noarch
配置存储
[root@server1 ~]# targetcli
Warning: Could not load preferences file /root/.targetcli/prefs.bin.
targetcli shell version 2.1.53
Copyright 2011-2013 by Datera, Inc and others.
For help on commands, type 'help'.
/> /backstores/block create name=storage1 dev=/dev/sdb1
Created block storage object storage1 using /dev/sdb1.
/> ls
o- / .................................................................................................................. [...]
o- backstores ....................................................................................................... [...]
| o- block ........................................................................................... [Storage Objects: 1]
| | o- storage1 .............................................................. [/dev/sdb1 (15.0GiB) write-thru deactivated]
| | 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: 0]
o- loopback .................................................................................................. [Targets: 0]
/>
存储端给iqn取名
/> /iscsi create iqn.2024-11.com.server1.node:disk1
Created target iqn.2024-11.com.server1.node:disk1.
Created TPG 1.
Global pref auto_add_default_portal=true
Created default portal listening on all IPs (0.0.0.0), port 3260.
创建lun
/> /iscsi/iqn.2024-11.com.server1.node:disk1/tpg1/luns create /backstores/block/storage1
查看客户端iqn
[root@kvm ~]# cat /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.1994-05.com.redhat:b45fd19d7584
存储端创建acl
/> /iscsi/iqn.2024-11.com.server1.node:disk1/tpg1/acls create iqn.1994-05.com.redhat:b45fd19d7584
Created Node ACL for iqn.1994-05.com.redhat:b45fd19d7584
Created mapped LUN 0.
/> /iscsi/iqn.2024-11.com.server1.node:disk1/tpg1/acls create iqn.1994-05.com.redhat:6768e7476451
Created Node ACL for iqn.1994-05.com.redhat:6768e7476451
Created mapped LUN 0.
仅允许iqn.1994-05.com.redhat:b45fd19d7584 iqn.1994-05.com.redhat:6768e7476451连接存储
客户端连接存储
[root@kvm ~]# iscsiadm -m discovery -t sendtargets -p 192.168.91.134:3260
192.168.91.134:3260,1 iqn.2024-11.com.server1.node:disk1
[root@kvm ~]# iscsiadm -m node -T iqn.2024-11.com.server1.node:disk1 -p 192.168.91.134:3260 -l
Logging in to [iface: default, target: iqn.2024-11.com.server1.node:disk1, portal: 192.168.91.134,3260]
Login to [iface: default, target: iqn.2024-11.com.server1.node:disk1, portal: 192.168.91.134,3260] successful.
[root@PXE ~]# iscsiadm -m discovery -t sendtargets -p 192.168.91.134:3260
192.168.91.134:3260,1 iqn.2024-11.com.server1.node:disk1
[root@PXE ~]# iscsiadm -m node -T iqn.2024-11.com.server1.node:disk1 -p 192.168.91.134:3260 -l
Logging in to [iface: default, target: iqn.2024-11.com.server1.node:disk1, portal: 192.168.91.134,3260]
Login to [iface: default, target: iqn.2024-11.com.server1.node:disk1, portal: 192.168.91.134,3260] successful.
标签:node,11,存储,disk1,配置,server1,iqn.2024,linux,com
From: https://www.cnblogs.com/cloudwangsa/p/18563749