iscsi Server(target):10.240.36.1731 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 [root@server(target)]# yum install targetcli [root@server(target)]# targetcli --- targetcli shell version 2.1.fb41 Copyright 2011-2013 by Datera, Inc and others. For help on commands, type 'help'. /> ls o- / ......................................................................................................................... [...] o- backstores .............................................................................................................. [...] | o- block .................................................................................................. [Storage Objects: 1] | | o- target.disk1 .................................................................... [/dev/vdb (50.0GiB) write-thru activated] | o- fileio ................................................................................................. [Storage Objects: 0] | o- pscsi .................................................................................................. [Storage Objects: 0] | o- ramdisk ................................................................................................ [Storage Objects: 0] o- iscsi ............................................................................................................ [Targets: 1] | o- iqn.2019-00.com.haha:iscsitarget1 ................................................................................. [TPGs: 1] | o- tpg1 ............................................................................................... [no-gen-acls, no-auth] | o- acls .......................................................................................................... [ACLs: 1] | | o- iqn.2019-00.com.haha:initiator ....................................................................... [Mapped LUNs: 1] | | o- mapped_lun0 .......................................................................... [lun0 block/target.disk1 (rw)] | o- luns .......................................................................................................... [LUNs: 1] | | o- lun0 .................................................................................. [block/target.disk1 (/dev/vdb)] | o- portals .................................................................................................... [Portals: 1] | o- 10.240.36.173:3260 ............................................................................................... [OK] o- loopback ......................................................................................................... [Targets: 0] />saveconfig />exit --- [root@server(target)]# systemctl restart iscsi iscsid [root@server(target)]# iscsiadm -m node
Client(initiator):10.240.36.1861 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 [root@client(initiator)]# yum install iscsi-initiator-utils [root@client(initiator)]# vim /etc/iscsi/initiatorname.iscsi --- InitiatorName=iqn.2019-00.com.haha:initiator --- [root@client(initiator)]# systemctl restart iscsi iscsid [root@host-10-240-36-186 ~]# iscsiadm --mode discoverydb --type sendtargets --portal 10.240.36.173 --discover --- 10.240.36.173:3260,1 iqn.2019-00.com.haha:iscsitarget1 --- [root@client(initiator)]# iscsiadm --mode node --targetname iqn.2019-00.com.haha:iscsitarget1 --portal 10.240.36.173:3260 --login [root@host-10-240-36-186 ~]# lsblk --- NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 50G 0 disk vda 252:0 0 80G 0 disk ├─vda1 252:1 0 1G 0 part /boot └─vda2 252:2 0 79G 0 part ├─vg_root-lv_root 253:0 0 30G 0 lvm / ├─vg_root-lv_swap 253:1 0 4G 0 lvm [SWAP] ├─vg_root-lv_tmp 253:2 0 20G 0 lvm /tmp vdb 252:16 0 50G 0 disk vdc 252:32 0 1.1T 0 disk --- [root@host-10-240-36-186 ~]# cat /proc/scsi/scsi Attached devices: Host: scsi26 Channel: 00 Id: 00 Lun: 00 Vendor: LIO-ORG Model: target.disk1 Rev: 4.0 Type: Direct-Access ANSI SCSI revision: 05
sda
above is the exactly disk.
manual
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 [root@client(initiator)]# man iscsiadm --- EXAMPLES Discover targets at a given IP address: iscsiadm --mode discoverydb --type sendtargets --portal 192.168.1.10 --discover Login, must use a node record id found by the discovery: iscsiadm --mode node --targetname iqn.2001-05.com.doe:test --portal 192.168.1.1:3260 --login Logout: iscsiadm --mode node --targetname iqn.2001-05.com.doe:test --portal 192.168.1.1:3260 --logout List node records: iscsiadm --mode node ---
target
1 [root@server(target)]# iscsiadm -m node
initiator
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 [root@client(initiator)]# iscsiadm -m node [root@host-10-240-36-186 ~]# iscsiadm --mode discoverydb --type sendtargets --portal 10.240.36.173 --discover 10.240.36.173:3260,1 iqn.2019-00.com.haha:iscsitarget1 [root@host-10-240-36-186 ~]# iscsiadm --mode node --targetname iqn.2019-00.com.haha:iscsitarget1 --portal 10.240.36.173:3260 --login Logging in to [iface: default, target: iqn.2019-00.com.haha:iscsitarget1, portal: 10.240.36.173,3260] (multiple) Login to [iface: default, target: iqn.2019-00.com.haha:iscsitarget1, portal: 10.240.36.173,3260] successful. [root@host-10-240-36-186 ~]# iscsiadm --mode node --targetname iqn.2019-00.com.haha:iscsitarget1 --portal 10.240.36.173:3260 --logout Logging out of session [sid: 20, target: iqn.2019-00.com.haha:iscsitarget1, portal: 10.240.36.173,3260] Logout of [sid: 20, target: iqn.2019-00.com.haha:iscsitarget1, portal: 10.240.36.173,3260] successful. [root@client(initiator)]# iscsiadm -m discovery -t sendtargets -p 10.240.36.173:3260 [root@client(initiator)]# iscsiadm -m discovery -t st -p 10.240.36.173:3260 [root@client(initiator)]# iscsiadm -m node -T iqn.2019-00.com.haha:iscsitarget1 --login [root@client(initiator)]# iscsiadm -m node -T iqn.2019-00.com.haha:iscsitarget1 --logout