现在来实际配置ISCSI Target了。
这里提一下,上一篇博文我用的虚拟机装的是centos6,内核是2.6的,而LIO的ISCSI驱动直到3.1才进内核(并且红帽没有将这一特性移植到2.6内核),所以实际上是犯了个二。
今天的虚拟机里面装载的是ubuntu14.04b2。
进入targetcli后。
/> iscsi/ create Created target iqn.2003-01.org.linux-iscsi.bogon.x8664:sn.14cf36c1f17c. Selected TPG Tag 1. Successfully created TPG 1. /> ls iscsi o- iscsi ............................................................ [1 Target] o- iqn.2003-01.org.linux-iscsi.bogon.x8664:sn.14cf36c1f17c ........... [1 TPG] o- tpgt1 ......................................................... [enabled] o- acls ......................................................... [0 ACLs] o- luns ......................................................... [0 LUNs] o- portals ................................................... [0 Portals]
可以看到这样就弄好了一个TPG,真是不要太简单。
TPG下属有三个目录,先弄LUN。
/> cd iscsi/iqn.2003-01.org.linux-iscsi.bogon.x8664:sn.14cf36c1f17c/tpgt1/ /iscsi/iqn.20...6c1f17c/tpgt1> luns/ create storage_object=/backstores/iblock/disk1 Selected LUN 0. Successfully created LUN 0. /iscsi/iqn.20...6c1f17c/tpgt1> ls o- tpgt1 ............................................................. [enabled] o- acls ............................................................. [0 ACLs] o- luns .............................................................. [1 LUN] | o- lun0 .......................................... [iblock/disk1 (/dev/sdb)] o- portals ....................................................... [0 Portals]
这样就创建了一个LUN,哎,简单得有点低潮。
接下来是Portal。也是依样画葫芦。
/iscsi/iqn.20...6c1f17c/tpgt1> portals/ create 192.168.1.104 Using default IP port 3260 Successfully created network portal 192.168.1.104:3260. /iscsi/iqn.20...6c1f17c/tpgt1> ls o- tpgt1 ............................................................. [enabled] o- acls ............................................................. [0 ACLs] o- luns .............................................................. [1 LUN] | o- lun0 .......................................... [iblock/disk1 (/dev/sdb)] o- portals ........................................................ [1 Portal] o- 192.168.1.104:3260 .................................. [OK, iser disabled]
到现在为止,只剩下最后一步设置了。
/iscsi/iqn.20...6c1f17c/tpgt1> acls/ create iqn.1994-05.com.redhat:5b22253996 Successfully created Node ACL for iqn.1994-05.com.redhat:5b22253996 Created mapped LUN 0. /iscsi/iqn.20...6c1f17c/tpgt1> ls o- tpgt1 ............................................................. [enabled] o- acls .............................................................. [1 ACL] | o- iqn.1994-05.com.redhat:5b22253996 ........................ [1 Mapped LUN] | o- mapped_lun0 ............................................... [lun0 (rw)] o- luns .............................................................. [1 LUN] | o- lun0 .......................................... [iblock/disk1 (/dev/sdb)] o- portals ........................................................ [1 Portal] o- 192.168.1.104:3260 .................................. [OK, iser disabled]
这里是设置了一个ACL权限,对LUN0有RW权限。这里只设置了一个LUN所以其实没什么意义。
那一串数值不可以乱设,需要对应客户端/etc/iscsi/initiatorname.iscsi里面的数值。
接下来设置用户名,密码。
/iscsi/iqn.20...6c1f17c/tpgt1> acls/iqn.1994-05.com.redhat:5b22253996 set auth userid=test password=test Parameter password is now 'test'. Parameter userid is now 'test'.
这里的用户名,密码也要对应客户端/etc/iscsi/iscsid.conf里面的数值。
一切就绪。开另一台虚拟机。
# iscsiadm -m discovery -t st -p 192.168.1.104 正在启动 iscsid: [确定] 192.168.1.104:3260,1 iqn.2003-01.org.linux-iscsi.bogon.x8664:sn.14cf36c1f17c
可以看到已经可以顺利找到刚配好的ISCSI Target了。
# iscsiadm -m node --login Logging in to [iface: default, target: iqn.2003-01.org.linux-iscsi.bogon.x8664:sn.14cf36c1f17c, portal: 192.168.1.104,3260] (multiple) Login to [iface: default, target: iqn.2003-01.org.linux-iscsi.bogon.x8664:sn.14cf36c1f17c, portal: 192.168.1.104,3260] successful.
好了,到此为止已经算是搞定了。