配置使用iscsi

配置使用iscsi

请确保服务器A上已经关闭了防火墙或者允许了3260端口。下图描述了使用iSCSI的大致过程,后文内容虽然因为介绍各种用法而显得比较杂,但根据这张图的流程,阅读时很容易搞清楚相关内容。

gtadm是一个高度模式化的命令,他们的模式很相近。有三个模式:target、logicalunit、account。指定模式时使用--mode选项。再使用--op来指定对应模式下的选项。另外,使用-lld指定driver,有两种driver:iscsi和iser,基本都会使用iscsi。

tgtadm --help
  --lld <driver> --mode target --op new --tid <id> --targetname <name>
                        add a new target with <id> and <name>. <id> 
                        must not be zero.
  --lld <driver> --mode target --op delete [--force] --tid <id>
                        delete the specific target with <id>.
                        With force option, the specific target is 
                        deleted even if there is an activity.
  --lld <driver> --mode target --op show
                        show all the targets.
  --lld <driver> --mode target --op show --tid <id>
                        show the specific target's parameters.
  --lld <driver> --mode target --op update --tid <id> --name <param> --value <value>
                        change the target parameters of the specific target with <id>.
  --lld <driver> --mode target --op bind --tid <id> --initiator-address <address>
  --lld <driver> --mode target --op bind --tid <id> --initiator-name <name>
                        enable the target to accept the specific initiators.
  --lld <driver> --mode target --op unbind --tid <id> --initiator-address <address>
  --lld <driver> --mode target --op unbind --tid <id> --initiator-name <name>
                        disable the specific permitted initiators.
  --lld <driver> --mode logicalunit --op new --tid <id> --lun <lun> --backing-store <path> --bstype <type> --bsoflags <options>
                        add a new logical unit with <lun> to the specific
                        target with <id>. The logical unit is offered
                        to the initiators. <path> must be block device files
                        (including LVM and RAID devices) or regular files. 
                        bstype option is optional.
                        bsoflags supported options are sync and direct
                        (sync:direct for both).
  --lld <driver> --mode logicalunit --op delete --tid <id> --lun <lun>
                        delete the specific logical unit with <lun> that the target with <id> has.
  --lld <driver> --mode account --op new --user <name> --password <pass>
                        add a new account with <name> and <pass>.
  --lld <driver> --mode account --op delete --user <name>
                        delete the specific account having <name>.
  --lld <driver> --mode account --op bind --tid <id> --user <name> [--outgoing]
                        add the specific account having <name> to 
                        the specific target with <id>.
                        <user> could be <IncomingUser> or <OutgoingUser>.
                        If you use --outgoing option, the account will be
                        added as an outgoing account.
  --lld <driver> --mode account --op unbind --tid <id> --user <name>
                        delete the specific account having <name> from specific target.
  --control-port <port> use control port <port>

 

 

 上表中的选项都是长格式的,但他们都有对应的短格式选项。

 

tgt-admin是读取配置文件的选项然后调用tgtadm来执行的工具。它的选项很多可以简化tgtadm命令的书写,毕竟tgtadm的选项太长太多余了,除此之外也有一些其他的作用用于更细致的配(tgtadm配置的太粗糙了)。用法如下:

 

参考资料

1. Linux上配置使用iSCSI详细说明

posted @ 2023-06-28 14:37  苏格拉底的落泪  阅读(19)  评论(0编辑  收藏  举报