1. 程式人生 > >iscsi使用教程(下)

iscsi使用教程(下)

動態創建 init event multipl online visio out opensta 動態更新

動態創建目標

安裝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使用教程(下)