IT技术互动交流平台

使用iSCSI挂载QNAP存储(byquqi99)

来源:IT165收集  发布日期:2015-12-28 20:03:47

作者:张华 发表于:2015-12-28
版权声明:可以任意转载,转载时请务必以超链接形式标明文章原始出处和作者信息及本版权声明

( http://blog.csdn.net/quqi99 )

 

QNAP服务端

系统设置 -> 存储空间总管 -> iSCSI选项卡
入口管理: 启动iSCSI目标服务
iSCSI目标管理:创建一个iSCSI目标并挂载一个iSCSI LUN
iqn.2004-04.com.qnap:ts-212p:iscsi.quqiSCSI.d5ad13
目标名称:quqiSCSI
目标别名:quqiSCSI
启用CHAP认证:username/password
动态配置:quqiSCSI, 800G
 

iSCSI Initiator客户端

hua@node1:~$ sudo /etc/init.d/open-iscsi start

hua@node1:~$ sudo update-rc.d -f open-iscsi remove
Removing any system startup links for /etc/init.d/open-iscsi ...
/etc/rc0.d/K81open-iscsi
/etc/rc0.d/S45open-iscsi
/etc/rc1.d/K81open-iscsi
/etc/rc6.d/K81open-iscsi
hua@node1:~$ sudo update-rc.d open-iscsi start 20 2 3 4 5 . stop 20 0 1 6 .
update-rc.d: warning: start runlevel arguments (2 3 4 5) do not match open-iscsi Default-Start values (S)
Adding system startup for /etc/init.d/open-iscsi ...
/etc/rc0.d/K20open-iscsi -> ../init.d/open-iscsi
/etc/rc1.d/K20open-iscsi -> ../init.d/open-iscsi
/etc/rc6.d/K20open-iscsi -> ../init.d/open-iscsi
/etc/rc2.d/S20open-iscsi -> ../init.d/open-iscsi
/etc/rc3.d/S20open-iscsi -> ../init.d/open-iscsi
/etc/rc4.d/S20open-iscsi -> ../init.d/open-iscsi
/etc/rc5.d/S20open-iscsi -> ../init.d/open-iscsi
hua@node1:~$ sudo update-rc.d open-iscsi enable
update-rc.d: warning: start runlevel arguments (none) do not match open-iscsi Default-Start values (S)
update-rc.d: warning: stop runlevel arguments (none) do not match open-iscsi Default-Stop values (0 1 6)
Enabling system startup links for /etc/init.d/open-iscsi ...
Removing any system startup links for /etc/init.d/open-iscsi ...
/etc/rc0.d/K20open-iscsi
/etc/rc1.d/K20open-iscsi
/etc/rc2.d/S20open-iscsi
/etc/rc3.d/S20open-iscsi
/etc/rc4.d/S20open-iscsi
/etc/rc5.d/S20open-iscsi
/etc/rc6.d/K20open-iscsi
Adding system startup for /etc/init.d/open-iscsi ...
/etc/rc0.d/K20open-iscsi -> ../init.d/open-iscsi
/etc/rc1.d/K20open-iscsi -> ../init.d/open-iscsi
/etc/rc6.d/K20open-iscsi -> ../init.d/open-iscsi
/etc/rc2.d/S20open-iscsi -> ../init.d/open-iscsi
/etc/rc3.d/S20open-iscsi -> ../init.d/open-iscsi
/etc/rc4.d/S20open-iscsi -> ../init.d/open-iscsi
/etc/rc5.d/S20open-iscsi -> ../init.d/open-iscsi
hua@node1:~$ sudo sysv-rc-conf --list open-iscsi
open-iscsi 0:off 1:off 2:on 3:on 4:on 5:on 6:off

 


vi /etc/iscsi/iscsid.conf
node.startup = automatic
node.session.auth.authmethod = CHAP
node.session.auth.username = username
node.session.auth.password = password

hua@node1:~$ sudo iscsiadm -m discovery -t st -p 192.168.99.122
192.168.99.122:3260,1 iqn.2004-04.com.qnap:ts-212p:iscsi.quqiscsi.d5ad13
10.8.0.1:3260,1 iqn.2004-04.com.qnap:ts-212p:iscsi.quqiscsi.d5ad13

hua@node1:~$ sudo cat /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.2004-04.com.qnap:ts-212p:iscsi.quqiscsi.d5ad13

hua@node1:~$ sudo iscsiadm -m node -T iqn.2004-04.com.qnap:ts-212p:iscsi.quqiscsi.d5ad13 -p 192.168.99.122 --op new
New iSCSI node [tcp:[hw=,ip=,net_if=,iscsi_if=default] 192.168.99.122,3260,-1 iqn.2004-04.com.qnap:ts-212p:iscsi.quqiscsi.d5ad13] added

hua@node1:~$ sudo iscsiadm -m node -T iqn.2004-04.com.qnap:ts-212p:iscsi.quqiscsi.d5ad13 -p 192.168.99.122 --login
Logging in to [iface: default, target: iqn.2004-04.com.qnap:ts-212p:iscsi.quqiscsi.d5ad13, portal: 192.168.99.122,3260] (multiple)
Login to [iface: default, target: iqn.2004-04.com.qnap:ts-212p:iscsi.quqiscsi.d5ad13, portal: 192.168.99.122,3260] successful.
hua@node1:~$ sudo iscsiadm -m node -T iqn.2004-04.com.qnap:ts-212p:iscsi.quqiscsi.d5ad13 -p 192.168.99.122 --op update -n node.startup -v automatic

hua@node1:~$ ls -l /dev/disk/by-path/ip-192.168.99.122:3260-iscsi-iqn.2004-04.com.qnap:ts-212p:iscsi.quqiscsi.d5ad13-lun-0
lrwxrwxrwx 1 root root 9 Dec 28 10:22 /dev/disk/by-path/ip-192.168.99.122:3260-iscsi-iqn.2004-04.com.qnap:ts-212p:iscsi.quqiscsi.d5ad13-lun-0 -> ../../sdb

hua@node1:~$ cat /sys/class/iscsi_host/host16/device/session11/iscsi_session/session11/targetname
iqn.2004-04.com.qnap:ts-212p:iscsi.quqiscsi.d5ad13

hua@node1:~$ sudo cat /etc/udev/rules.d/55-openiscsi.rules
KERNEL=="sd*", BUS=="scsi", PROGRAM="/etc/udev/scripts/iscsidev.sh %b",SYMLINK+="iscsi/%c"

hua@node1:~$ sudo cat /etc/udev/scripts/iscsidev.sh
#!/bin/sh
# FILE: /etc/udev/scripts/iscsidev.sh
BUS=${1}
HOST=${BUS%%:*}
[ -e /sys/class/iscsi_host ] || exit 1
file="/sys/class/iscsi_host/host${HOST}/device/session*/iscsi_session*/targetname"
target_name=$(cat ${file})
# This is not an open-scsi drive
if [ -z "${target_name}" ]; then
exit 1
fi
echo "${target_name##*.}"

hua@node1:~$ sudo fdisk -l
...
Disk /dev/sdb: 859.0 GB, 858993459200 bytes
255 heads, 63 sectors/track, 104433 cylinders, total 1677721600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 1048576 bytes / 1048576 bytes
Disk identifier: 0x00000000

Disk /dev/sdb doesn't contain a valid partition table


hua@node1:~$ sudo mkfs.ext4 /dev/sdb
mke2fs 1.42.9 (4-Feb-2014)
/dev/sdb is entire device, not just one partition!
Proceed anyway? (y,n) y
Discarding device blocks: done
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=256 blocks, Stripe width=256 blocks
52428800 inodes, 209715200 blocks
10485760 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
6400 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

hua@node1:~$ sudo mkdir /qnap
hua@node1:~$ sudo mount -t ext4 /dev/sdb /qnap
hua@node1:~$ df -h |grep sdb
/dev/sdb 788G 69M 748G 1% /qnap

hua@node1:~$ sudo tune2fs -l /dev/sdb |grep UUID
Filesystem UUID: 30aa3ef9-698b-41c2-9637-dc79be91eb79

hua@node1:~$ sudo cat /etc/fstab |grep sdb
/dev/sdb /qnap ext4 defaults,auto,_netdev 0 0

 

hua@hua-ThinkPad-T440p:/bak$ sudo mount -t ext4 /dev/sdb /qnap
mount: /dev/sdb is already mounted or /qnap busy
hua@hua-ThinkPad-T440p:/bak$ sudo multipath -ll
36001405abdafa5bd00cbd4d1ad9498d1 dm-0 QNAP,iSCSI Storage
size=800G features='0' hwhandler='0' wp=rw
`-+- policy='round-robin 0' prio=1 status=active
`- 6:0:0:0 sdb 8:16 active ready running
hua@hua-ThinkPad-T440p:/bak$ sudo multipath -F
hua@hua-ThinkPad-T440p:/bak$ sudo multipath -ll
hua@hua-ThinkPad-T440p:/bak$ sudo mount -t ext4 /dev/sdb /qnap

 

遇到的问题

1, 多出来的10.8.0.1:3260这个Portal连不上会导致开机时超时非常慢,得删除它。

hua@node2:~$ sudo iscsiadm -m discoverydb -P1
SENDTARGETS:
DiscoveryAddress: 192.168.99.122,3260
Target: iqn.2004-04.com.qnap:ts-212p:iscsi.quqiscsi.d5ad13
Portal: 192.168.99.122:3260,1
Iface Name: default
Portal: 10.8.0.1:3260,1
Iface Name: default
DiscoveryAddress: aa.quqi.com,3260
iSNS:
No targets found.
STATIC:
Target: iqn.2004-04.com.qnap:ts-212p:iscsi.quqiscsi.d5ad13
Portal: aa.quqi.com:3260,-1
Iface Name: default
FIRMWARE:
No targets found.


hua@node2:~$ sudo iscsiadm -m discoverydb -t st -p 10.8.0.1,3260 -o delete
iscsiadm: Discovery record [10.8.0.1,3260] not found.
hua@node2:~$ sudo iscsiadm -m discoverydb -t st -p 10.8.0.1:3260 -o delete
iscsiadm: Discovery record [10.8.0.1,3260] not found


hua@node2:~$ sudo iscsiadm -m discoverydb -P1
SENDTARGETS:
DiscoveryAddress: 192.168.99.122,3260
Target: iqn.2004-04.com.qnap:ts-212p:iscsi.quqiscsi.d5ad13
Portal: 192.168.99.122:3260,1
Iface Name: default
DiscoveryAddress: veryhua2006.myqnapcloud.com,3260
iSNS:
No targets found.
STATIC:
No targets found.
FIRMWARE:
No targets found.

 

2, 遇到这个类似的问题(http://forum.open-e.com/showthread.php?1262-Problem-synchronize-data-using-2-initiator-1-target),即多个iscsi client连向同一个iscsi server时,在共享存储上写入新内容了,iscsi client需要先umount再mount才能更新。似乎没有自动地sync
 

延伸阅读:

  • 专题推荐

About IT165 - 广告服务 - 隐私声明 - 版权申明 - 免责条款 - 网站地图 - 网友投稿 - 联系方式
本站内容来自于互联网,仅供用于网络技术学习,学习中请遵循相关法律法规