配置舉例
更新時間 2025-04-23 15:02:32
最近更新時間: 2025-04-23 15:02:32
分享文章
本節給出Linux客戶端掛載HBlock單機版的卷示例。
應用場景
- Linux客戶端需要連接HBlock單機版的卷。
- 需要連接的HBlock單機版的卷為lund1和lunf1,lund1有CHAP認證。
前置條件
- 對于需要連接HBlock單機版的客戶端,已經按照客戶端配置的前置條件成準備工作。
- 對于HBlock服務器端,已經成功創建卷lund1和lunf1。
操作步驟
-
HBlock服務器端:查詢要連接的LUN及LUN對應iSCSI Target的詳細信息。
[root@hblockserver CTYUN_HBlock_Plus_3.9.0_x64]# ./stor lun ls -n lund1 LUN Name: lund1 (LUN 0) Storage Mode: Local Capacity: 500 GiB Status: Normal iSCSI Target: iqn.2012-08.cn.ctyunapi.oos:targetd.4(192.168.0.32:3260,Active) Create Time: 2024-05-21 10:00:34 Local Sector Size: 4096 bytes Write Policy: WriteBack WWID: 33000000068f2f320 UUID: lun-uuid-3ddcc779-bf34-42b9-ac5e-0339dae28821 Path: /mnt/storage01 Snapshot Numbers: 0 [root@hblockserver CTYUN_HBlock_Plus_3.9.0_x64]# ./stor target ls -n targetd Target Name: targetd Max Sessions: 2 Create Time: 2024-05-21 09:59:12 iSCSI Target: iqn.2012-08.cn.ctyunapi.oos:targetd.4(192.168.0.32:3260) LUN: lund1(LUN 0) CHAP: testd,T12345678912,Enabled [root@hblockserver CTYUN_HBlock_Plus_3.9.0_x64]# ./stor lun ls -n lunf1 LUN Name: lunf1 (LUN 0) Storage Mode: Local Capacity: 600 GiB Status: Normal iSCSI Target: iqn.2012-08.cn.ctyunapi.oos:targetf.5(192.168.0.32:3260,Active) Create Time: 2024-05-21 10:00:56 Local Sector Size: 4096 bytes Write Policy: WriteBack WWID: 33000000030f798a5 UUID: lun-uuid-7b7f91d8-b75e-4de2-ac69-621e4be7a0cf Path: /mnt/storage01 Snapshot Numbers: 0 [root@hblockserver CTYUN_HBlock_Plus_3.9.0_x64]# ./stor target ls -n targetf Target Name: targetf Max Sessions: 2 Create Time: 2024-05-21 10:00:15 iSCSI Target: iqn.2012-08.cn.ctyunapi.oos:targetf.5(192.168.0.32:3260) LUN: lunf1(LUN 0) -
Linux客戶端
-
發現lund1和lunf1的Target:
[root@client ~]# iscsiadm -m discovery -t st -p 192.168.0.32 192.168.0.32:3260,1 iqn.2012-08.cn.ctyunapi.oos:targetf.5 192.168.0.32:3260,1 iqn.2012-08.cn.ctyunapi.oos:targetd.4 192.168.0.32:3260,1 iqn.2012-08.cn.ctyunapi.oos:targetc.3 -
登錄iSCSI存儲。
-
登錄lund1的iSCSI存儲,需要進行CHAP認證:
[root@client ~]# iscsiadm -m node -T iqn.2012-08.cn.ctyunapi.oos:targetd.4 -o update --name node.session.auth.authmethod --value=CHAP [root@client ~]# iscsiadm -m node -T iqn.2012-08.cn.ctyunapi.oos:targetd.4 -o update --name node.session.auth.username --value=testd [root@client ~]# iscsiadm -m node -T iqn.2012-08.cn.ctyunapi.oos:targetd.4 -o update --name node.session.auth.password --value=************* [root@client ~]# iscsiadm -m node -T iqn.2012-08.cn.ctyunapi.oos:targetd.4 -p 192.168.0.32:3260 -l Logging in to [iface: default, target: iqn.2012-08.cn.ctyunapi.oos:targetd.4, portal: 192.168.0.32,3260] (multiple) Login to [iface: default, target: iqn.2012-08.cn.ctyunapi.oos:targetd.4, portal: 192.168.0.32,3260] successful. -
登錄lunf1的iSCSI存儲
[root@client ~]# iscsiadm -m node -T iqn.2012-08.cn.ctyunapi.oos:targetf.5 -p 192.168.0.32:3260 -l Logging in to [iface: default, target: iqn.2012-08.cn.ctyunapi.oos:targetf.5, portal: 192.168.0.32,3260] (multiple) Login to [iface: default, target: iqn.2012-08.cn.ctyunapi.oos:targetf.5, portal: 192.168.0.32,3260] successful.
-
-
顯示會話情況,查看當前iSCSI連接。
[root@client ~]# iscsiadm -m session tcp: [1] 192.168.0.32:3260,1 iqn.2012-08.cn.ctyunapi.oos:targetd.4 (non-flash) tcp: [2] 192.168.0.32:3260,1 iqn.2012-08.cn.ctyunapi.oos:targetf.5 (non-flash) -
查看iSCSI磁盤、磁盤對應的LUN(通過lsscsi -i可以查看LUN的wwid)。
[root@client ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 500G 0 disk sdb 8:16 0 600G 0 disk vda 253:0 0 40G 0 disk ├─vda1 253:1 0 4G 0 part └─vda2 253:2 0 36G 0 part / vdb 253:16 0 100G 0 disk └─vdb1 253:17 0 100G 0 part /mnt/storage01 vdc 253:32 0 100G 0 disk vdd 253:48 0 100G 0 disk [root@client ~]# lsscsi -i [2:0:0:0] disk CTYUN iSCSI LUN Device 1.00 /dev/sda 33000000068f2f320 [3:0:0:0] disk CTYUN iSCSI LUN Device 1.00 /dev/sdb 33000000030f798a5說明可以看出/dev/sda對應HBlock卷lund1(卷WWID為33000000068f2f320),/dev/sdb對應HBlock卷lunf1(卷WWID為33000000030f798a5)。
-
格式化iSCSI磁盤。
[root@client ~]# mkfs.ext4 /dev/sda mke2fs 1.42.9 (28-Dec-2013) /dev/sda is entire device, not just one partition! Proceed anyway? (y,n) y Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 32768000 inodes, 131072000 blocks 6553600 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=2279604224 4000 block groups 32768 blocks per group, 32768 fragments per group 8192 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968, 102400000 Allocating group tables: done Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done [root@client ~]# mkfs.ext4 /dev/sdb mke2fs 1.42.9 (28-Dec-2013) /dev/sdb is entire device, not just one partition! Proceed anyway? (y,n) y Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 39321600 inodes, 157286400 blocks 7864320 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=2304770048 4800 block groups 32768 blocks per group, 32768 fragments per group 8192 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968, 102400000 Allocating group tables: done Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done -
掛載iSCSI磁盤。
將iSCSI磁盤分區掛載到本地目錄上,掛載之后可以寫入數據。
[root@client ~]# mount /dev/sda /mnt/disk_sda [root@client ~]# mount /dev/sdb /mnt/disk_sdb [root@client ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 500G 0 disk /mnt/disk_sda sdb 8:16 0 600G 0 disk /mnt/disk_sdb vda 253:0 0 40G 0 disk ├─vda1 253:1 0 4G 0 part └─vda2 253:2 0 36G 0 part / vdb 253:16 0 100G 0 disk └─vdb1 253:17 0 100G 0 part /mnt/storage01 vdc 253:32 0 100G 0 disk vdd 253:48 0 100G 0 disk
-