iSCSI Target/initiator

  
 

1. Target side configuration The target side is the disk array or other host with disk. The disk space is mapped to the network by the iscsitarget tool, and the initiator can find and discover the disk. Note that a target host can map multiple targets to the network, that is, multiple block devices can be mapped to the network. 1) Package iscsitarget The latest version can be downloaded from http://sourceforge.net/projects/iscsitarget/files/. 2) Compile and install Very simple, unpack, compile, and install. Tar zxvf iscsitarget-1.4.19.tar.gz cd iscsitarget-1.4.19/make make install This package will install the kernel modules, user layer tools, service startup scripts, configuration files, man pages, etc. required by iscsitarget into the system. : iscsi_trgt.ko kernel module ietd iscsitarget daemon ietadm iscsitarget user layer management tool /etc/init.d/iscsi-target iscsitarget startup script /etc/ietd.conf iscsitarget configuration file /etc/initiators.allow control initiator Access to the target. /etc/initiators.deny Controls the access rights of the initiator to the target. /etc/iet/targets.allow Controls the access rights of different targets. 3) Configure /etc/ietd.conf

Target iqn.2001-04.com.example:storage.disk2.sys1.xyz Lun 0 Path=/dev/sda1,Type=fileio Alias ​​lun0

Overview: Target iqn.2001-04.com.example:storage.disk2.sys1.xyz indicates the naming of the ISCSI Target. The naming should be unique within the same subnet. The standard naming method is: "Target "+ target name (format is as follows: iqn.yyyy-mm.<reversed domain name>[:identifier] ) “Lun 0 Path=/dev/sda1” indicates that the block device number is 0 and the mapped disk is /dev /sda1. In this configuration, the Type is set to "fileio", which I mainly use to store and share a disk. Of course, you can also set it to: "file" or "LVM". In addition to this there are many other parameters that can be set, for specific reference: http://manpages.ubuntu.com/manpages/hardy/man5/ietd.conf.5.html

4) Start iscsitarget /etc /init.d/iscsi-target start

2.inititor configuration 1) The package source package is open-iscsi. After rpm package encapsulation, the name is iscsi-initiator-utils. 2) The following files are mainly installed /etc/iscsi/iscsid.conf /etc/rc.d/init.d/iscsi /etc/rc.d/init.d/iscsid /sbin/iscsi-iname /sbin/iscsiadm /sbin/iscsid /sbin/iscsistart /var/lib/iscsi /var/lib/iscsi/ifaces /var/lib/iscsi/isns /var/lib/iscsi/nodes /var/lib/iscsi/send_targets /var/lib /iscsi/slp /var/lib/iscsi/static /var/lock/iscsi

3) Connecting the target First, ensure that the iscsid daemon starts, or a series of operations that detect iscsiadm will fail: /etc/init .d/iscsid start

Discover target: iscsiadm -m discovery -t sendtargets -p <iSCSI target ip>:<port> By default, <port> is 3260 unless you have special settings .

Connect to target: iscsiadm -m node -T <target-name> -p <ip-address>:<port> --login where target-name is the target found in the previous step Obtained.

At this point, you can see the mapped disk through fdisk -l. The disk can be formatted, partitioned, etc. as if it were a local disk. You can experiment with the following command: fdisk /dev/sdc mkfs.ext3 /dev/sdc1 mount /dev/sdc1 /mnt dd if=/dev/zero of=100M.img bs=1M count=100

3 Use CHAP authentication between .target and initiator. There are two types of CHAP authentication. One is for discovery. If the username and password are not verified, the initiator will not be able to discover any target on the specified host through "-m discovery". The command will return a verification failure as follows: $ iscsiadm -m discovery -t sendtargets -p 192.168.29.224 iscsiadm: Login failed to authenticate with target iscsiadm: discovery login to 192.168.29.224 rejected: initiator error (02/01), non-retryable , giving up

The other is for node login, that is, if the user name and password do not match the authentication, the initiator can not log in to a target on the specified host through --login. The command will return a verification failure as follows: $ iscsiadm -m discovery -t sendtargets -p 192.168.29.224 # successful discover the target on the specified host 192.168.29.224:3260,1 iqn.2001-04.com.example:storage.disk2. Sys1.xyz $ iscsiadm -m node -T iqn.2001-04.com.example:storage.disk2.sys1.xyz -p 192.168.29.224 --login #Unable to pass validation, login failed Logging in to [iface: default, Target: iqn.2001-04.com.example:storage.disk2.sys1.xyz, portal: 192.168.29.224,3260] iscsiadm: Could not login to [iface: default, target: iqn.2001-04.com.example :storage.disk2.sys1.xyz, portal: 192.168.29.224,3260]: iscsiadm: initiator reported error (15 - already exists)

1) Configure /etc/iscsi/iscsid.conf on the initiator side, Add the following options: #The following three are for discovery. #discovery Enable CHAP authentication. discovery.sendtargets.auth.authmethod = CHAP #initiator name, or other string, as long as the name of the target IncomingUse is configured. discovery.sendtargets.auth.username = iqn.1994- 05.com.fedora:ba72af8aaf5 #Verify the password, the same as the target side discovery.sendtargets.auth.password = 1234567890ab

#The following three are for login. #login Enable CHAP authentication node.session.auth.authmethod = CHAP #initiator name, or other string, as long as the name configured by the target IncomingUse is on the node.session.auth.username = iqn.1994- 05.com.fedora:ba72af8aaf5 #Verify the password, the same as the target side node.session.auth.password = 1234567890

Then restart the initiator. /etc/init.d/iscsid stop /etc/init.d/iscsid start

2) Configure /etc/ietd.conf for discovery on the target side, at global parameters (before defining the first target) ), add the following line: IncomingUser iqn.1994-05.com.fedora:ba72af8aaf5 1234567890ab IncomingUser and OutgoingUser represent the user name and password of the ISCSI client, the username and password can be empty, the default is allow, the password can be up to 12 character. Here iqn.1994-05.com.fedora:ba72af8aaf5 is the name of the initiator (can also be another string), 1234567890ab is the password of the initiator, the name and password must be in the /etc/iscsi/iscsid.conf on the initiator The username and password are the same. If it is inconsistent, the initiator will execute "-m discovery" and it will fail.

Configure /etc/ietd.conf for login, since it is for login, then adding IncomingUser is the specified target that should be added. As follows: Target iqn.2001-04.com.example:storage.disk2.sys1.xyz Lun 0 Path=/dev/sda1,Type=fileio IncomingUser iqn.1994-05.com.fedora:ba72af8aaf5 1234567890

Then restart iscsitarget /etc/init.d/iscsi-target stop /etc/init.d/iscsi-target start

Copyright © Windows knowledge All Rights Reserved