Configure ISCSI Target on RHEL7

Source: Internet
Author: User

In RHEL7, the scsi-target-utils has been replaced with the TARGETCLI software, and targetcli is easier to use than the Scsi-target-utils software. Specific as follows:


1. Create a logical Volume:

[[email protected] ~]# lvcreate-n vv01-l +500g datavg[[email protected] ~]# lvcreate-n vv02-l +500g datavg[[email Prot Ected] ~]# lvcreate-n vv03-l +500g datavg

2. Install TARGETCLI software and start the service:

[[email protected] ~]# yum-y install targetcli[[email protected] ~]# systemctl start target[[email protected] ~]# SYSTEMC TL Enable Target[[email protected] ~]# systemctl status target

3. Create shared storage:

[[email protected] ~]# targetcli /backstores/block [[email protected] ~]#  targetcli/backstores/block> create sharedisk01 /dev/datavg/vv01/backstores/block>  create sharedisk02 /dev/datavg/vv02/backstores/block> create sharedisk03 / dev/datavg/vv03/backstores/block> lso- block  ..... ...  [storage objects: 3]  o-. ..... ..... ..... ..... ..... .....??????????????????...  sharedisk01 .................................................. [/dev/datavg/vv01  ( 500.0GiB)  write-thru deactivated]  o- sharedisk02  ............................................................. [/dev/datavg/vv02  (500.0GiB)   write-thru deactivated]  o- sharedisk03  ............................................................. [/dev/datavg/vv03  (500.0GiB)   Write-thru deactivated]

4. Create IQN Name:

/backstores/block> CD//> CD iscsi/iscsi> create iqn.2015-09.com.he:lun1created target iqn.2015-09.com.he: Lun1. Created TPG 1.Global pref auto_add_default_portal=truecreated Default portal listening on all IPs (0.0.0.0), Port 3260.

The target service listens to 3260 ports on all IPs in the system by default. If you want to enable it to listen on port 3260 for an interface IP, run the following command:

/iscsi> CD iqn.2015-09.com.he:lun1/tpg1/iscsi/iqn.20....he:lun1/tpg1> portals/create 172.16.250.100Using Default IP port 3260Created Network Portal 172.16.250.100:3260./iscsi/iqn.2015-09.com.he:lun1/tpg1>

5. Create LUN mappings:

/iscsi/iqn.2015-09.com.he:lun1/tpg1> luns/create/backstores/block/sharedisk01created Lun 0.Created LUN 0->0 Mapping in node ACL iqn.1991-05.com.microsoft:win10/iscsi/iqn.2015-09.com.he:lun1/tpg1> luns/create/backstores/ block/sharedisk02created LUN 1.Created LUN 1->1 Mapping in node ACL iqn.1991-05.com.microsoft:win10/iscsi/ iqn.2015-09.com.he:lun1/tpg1> luns/create/backstores/block/sharedisk03created Lun 2.Created LUN 2->2 mapping in Node ACL iqn.1991-05.com.microsoft:win10

By default, the added LUN is readable and writable, and if you add a read-only LUN, use the following command:

/> Set global Auto_add_mapped_luns=falseparameter auto_add_mapped_luns is now ' false '.

6. Add ACLs:

This ACL requires the client's initiator name.

Under Linux, you can view the/etc/iscsi/initiatorname.iscsi file to get the initiator name;

Under Windows, obtain the initiator name through the Configuration tab in the iSCSI initiator;

Under Solaris, initiator name is obtained by Iscsiadm list Initiator-node.

The default initiator name can be changed casually. The initiator name for Windows 10 here is: Iqn.1991-05.com.microsoft:win10.

/iscsi/iqn.2015-09.com.he:lun1/tpg1> acls/ create iqn.1991-05.com.microsoft:win10created  Node ACL for iqn.1991-05.com.microsoft:win10/iscsi/iqn.2015-09.com.he:lun1/tpg1>  lso- tpg1  ..... ..... ..... ..... ..... ..... ............ ........... ..... ..... ..... ..... ..... .............. ..........  [ no-gen-acls, no-auth]  o- acls  ...............................................................................................................  [ACLs: 1]  | o- iqn.1991-05.com.microsoft:win10  ... ..... ... ..... ... ..... ... ..... ... ..... ... .... ..... ..... .... ....  [mapped luns: 3 ..... .....???????????????????   |   o- mapped_lun0  ............................. ....................... ........  [lun0 block/ sharedisk01  (rw)]  |   o- mapped_lun1  ................................................................................ [lun1 block/sharedisk02  (rw)]  |   o- mapped_ lun2 ................................................................................ [lun2  block/sharedisk03  (rw)]  o- luns  ...............................................................................................................  [LUNs: 3]  | o- lun0  ................................................................................ [block/sharedisk01  (/DEV/DATAVG/VV01)]   | o- lun1  ................................................................................ [block/sharedisk02  (/DEV/DATAVG/VV02)]   | o- lun2  ................................................................................ [block/sharedisk03  (/DEV/DATAVG/VV03)]   O- PORTALS&NBSP, ... ..... ... ..... ... .... ..... .... ..... ..... ..... ..... ..... ..... ....................  [portals: 1]    o- 0.0.0.0:3260.......... ................. &NBSP: ..... ..... ..... ..... ..... ..... ..... ........... ........... ..... ..... ..... ..... ..... ..... ..... ....... ....... .........  [ok]

7. Save the configuration and exit:

Enter exit directly in TARGETCLI and the system will save the configuration file by default and exit.

/iscsi/iqn.2015-09.com.he:lun1/tpg1> exitglobal pref auto_save_on_exit=truelast configs saved in/etc/target/ Backup. Configuration saved To/etc/target/saveconfig.json

Reference documents:

1.http://linux-iscsi.org/wiki/targetcli

2.docs.redhat.com

This article from "candon123" blog, declined reprint!

Configure ISCSI Target on RHEL7

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.