iscsi使用教程(下)

Posted 银魔术师

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了iscsi使用教程(下)相关的知识,希望对你有一定的参考价值。

动态创建目标

安装iscsi服务端

# yum install -y scsi-target-utils.x86_64

修改配置文件

# mkdir -p ~/volumes
# sed -i ‘$ i include /root/volumes/*‘ /etc/tgt/tgtd.conf

启动服务

### 有告警是正常的,因为我们现在还没配置目标
# tgtd -f --iscsi portal=92.0.0.14:3260
tgtd: iser_ib_init(3436) Failed to initialize RDMA; load kernel modules?
tgtd: work_timer_start(146) use timer_fd based scheduler
tgtd: bs_init_signalfd(267) could not open backing-store module directory /usr/lib64/tgt/backing-store
tgtd: bs_init(386) use signalfd notification

新增磁盘并创建LV

# pvcreate /dev/sda
# vgcreate cinder-volumes /dev/sda
# lvcreate -n vol cinder-volumes -L 1g

创建目标配置文件

# tee /root/volumes/vol.conf << EOF
<target iqn.2010-10.org.openstack:vol>
    backing-store /dev/cinder-volumes/vol
    driver iscsi
    write-cache on
</target>
EOF

动态更新目标

# tgt-admin --update iqn.2010-10.org.openstack:vol

查询目标信息

# tgtadm --lld iscsi --op show --mode target
Target 1: iqn.2010-10.org.openstack:vol
    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
            SWP: No
            Thin-provisioning: No
            Backing store type: null
            Backing store path: None
            Backing store flags:
        LUN: 1
            Type: disk
            SCSI ID: IET     00010001
            SCSI SN: beaf11
            Size: 1074 MB, Block size: 512
            Online: Yes
            Removable media: No
            Prevent removal: No
            Readonly: No
            SWP: No
            Thin-provisioning: No
            Backing store type: rdwr
            Backing store path: /dev/cinder-volumes/vol
            Backing store flags:
    ### 允许连接的客户端用户名
    Account information:
    ### 允许连接的客户端地址
    ACL information:
        ALL

安装客户端

# yum install iscsi-initiator-utils.x86_64 -y

发现目标

# iscsiadm -m discovery -t sendtargets -p 92.0.0.14
92.0.0.14:3260,1 iqn.2010-10.org.openstack:vol

连接目标

# iscsiadm -m node -T iqn.2010-10.org.openstack:vol -p 92.0.0.14 -l
Logging in to [iface: default, target: iqn.2010-10.org.openstack:vol, portal: 92.0.0.14,3260] (multiple)
Login to [iface: default, target: iqn.2010-10.org.openstack:vol, portal: 92.0.0.14,3260] successful.

# iscsiadm -m session
tcp: [1] 92.0.0.14:3260,1 iqn.2010-10.org.openstack:vol (non-flash)

断开连接

# iscsiadm -m node -T iqn.2010-10.org.openstack:vol -p 92.0.0.14 -u
Logging out of session [sid: 2, target: iqn.2010-10.org.openstack:vol, portal: 92.0.0.14,3260]
Logout of [sid: 2, target: iqn.2010-10.org.openstack:vol, portal: 92.0.0.14,3260] successful.

# iscsiadm -m session
iscsiadm: No active sessions.

以上是关于iscsi使用教程(下)的主要内容,如果未能解决你的问题,请参考以下文章

iscsi使用教程(上)

iscsi使用教程(中)

Hyper-V 2016 系列教程32 StartWind 虚拟NFS,iSCSI软件

如何在vSphere环境下使用iSCSI存储

Hyper-V 2016 系列教程24 配置 iSCSI存储服务器

Linux下搭建iSCSI共享存储