Target/initiator Configuration of iSCSI

Source: Internet
Author: User


Prepare the Environment

Target:node1 192.168.139.2

Initiator1:node2 192.168.139.4

Initiatos2:node4 192.168.139.8

Target: Install Scsi-target-utils

Initiatos: Installing Scsi-initiator-utils


For more information about iSCSI and SCSI, see http://11107124.blog.51cto.com/11097124/1884637


Create a partition to make a SCSI storage disk, preferably with an entire disk partition

[Email protected] ~]# Fdisk/dev/sdb

[Email protected] ~]# Partprobe/dev/sdb

[Email protected] ~]# fdisk-l

Device Boot Start End Blocks Id System

/DEV/SDB1 1 654 5253223+ Linux

/DEV/SDB2 655 1308 5253255-up Linux

/DEV/SDB3 1309 1701 156772+-up Linux

[email protected] ~]# Yum install scsi-target-utils-y

[Email protected] ~]# RPM-QL scsi-target-utils

/ETC/RC.D/INIT.D/TGTD \ \ Service Script

/etc/sysconfig/tgtd

/etc/tgt/targets.conf \ \ config file

/usr/sbin/tgt-admin \ \ Create the target and LUN when the service is started by reading the configured files

/usr/sbin/tgt-setup-lun

/usr/sbin/tgtadm \ \ \ \ In the Dream. Tools for creating target and LUNs

/usr/sbin/tgtd

[[Email protected] ~]# service TGTD start

Starting SCSI target daemon: [OK]

[Email protected] ~]# NETSTAT-TNLP |grep TGTD

TCP 0 0 0.0.0.0:3260 0.0.0.0:* LISTEN 1820/TGTD

TCP 0 0::: 3260:::* LISTEN 1820/TGTD


The Tatadm command is a highly modeled command:

Usage:tgtadm--lld [Driver]--op [operation]--mode [mode] [OPTION] ...


-L/--LLD specifies that the drive is typically iSCSI

-t/--tid the ID of the specified target

-l/--lun Specifying LUN ID

-b/--back-store specifying a true back-end storage device

-i/--initiators-ddress Specifies that initiators IP is typically used to bind target and initiators for authorization

-T/--TARGETNAME Specifies the name of the target to distinguish between multiple different target

--mode create target as Target and create Logicalunit as Logicalunit

--op new Delete show update bind unbind

(Bind/unbind is often used to bind initiator's address to target, thereby authorizing its use)

TATADM command detailed use see: http://blog.chinaunix.net/uid-30212356-id-5520545.html


A maximum of 32 LUNs can be on a target

Syntax for Target name: IQN.YYYY-XX.COM.ZXL: Rack. Disk

INQ iSCSI globally Unique identifier name

YYYY-XX year-month: 2016-12

COM.ZXL the reverse of your company's domain name

Rack. The disk is used to differentiate the specific location of the disk, which is the disc

such as: Iqn.2016-12.com.zxl:store.disk1


[[email protected] ~]# tgtadm--lld iSCSI--mode Target--op New--targetname iqn.2016-12.com.zxl:store1.disk1--tid 1

Driver: iSCSI

Targetname:iqn.2016-12.com.zxl:store1.disk1

Target id:1 (0 reserved for the system to be used by the current host)

[[email protected] ~]# tgtadm--lld iSCSI--mode target--op show \ \ View created target

Target 1:iqn.2016-12.com.zxl:store1.disk1

System Information:

Driver:iscsi

State:ready

i_t Nexus Information:

LUN Information:

lun:0

Type:controller \ Type Controller (director)

SCSI Id:iet 00010000

SCSI SN:BEAF10

size:0 MB, Block size:1

Online:yes

Removable Media:no

Prevent Removal:no

Readonly:no

Backing store Type:null

Backing store Path:none

Backing Store Flags:

Account information:

ACL Information:

Create Logicalunit, and correlate back-end storage

[[email protected] ~]# tgtadm--lld iSCSI--mode logicalunit--op New--tid 1--lun 1--backing-store/dev/sdb1

Create a logicalunit with a LUN ID of 1 at Target with Target ID 1 and a back-end storage device of/DEV/SDB1

Note: When I use--BACKING-STORE/DEV/SDB2 or/DEV/SDB3, I can't create the following error, probably because the/dev/sdb2/dev/sdb3 you just created is not recognized by the kernel (I used partprobe), It is recommended to use the entire disk when actually using, do not use partition

Tgtadm:invalid Request

[[email protected] ~]# tgtadm--lld iSCSI--mode Target--op Show

Target 1:iqn.2016-12.com.zxl:store1.disk1

System Information:

Driver:iscsi

State:ready

i_t Nexus Information:

LUN Information:

lun:0

Type:controller

SCSI Id:iet 00010000

SCSI SN:BEAF10

size:0 MB, Block size:1

Online:yes

Removable Media:no

Prevent Removal:no

Readonly:no

Backing store Type:null

Backing store Path:none

Backing Store Flags:

Lun:1

Type:disk \ \ Type is disk

SCSI Id:iet 00010001

SCSI sn:beaf11

size:5379 MB, Block size:512

Online:yes

Removable Media:no

Prevent Removal:no

Readonly:no

Backing store Type:rdwr

Backing store Path:/DEV/SDB1

Backing Store Flags:

Account information:

ACL Information:


There are two types of authentication methods for clients to ensure the security of different user data:

1: IP-based

2: User-based CHAP (CHAP for two-way authentication server Authentication Client,client also authentication server)


IP-based authentication for initiators will be performed below

[[email protected] ~]# tgtadm--lld iSCSI--mode target--op bind--tid 1--initiator-address 192.168.139.0/24


Allow all hosts from the 192.168.139.0/24 network segment to access target with Target ID 1

[[email protected] ~]# tgtadm--lld iSCSI--mode Target--op Show

Account information:

ACL information:192.168.139.0/24


Installed in Node2 (192.168.139.4) iscsi-initiator-utils

[Email protected] ~]# yum-y install Iscsi-initiator-utils

