First, create 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/lvlabstor1meta-data=/dev/vglabstor1/lvlabstor1 isize=512 agcount=4, agsize= 5242624 blks = sectsz=512 attr=2, Projid32bit=1 = crc=1 finobt=0, sparse=0data = bsize=4096 blocks=20970496, imaxpct=25 = sunit=0 swidth=0 blksnaming =version 2 bsize=4096 ascii-ci=0 ftype=1log =internal log bsize=4096 blocks= 10239, version=2 = sectsz=512 sunit=0 blks, lazy-count=1realtime =none extsz=4096 blocks=0, rtextents=0[[email protected] ~]# mkdir /labstor1[[email protected] ~]# mount /dev/vglabstor1/ lvlabstor1 /labstor1/
II. installation configuration iSCSI target
1. Installing TARGETCLI
[[email protected] ~]# uname-r3.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. Configure TARGETCLI
[[email protected] ~]# targetclitargetcli shell version 2.1.fb46copyright 2011-2013 by datera, inc and others. for help on commands, type ' help './backstores> cd fileio/backstores/ Fileio> create disk01 /labstor1/disk01.img 1gcreated fileio disk01 with size 1073741824/backstores/fileio> create disk02 /labstor1/disk02.img 30gcreated fileio disk02 with size 32212254720/backstores/fileio> ls /o- / ...................................................................................................................... [...] o- backstores ........................................................................................................... [...]   | O- BLOCK&NBSP, ... ..... ... .... ... .... ... .... ... ..... .... ..... ..... ..... ..... ..... ..... ..... ..... ..................................... [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&NBSP: ..... ..... ..... ..... ..... ..... ..... ........... ................ [targets: 0]/backstores/fileio> cd /. .................... .....???????.. iscsi//iscsi> lso- 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]     &Nbsp;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/disk01created lun 0./iscsi/iqn.20...or1/tpg1/luns> create /backstores/fileio/disk02created lun 1./iscsi/iqn.20...or1/tpg1/luns> lso- luns &NBSP, ... ..... ..... ..... ..... ..... ..... ..... ..... .................. ..... ..... ..... ..... ..... ..... ..... ..... ..... ..... ..... ....... ..... [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:kvmcreated node acl for iqn.1994-05.com.redhat:kvmcreated mapped lun 1.created mapped lun 0./iscsi/iqn.20...or1/tpg1/acls> create iqn.1994-05.com.redhat:node2Created Node Acl for iqn.1994-05.com.redhat:node2created mapped lun 1.created mapped lun 0./iscsi/iqn.20...or1/tpg1/acls> lso- 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)
Third, client initiator connection target
1. Check if the software is installed and see the initiatorname name
[Email protected] ~]# Rpm-qa |grep iscsilibiscsi-1.9.0-7.el7.x86_ 64libvirt-daemon-driver-storage-iscsi-3.9.0-14.el7_5.2.x86_64iscsi-initiator-utils-6.2.0.873-35.el7.x86_ 64iscsi-initiator-utils-iscsiuio-6.2.0.873-35.el7.x86_64[[email protected] ~]# Rpm-qa |grep Iscsilibiscsi-1.9.0-7.el7.x86_64iscsi-initiator-utils-iscsiuio-6.2.0.874-4.el7.x86_ 64iscsi-initiator-utils-6.2.0.874-4.el7.x86_64libvirt-daemon-driver-storage-iscsi-3.2.0-14.el7_4.9.x86_64[[ Email protected] ~]# Vim/etc/iscsi/initiatorname.iscsiinitiatorname=iqn.1994-05.com.redhat:node2[[email protected] ~]# CAT/ETC/ISCSI/INITIATORNAME.ISCSI INITIATORNAME=IQN.1994-05.COM.REDHAT:KVM
2. Check if you can find
[Email protected] ~]# iscsiadm--mode discovery--type sendtargets--portal 172.16.216.167172.16.216.167:3260,1 Iqn.2018-05.storage.kvm.com:stor1
3. Test Mount Device
[Email protected] ~]# iscsiadm-d2-m node--login #<--login Nodes Iscsiadm:max file limits 1024x768 4096iscsiadm:libvirt-if Ace-08137b06:creating session 1/1logging 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 #<--view iSCSI Discovery Records 172.16.216.167:3260,1 iqn.2018-05.storage.kvm.com:s Tor1
4. Disconnecting from Target
[[email protected] ~]# iscsiadm-d2-m node--logout #<--exit nodes
Linux System Configuration iSCSI storage