Usage of tgtadm and ISCSIADM commands

Source: Internet
Author: User

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

I. TGTADM order
Tgtadm is often used to manage three types of objects:
Target: Create new, delete, view

LUNs: Creating, viewing, deleting

Account: Create user, bind, unbind, delete, view

Syntax: Tgtadm--lld [Driver]--op [operation]--mode [mode] [OPTION] ...

(1), add a new target and its ID is [ID], and the name is [name].
--LLD [Driver]--op new--mode target--tid=[id]--targetname [name]

For example, create a target
Tgtadm--lld iSCSI--op new--mode target--tid 1-t iqn.2013-05.com.magedu:tsan.disk1

(2), display all or a specific target:
--LLD [Driver]--op show--mode target [--tid=[id]]

such as: Show All
Tgtadm--lld iSCSI--op show--mode Target

(3) Add a new LUN to a device with an ID of [ID], the number is [LUN], and the device is available to initiator. [path] is the path to a block device, which can also be a RAID or LVM device. The lun0 has been reserved by the system.
--LLD [Driver]--op new--mode=logicalunit--tid=[id]--lun=[lun]--backing-store [path]

For example, display the target you just created
Tgtadm--lld iSCSI--op Show--mode target--tid 1

(4), delete target with ID [ID]:
--LLD [Driver]--op delete--mode target--tid=[id]

such as: Create LUN, number is 1
Tgtadm--lld iSCSI--op New--mode logicalunit--tid 1--lun 1-b/dev/sda1

(5), delete LUN [LUN] in Target [ID]:
-LLD [Driver]--op delete--mode=logicalunit--tid=[id]--lun=[lun]

For example: open to host access in 192.168.0.0/24 networks (where-I is equivalent to--initiator-address):
Tgtadm--lld iSCSI--op bind--mode target--tid 1-i 192.168.85.0/24


(6) A host-based access control list defining a target in which [address] represents a list of initiator clients that allow access to this target
--LLD [Driver]--op bind--mode=target--tid=[id]--initiator-address=[address]

such as: Create a new account
Tgtadm--lld iSCSI--op New--mode account--user Administrator--password 123456

Tgtadm--lld iSCSI--op show--mode Account

Assign This account to a target:
Tgtadm--lld iSCSI--op bind--mode account--tid 1--user Administrator

Tgtadm--lld iSCSI--op show--mode Target


(7), remove access control rights to [address] in Target [ID] 's access control list:
--LLD [Driver]--op unbind--mode=target--tid=[id]--initiator-address=[address]

such as: Set up a outgoing account. Need to create a new account like the previous example

Tgtadm--lld iSCSI--op new--mode account--user ABC--password 123456

Tgtadm--lld iSCSI--op show--mode Account

Tgtadm--lld iSCSI--op bind--mode account--tid 1--user ABC--outgoing

Tgtadm--lld iSCSI--op show--mode Target

Tgtadm Command common options:
-L--LLD <driver>: Here driver driver is iSCSI

-M--mode <mode>: Specifies the object of the operation, mode is target,logicalunit, etc.

-O--op [operation]: Actions to be taken on the specified object, operation Delete,new,bind,show,unbind, etc.

Option Common options:
-T--tid <id>: Used to specify the ID of target

-T--targetname <targetname>: Specifying target Name
Target's name format:
Iqn.xxxx-yy.reversedoamin.string[:substring]
which
IQN is a IQN prefix;
XXXX is the year;
YY is the month;
Reversedomain for the domain name of the reverse write;
string is a literal;
SUBSTRING is a substring;
such as Iqn.2015-11.com.a.web:server1

-L--lun <lun&gt: Specifies the number of the LUN

-B--backing-store <path&gt: associated with a backend storage device on a specified LUN, this example is a partition

-I--initiator-address <address&gt: Specifies the IP address that can access target

Specific Use please man Tgtadm

Two. Iscsiadm command
Iscsiadm is a modular tool that can be specified by the-m or--mode option, and the common patterns are discoverydb, node, FW, Session, host, Iface, and if no additional options are specified, Then discoverydb and node display all of their related records; session is used to display all active sessions and connections, FW displays all boot firmware values, host displays all iSCSI hosts, Iface displays/var/lib/iscsi/ All ifaces settings in the Ifaces directory.

Grammar:
ISCSIADM-M Discovery [D-Debug_level] [-P printlevel] [-I iface-t type-p ip:port [-l]]

ISCSIADM-M node [D-Debug_level] [-P printlevel] [l all,manual,automatic] [-u all,manual,automatic] [[t Tar-g Etname-p ip:port-i Iface] [-L |-u |-r |-S]] [[O operation]

-D--debug=debug_level #显示debug信息 with a level of 0-8;

-L--login #登入节点 (server)

-T--type=type #这里可以使用的类型为sendtargets (ST), SLP, FW, and iSNS, this option is only for discovery mode and currently supports only St, FW, and iSNS Where St indicates that each iscsitarget is allowed to send an available target list to initiator;

-P--portal=ip[:p ort] #指定target服务的IP和端口;

-M--mode op #可用的mode有discovery, node, FW, host Iface and session

-T--targetname=targetname #用于指定target的名字

-U--logout #登出节点 (server)

-O--op=opeartion: Specifies operations for the DISCOVERYDB database, which can only be one of the new, delete, update, show, and nonpersistent;

-I--interface=[iface] #指定执行操作的iSCSI接口, these interfaces are defined in/var/lib/iscsi/ifaces

Specific Use please man Iscsiadm

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.