[Email protected] ~]# RPM-QL iscsi-initiator-utils

/etc/iscsi

/etc/iscsi/iscsid.conf \ \ config file

/etc/logrotate.d/iscsiuiolog

/ETC/RC.D/INIT.D/ISCSI \ \ Service Script

/ETC/RC.D/INIT.D/ISCSID \ \ Service script, just start iSCSI to start Iscsid

/sbin/iscsi-iname \\-p itself specifies the iqn name prefix of the initiator, which is automatically generated by the system and saved in the/etc/iscsi/initiatorname.iscsi file

/SBIN/ISCSIADM \ \ Client Command

/var/lib/iscsi/ifaces \ \ Can choose which NIC to exchange data with target



Iscsiadm is also a modal command that is the client's command


-M {Discovery|node|session|iface}

Discovery: Discover if a server has a target output and what output

Node: Establish a connection to the server side as a node

Session: Viewing Sessions

Iface: Interface Management

-d:debug_lebel level 0-8 Higher output debug information more detailed, can be omitted

-I: Specifies which network interface to use, if only one NIC is not specified

-t:sendtarget,slp,isns three kinds of forms, generally we use the Sendtarget shorthand for St

-p:ip:port IP for server ip,port can be omitted, default is 3260


The target associated with the login target is found after the

-U Log Out

-R Log in again

-L Log In

-t Specifies targetname

-p Specifies the ip/port of the server

-S displays the session statistics

-op some other operations

......

Iscsiadm command Detailed use can refer to here

Http://blog.chinaunix.net/uid-30212356-id-5520545.html



[Email protected] ~]# iscsiadm-m discovery-d 2-t st-p 192.168.139.2:3260

Iscsiadm:max file Limits 1024 4096


Iscsiadm:starting sendtargets Discovery, Address 192.168.139.2:3260,

Iscsiadm:connecting to 192.168.139.2:3260

Iscsiadm:connected Local port 52104 to 192.168.139.2:3260

iscsiadm:connected to Discovery address 192.168.139.2

Iscsiadm:login response status 0000

Iscsiadm:discovery process to 192.168.139.2:3260 exiting

Iscsiadm:disconnecting Conn 0xad5a78, FD 3

192.168.139.2:3260,1 Iqn.2016-12.com.zxl:store1.disk1


You can see the target:iqn.2016-12.com.zxl:store1.disk1 that found the node2 output.


For Target Login

[Email protected] ~]# iscsiadm-m node-t iqn.2016-12.com.zxl:store1.disk1-p 192.168.139.2-l

Logging in to [Iface:default, Target:iqn.2016-12.com.zxl:store1.disk1, portal:192.168.139.2,3260] (multiple)

Login to [Iface:default, Target:iqn.2016-12.com.zxl:store1.disk1, portal:192.168.139.2,3260] successful.

Successful (login successful)


[[email protected] ~]# fdisk-l \ \ Can see a/dev/sdc size of about 5G, the server side of the target associated LUN \ \ Device is recognized for local storage, and a partition is recognized as a Entire disk

disk/dev/sdc:5379 MB, 5379300864 bytes

166 heads, Sectors/track, 1020 cylinders


Create a partition on/DEV/SDC

[Email protected] ~]# FDISK/DEV/SDC

Device Boot Start End Blocks Id System

/DEV/SDC1 1 612 3149321 Linux


[[email protected] ~]# PARTPROBE/DEV/SDC \ \ Notify kernel recognition

[[email protected] ~]# mke2fs-j/DEV/SDC1 \ \ format to ext3 file system

[[email protected] ~]# mount/dev/sdc1/mnt \ \ Mount

[[email protected] ~]# cp/etc/issue/mnt \ \ copy a file past

[Email protected] ~]# cd/mnt

[email protected] mnt]# ll \\OK

Total 20

-rw-r--r--. 1 root root 10:28 issue

DRWX------. 2 root root 16384 Dec 10:27 lost+found



After joining a node4 (192.168.139.8) as a second initiator


[email protected] ~]# Yum install-y iscsi-initiator-utils

[Email protected] ~]# iscsiadm-m discovery-t st-p 192.168.139.2

Starting iscsid: [OK]

192.168.139.2:3260,1 Iqn.2016-12.com.zxl:store1.disk1

[Email protected] ~]# iscsiadm-m node-t iqn.2016-12.com.zxl:store1.disk1-p 192.168.139.2-l

Logging in to [Iface:default, Target:iqn.2016-12.com.zxl:store1.disk1, portal:192.168.139.2,3260] (multiple)

Login to [Iface:default, Target:iqn.2016-12.com.zxl:store1.disk1, portal:192.168.139.2,3260] successful.

[Email protected] ~]# fdisk-l

disk/dev/sdc:5379 MB, 5379300864 bytes

166 heads, Sectors/track, 1020 cylinders

Device Boot Start End Blocks Id System

/DEV/SDC1 1 612 3149321 Linux

[Email protected] ~]# mount/dev/sdc1/mnt

[Email protected] ~]# cd/mnt

[[email protected] mnt]# ll \ \ Can see Node2 copy of issue file Node4 page can see

Total 20

-rw-r--r--. 1 root root 10:28 issue

DRWX------. 2 root root 16384 Dec 10:27 lost+found


This experiment was completed


This article is from the "11097124" blog, please be sure to keep this source http://11107124.blog.51cto.com/11097124/1884645

Target/initiator Configuration of iSCSI

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.