iscsiadm常用命令

iscsiadm常用命令:
# iscsiadm -m discovery -t st -p IP:port     //发现iSCSI存储

# iscsiadm -m node -o delete -T TARGET -p IP:port    //删除iSCSI发现记录

# iscsiadm -m node          //查看iSCSI发现记录

# iscsiadm -m session     //查看会话情况

# iscsiadm -m node -T TARGET -p IP:port -l       //登录iSCSI存储
# iscsiadm -m node -T TARGET -p IP:port -u      //登出iSCSI存储

 

iSCSI客户端操作:

[root@mysql51 ~]# iscsiadm -m discovery -t st -p 192.168.4.10        //发现iSCSI存储
192.168.4.10:3260,1 iqn.2018-12.com.oven:master

[root@mysql51 ~]# iscsiadm -m node    //查看iSCSI发现记录
192.168.4.10:3260,1 iqn.2018-12.com.oven:master

[root@mysql51 ~]# iscsiadm -m session
iscsiadm: No active sessions.


删除操作 :# iscsiadm -m node -o delete -T iqn.2018-12.com.oven:master -p 192.168.4.10:3260

[root@mysql51 ~]# iscsiadm -m node -T iqn.2018-12.com.oven:master -p 192.168.4.10 -l    //登录iSCSI存储。没有添加认证,登录失败。
Logging in to [iface: default, target: iqn.2018-12.com.oven:master, portal: 192.168.4.10,3260] (multiple)
iscsiadm: Could not login to [iface: default, target: iqn.2018-12.com.oven:master, portal: 192.168.4.10,3260].
iscsiadm: initiator reported error (24 - iSCSI login failed due to authorization failure)
iscsiadm: Could not log into all portals


[root@mysql51 ~]# vim /etc/iscsi/initiatorname.iscsi    //添加客户端认证

InitiatorName=iqn.2018-12.com.oven:client     //名称与服务端acl设置的名称一致

[root@mysql51 ~]# iscsiadm -m node -T iqn.2018-12.com.oven:master -p 192.168.4.10 -l         //仍登录失败。因为未更新IQN
Logging in to [iface: default, target: iqn.2018-12.com.oven:master, portal: 192.168.4.10,3260] (multiple)
iscsiadm: Could not login to [iface: default, target: iqn.2018-12.com.oven:master, portal: 192.168.4.10,3260].
iscsiadm: initiator reported error (24 - iSCSI login failed due to authorization failure)
iscsiadm: Could not log into all portals

[root@mysql51 ~]# systemctl restart iscsid    //更新IQN
[root@mysql51 ~]# iscsiadm -m node -T iqn.2018-12.com.oven:master -p 192.168.4.10 -l         //更新IQN后登录成功
Logging in to [iface: default, target: iqn.2018-12.com.oven:master, portal: 192.168.4.10,3260] (multiple)
Login to [iface: default, target: iqn.2018-12.com.oven:master, portal: 192.168.4.10,3260] successful.

[root@mysql51 ~]# iscsiadm -m node session    //查看会话情况
192.168.4.10:3260,1 iqn.2018-12.com.oven:master 

[root@mysql51 ~]# iscsiadm -m session -P 3 | grep -i attached     // 验证会话状态

                               Attached SCSI devices:
                                              Attached scsi disk sdb              State: running

 

posted on 2019-01-06 21:11  iouwenbo  阅读(17953)  评论(0编辑  收藏  举报

导航