1. server-side configuration
Experimental environment system version:
CentOS Linux release 7.3.1611 (Core)
1)Install packages
Yum-y Install TARGETCLI
2)to create an iSCSI storage to output
There are several types of devices that can be output:
A, LVM coil equipment;
B, a block device composed of files (after tgtimg tools processed);
C, a single partition;
D, the entire disk;
E, RAID a volume device consisting of;
An LVM logical volume is prepared here, as follows:
[[email protected] conf.d]# lvdisplay --- Logical volume --- LV Path /dev/vg_dengqp03/LogVol01 LV Name LogVol01 VG Name vg_dengqp03 lv uuid wk1tx8-98eo-wxsn-tmdu-0yl8-8okh-7iiquo lv write access read/write lv creation host, time dengqp03, 2016-04-19 03:43:00 -0400 LV Status available # open 1 LV Size 10.84 GiB Current LE 2774 Segments 4 Allocation inherit Read ahead sectors auto - currently set to 8192 block device 253:2
3)View Client Initiatorname user-created ACLs
[Email protected] ~]# CAT/ETC/ISCSI/INITIATORNAME.ISCSI initiatorname=iqn.1994-05.com.redhat:f958e9b53119
4)Configuring storage with TARGETCLI
[[email protected] conf.d]# targetcli warning: could not load Preferences file /root/.targetcli/prefs.bin.targetcli shell version 2.1.fb41copyright 2011-2013 by datera, inc and others. for help on commands, type ' Help ' . /> lso- / ......................................................................................................................... [...] 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 mydata /dev/mapper/vg_dengqp03-logvol01 //creating shared block storage Created block storage object mydata using /dev/mapper/vg_ Dengqp03-logvol01./> cd iscsi /iscsi> create iqn.2017-03.com.dengqp:server0 //Create a TargeTcreated target iqn.2017-03.com.dengqp:server0. Created tpg 1.global pref auto_add_default_portal=truecreated default portal listening on all IPs (0.0.0.0),  PORT 3260./ISCSI> LSO- ISCSI &NBSP, ... ..... ..... ..... ..... ..... ..... ..... ..... .................. ..... ..... ..... ..... ..... ..... ..... ..... ..... ...... ....... ....... [Targets: 1] o- iqn.2017-03.com.dengqp:server0 ....... ..... ................. ......... ........ ................... ....... [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]/iscsi> cd iqn.2017-03.com.dengqp:server0/tpg1//iscsi/iqn.20...:server0/tpg1> cd portals//iscsi/iqn.20.../tpg1/portals> delete ip_address=0.0.0.0 ip_port=3260deleted network portal 0.0.0.0:3260/iscsi/iqn.20.../tpg1/portals> create 10.20.2.237 //Create shared address, port defaults to 3260using default ip port 3260created network portal  10.20.2.237:3260./ISCSI/IQN.20.../TPG1/PORTALS> CD&NBSP, .... /iscsi/iqn.20...:server0/tpg1> luns/ create /backstores/block/mydata //Create a luncreated lun on target 0./iscsi/iqn.20...:server0/tpg1> acls/ create iqn.1994-05.com.redhat:f958e9b53119 // ACLS directory create shared password created node acl for iqn.1994-05.com.redhat:f958e9b53119created mapped LUN 0./iscsi/iqn.20...engqp:server0> cd //> lso- / ......................................................................................................................... [...] o- backstores .............................................................................................................. [...] | o- block ..... ..... ..... ..... ..... ............... ......... ..... ..... ..... ..... ..... ............. .......... [ storage objects: 1] | | o- mydata .... [/dev/mapper/vg_deng. ................ .....?????????????...qp03-logvol01 (10.8GiB) write-thru activated] | o- fileio ..... ..... ..... ..... ..... .............. .......... ..... ..... ..... ..... ..... ............. .......... [ storage objects: 0] | o- pscsi ..... ..... ..... ..... ..... ............... ......... ..... ..... ..... ..... ..... ............. .......... [ storage objects: 0] | o- ramdisk ..... ..... ..... ..... ..... .............. .......... ..... ..... ..... ..... .............. ........... [storage Objects: 0] o- iscsi ............................................................................................................ [targets: 1] | o- iqn.2017-03.com.dengqp:server0 .................................................................................... [tpgs: 1]  |   O- TPG1&NBSP: ..... ..... ..... ..... ....................................................................... [no-gen-acls, no-auth] | o- acls .......................................................................................................... [acls: 1] | | o- iqn.1994-05.com.redhat:f958e9b53119 .................................................................. [Mapped LUNs: 1] | | o- mapped_lun0 ............................. ....................... ........ [lun0 block/mydata (rw)] | o- luns .......................................................................................................... [luns: 1] | | o- lun0 ..... ..... ..... ..... ..... ..... ..... [b. ..... .....??????????????????..lock/mydata (/DEV/MAPPER/VG_DENGQP03-LOGVOL01)] | o- portals   ..... ..... ..... ..... ..... ..... ..................... ..... ..... ..... ..... ..... ............... ......... [Portals: 1] | o- 10.20.2.237:3260 ..... ..... ..... ..... ..... .............. .......... ..... ..... ..... ..... ..... ............. .......... [ok] o- loopback ......................................................................................................... [targets: 0]/> saveconfig //Save Configuration Last 10 configs saved in /etc/target/backup. Configuration saved to /etc/target/saveconfig.json/> exitglobal pref auto_ Save_on_exit=truelast 10 configs saved in /etc/target/backup. Configuration saved to /etc/target/saveconfig.json
5)Start the target service
[[Email protected] conf.d]# systemctl enable targetcreated symlink from /etc/systemd/system/multi-user.target.wants/target.service to /usr/lib/systemd/system/ Target.service. [[EMAIL PROTECTED] CONF.D]# SYSTEMCTL START TARGET[[EMAIL PROTECTED] CONF.D ]# systemctl status target target.service - Restore LIO kernel target configuration loaded: loaded (/usr/lib/systemd/system/target.service; enabled; vendor preset: disabled) Active: active (exited) since mon 2017-03-27 03:33:22 edt; 4s ago process: 14646 ExecStart=/usr/bin/targetctl restore (code=exited, status=0/success) main pid: 14646 (code=exited, status=0/success) Mar 27 03:33:22 dengqp03 Systemd[1]: startinG restore lio kernel target configuration ... mar 27 03:33:22 dengqp03 systemd[1]: started restore lio kernel Target configuration.
2.Client Configuration
Experimental environment system version:
CentOS Release 6.7 (Final)
1)Man Iscsiadm Viewing the examples in Help
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
2)devices found on server-side output
[Email protected] samba]# iscsiadm--mode discoverydb--type sendtargets--portal 10.20.2.237--discover starting Iscsid: [OK]10.20.2.237:3260,1 Iqn.2017-03.com.dengqp:server0
3)Linked Devices
[Email protected] samba]# iscsiadm--mode node--targetname iqn.2017-03.com.dengqp:server0--portal 10.20.2.237:3260-- Login Logging in to [Iface:default, Target:iqn.2017-03.com.dengqp:server0, portal:10.20 .2.237,3260] (multiple) Login to [Iface:default, Target:iqn.2017-03.com.dengqp:server0, portal:10.20.2.237,3260] Successful.
4)View verify that the device is recognized
[[email protected] samba]# fdisk-l below for discovered networked storage disk/dev/sdb:11.6 GB, 11634999296 bytes64 heads, sectors/track, 11096 CY Lindersunits = Cylinders of 2048 * 1048576 bytessector size (logical/physical): bytes/512 bytesi/o Size (minim Um/optimal): bytes/4194304 bytesdisk identifier:0x00000000
5)Create an iSCSI mount point and Mount networked storage
[[email protected]/]# mkdir iscsi[[email protected]/]# mount/dev/sdb/iscsi///If you mount the following error, you need to use MKFS format before mounting mount:you m UST Specify the filesystem Type[[email protected]/]# df-hfilesystem Size used Avail use% mounted ON/DEV/SDB 11G 4.1G 6.0G 41%/ISCSI
This article is from the "11528244" blog, please be sure to keep this source http://11538244.blog.51cto.com/11528244/1910810
Configuring iSCSI networked Storage under Linux