Linux iSCSI Configuration

Source: Internet
Author: User
Tags cpu usage

iSCSI is a SAN device and the SAN device is primarily a space for providing Server storage. iSCSI (Internet SCSI) is an ip-based data storage device compared to a traditional SAN, which is a fiber-optic transmission medium. It makes it easier for him to apply in the enterprise. 1. The normal network card can be used as iSCSI target but the disadvantage is that it will consume too much CPU resources, in order to develop the other two kinds of iSCSI target network adapter. 2. A software iSCSI + TOE (TOE:TCP/IP offload E Ngine), which can operate on a network card for TCP/IP packets so it does not take up CPU usage on the system, 3. The other is hardware-based ISCSI + TOE. In addition to having TOE, it can also perform operations on iSCSI data. Basically it's used like a generic storage device HBA. You can do the iSCSI hardware boot action directly in the BIOS option.
The current RHEL5 and SLES10 have already treated iSCSI target as the default component, so previous versions such as RHEL4 need to use iSCSI target to introduce another set of IET (iSCSI Enterprise Target) First to download ISCSI Target we can see in the http://iscsitarget.sourceforge.net/. Use the latest version directly. Download Down is Source code so basic Linux (RedHat, Fedora ... ) can be edited directly using.
Configuration at the 1.Target end
The target side is a disk array or other host with disk installed. By mapping disk space to the network through the Iscsitarget tool, the initiator side can find and use the disk.
Note that a target host can map multiple target to the network, that is, you can map multiple block devices to the network.
1) package
Iscsitarget
You can download the latest version from http://sourceforge.net/projects/iscsitarget/files/.
2) Compile and install
It's simple, unpacking, compiling, installing.
Tar zxvf iscsitarget-1.4.19.tar.gz
CD iscsitarget-1.4.19/
Make
Make install
The package installs the kernel modules, user-level tools, service startup scripts, configuration files, man manuals, etc. required by iscsitarget into the system.
Including:
Iscsi_trgt.ko kernel Modules
Ietd Iscsitarget of the Guardian process
Ietadm Iscsitarget User-level management tools
/etc/init.d/iscsi-target Iscsitarget's startup script
/etc/ietd.conf configuration files for Iscsitarget
/etc/initiators.allow controls the access rights of the initiator to target.
/etc/initiators.deny controls the access rights of the initiator to target.
/etc/iet/targets.allow controls the access rights of different target.
3) configuration/etc/ietd.conf
Target iqn.2001-04.com.example:storage.disk2.sys1.xyz
Lun 0 Path=/dev/sda1,type=fileio
Alias Lun0
General Description:
Target IQN.2001-04.COM.EXAMPLE:STORAGE.DISK2.SYS1.XYZ indicates that the name of the iSCSI target, named in the same subnet should be unique, the standard naming method is:
"Target" + Target name (format 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.
The Type in this configuration is set to "FileIO" and I am primarily used to store a disk for sharing.
Of course, it can also be set to: "File" or "LVM".
In addition, there are many other parameters can be set, specific reference:
Http://manpages.ubuntu.com/manpages/hardy/man5/ietd.conf.5.html
4) Start Iscsitarget
/etc/init.d/iscsi-target start
2.inititor Terminal configuration
1) package
Source package is OPEN-ISCSI, after the RPM package package, 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) Connect target
First of all to ensure that the Iscsid daemon start, no test Iscsiadm a series of operations 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 a special setting.
To establish a connection to target:
Iscsiadm-m node-t <target-name>-P <ip-address>:<port>--login
Here Target-name is obtained for the previous step when target was found.
At this point, you can see the mapped disk through Fdisk-l, which can be formatted, partitioned, and so on as if you were using a local disk.
You can experiment with the following commands:
Fdisk/dev/sdc
Mkfs.ext3/dev/sdc1
Mount/dev/sdc1/mnt
DD If=/dev/zero f=100m.img bs=1m count=100
CHAP authentication is used between 3.target and initiator.
There are two types of CHAP authentication, one for discovery, that is, if the user name and password are not validated, then the initiator side cannot discover any target on the specified host through "-M discovery".
The command returns a validation 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 conform to the authentication, then the initiator can not log on to specify a target on the host by--login.
The command returns a validation failure, as follows:
$ iscsiadm-m discovery-t sendtargets-p 192.168.29.224 #成功discover指定主机上的target
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 #无法通过验证, 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) on the initiator side
To configure/etc/iscsi/iscsid.conf, add the following options:
#以下三个是针对discovery的.
#discovery时启用CHAP验证
Discovery.sendtargets.auth.authmethod = CHAP
#initiator的名字, can be another string, as long as the target side incominguse configuration of the name of the line
Discovery.sendtargets.auth.username = Iqn.1994-05.com.fedora:ba72af8aaf5
#验证密码, the same as the target side
Discovery.sendtargets.auth.password = 1234567890ab
#以下三个是针对login的.
#login时启用CHAP验证
Node.session.auth.authmethod = CHAP
#initiator的名字, can be another string, as long as the target side incominguse configuration of the name of the line
Node.session.auth.username = Iqn.1994-05.com.fedora:ba72af8aaf5
#验证密码, the same as the target side
Node.session.auth.password = 1234567890
Then restart Initiator.
/etc/init.d/iscsid stop
/etc/init.d/iscsid start
2) on the target side
For discovery configuration/etc/ietd.conf, at the global parameter (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 for the iSCSI client, the user name and password can be null, the default is Allow permission, and the password can be up to 12 characters long.
Here Iqn.1994-05.com.fedora:ba72af8aaf5 is initiator name (also can be other string), 1234567890ab is initiator password, name and password must and initiator/etc/ Iscsi/iscsid.conf
The user name password in the same. If not, the initiator execution of "-M discovery" will fail.
For login configuration/etc/ietd.conf, since it is for login, 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

iSCSI Operations Summary
Increase iSCSI Storage
(1) Discovery of iSCSI Storage:

Iscsiadm-m discovery-t st-p iscsi_ip
(2) To view iSCSI Discovery Records:

ISCSIADM-M node
(3) Log in to iSCSI storage:

Iscsiadm-m node-t lun_name-p iscsi_ip-l
(4) boot automatically:

Iscsiadm-m node–t lun_name-p iscsi_ip--op update-n node.startup-v Automatic
Remove iSCSI Storage
(1) Logging out of iSCSI storage

Iscsiadm-m node-t lun_name-p Iscsi_ip-u
(2) Log out of iSCSI all logins

ISCSIADM-M node--logoutall=all
(3) Delete iSCSI Discovery Records:

Iscsiadm-m node-o delete-t lun_name-p iscsi_ip
Log in to the node that requires verification code
(1) Open authentication
Iscsiadm-m node-t lun_name-o update--name Node.session.auth.authmethod--value=chap
*. Use-O with--op
(2) Add user
Iscsiadm-m node-t lun_name--op update--name node.session.auth.username--value=[user Name]
(3) Add password
Iscsiadm–m node–t lun_name–op update–name node.session.auth.password–value=[Password]

Linux iSCSI Configuration

Related Article

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.