问题导读
1、什么是iscsiadm?
2、如何发现节点、登入登出?
iscsiadm是open-iscsi包中的一个工具,用来发现和登陆iSCSI target。
关于iSCSI基本介绍,可以参考《鸟哥私房菜》,本文主要记录iscsiadm的常用命令,同时对其功能有大致的体会
发现
- $ sudo iscsiadm -m discovery -t sendtargets -p 127.0.0.1:3260
- 127.0.0.1:3260,1 iqn.2010-10.org.openstack:volume-63cb9eb0-7eee-470e-b4a9-5c3d562926be
- 127.0.0.1:3260,1 iqn.2010-10.org.openstack:volume-252b5988-8f76-4988-a10b-413fb63d1a67
复制代码
查看已发现的节点
- $ sudo iscsiadm -m node
- 127.0.0.1:3260,1 iqn.2010-10.org.openstack:volume-63a98496-4f2a-4c37-bbb5-f4e5e6b304fe
- 127.0.0.1:3260,1 iqn.2010-10.org.openstack:volume-252b5988-8f76-4988-a10b-413fb63d1a67
复制代码
查看会话状况
- sudo iscsiadm -m session -P 3
- Target: iqn.2010-10.org.openstack:volume-252b5988-8f76-4988-a10b-413fb63d1a67
- Current Portal: 127.0.0.1:3260,1
- Persistent Portal: 127.0.0.1:3260,1
- **********
- Interface:
- **********
- Iface Name: default
- Iface Transport: tcp
- Iface Initiatorname: iqn.1993-08.org.debian:01:32d2f2212ee1
- Iface IPaddress: 127.0.0.1
- Iface HWaddress: <empty>
- Iface Netdev: <empty>
- SID: 6
- iSCSI Connection State: LOGGED IN
- iSCSI Session State: LOGGED_IN
- Internal iscsid Session State: NO CHANGE
- Target: iqn.2010-10.org.openstack:volume-63a98496-4f2a-4c37-bbb5-f4e5e6b304fe
- Current Portal: 127.0.0.1:3260,1
- Persistent Portal: 127.0.0.1:3260,1
- **********
- Interface:
- **********
- Iface Name: default
- Iface Transport: tcp
- Iface Initiatorname: iqn.1993-08.org.debian:01:32d2f2212ee1
- Iface IPaddress: 127.0.0.1
- Iface HWaddress: <empty>
- Iface Netdev: <empty>
- SID: 7
- iSCSI Connection State: LOGGED IN
- iSCSI Session State: LOGGED_IN
- Internal iscsid Session State: NO CHANGE
复制代码
登陆/登出
设置验证方式,用户名,密码
- $ sudo iscsiadm -m node -T $iqn --op update -n node.session.auth.authmethod -v CHAP -p <span style="font-family: Arial, Helvetica, sans-serif;">127.0.0.1:3260</span>
- $ sudo iscsiadm -m node -T $iqn --op update -n node.session.auth.username -v CHAP -p $portal
- $ sudo iscsiadm -m node -T $iqn --op update -n node.session.auth.password -v CHAP -p $portal
复制代码
登陆,成功后会将target挂载到本地,可以通过上面的(session)查看详细信息
- $ sudo iscsiadm -m node --targetname iqn.2010-10.org.openstack:volume-63cb9eb0-7eee-470e-b4a9-5c3d562926be -p 127.0.0.1:3260 --login
- Logging in to [iface: default, target: iqn.2010-10.org.openstack:volume-63cb9eb0-7eee-470e-b4a9-5c3d562926be, portal: 127.0.0.1,3260] (multiple)
- Login to [iface: default, target: iqn.2010-10.org.openstack:volume-63cb9eb0-7eee-470e-b4a9-5c3d562926be, portal: 127.0.0.1,3260] successful.
复制代码
登出,卸载target
- $ sudo iscsiadm -m node --target iqn.2010-10.org.openstack:volume-63a98496-4f2a-4c37-bbb5-f4e5e6b304fe -p 127.0.0.1:3260 --logout
- Logging out of session [sid: 4, target: iqn.2010-10.org.openstack:volume-63a98496-4f2a-4c37-bbb5-f4e5e6b304fe, portal: 127.0.0.1,3260]
- Logout of [sid: 4, target: iqn.2010-10.org.openstack:volume-63a98496-4f2a-4c37-bbb5-f4e5e6b304fe, portal: 127.0.0.1,3260] successful.
复制代码
本文转自:
|