Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

ISCSI based on user authentication and iSCSI creation based on configuration file

2025-04-13 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Continue the above-> http://11107124.blog.51cto.com/11097124/1884645

The target information of the previous discovery will be saved here (discovery's database)

[root@node2 mnt] # cd / var/lib/iscsi/

[root@node2 iscsi] # ls

Ifaces isns nodes send_targets slp static

[root@node2 iscsi] # ls send_targets/

[root@node2 mnt] # ls / var/lib/iscsi/send_targets/192.168.139.2,3260/

Iqn.2016-12.com.zxlvor store1.disk1192.168.139.2, 32pr 3260, jiggle default st_config

192.168.139.2,3260

Http://11107124.blog.51cto.com/11097124/1884645

For more information about iSCSI configuration here

[root@node2 iscsi] # vim / etc/iscsi/iscsid.conf

Node.startup = automatic\\ Node open auto start

# CHAP Settings\\ Settings related to CHAP two-way authentication

# node.session.auth.authmethod = CHAP

# To set a CHAP username and password for initiator\\ server account and password when authenticating the client

# node.session.auth.username = username\\

# node.session.auth.password = password

# To set a CHAP username and password for target\\ client account and password for server authentication

# node.session.auth.username_in = username_in

# node.session.auth.password_in = password_in

The following is the general use of the system default and a variety of time settings, generally use the system default can, rarely change

Node.session.timeo.replacement_timeout = 120

Node.conn [0] .timeo.login _ timeout = 15\\ logon timeout

Node.conn [0] .timeo.logout _ timeout = 15\\ logout timeout

Node.conn [0] .timeo.noop _ out_interval = 5\\ logout interval

Node.conn [0] .timeo.noop _ out_timeout = 5\\ logout time

Node.session.err_timeo.abort_timeout = 15\\ session session time

Let's start defining user-based authentication

First log out the LUN associated with target

[root@node2 iscsi] # iscsiadm-m node-T iqn.2016-12.com.zxl:store1.disk1-p 192.168.139.2-u

Logging out of session [sid: 1, target: iqn.2016-12.com.zxl:store1.disk1, portal: 192.168.139.2 Magi 3260]

Logout of [sid: 1, target: iqn.2016-12.com.zxl:store1.disk1, portal: 192.168.139.2 iqn.2016 3260] successful.

[root@node2 iscsi] # fdisk-l\\ you can find / dev/ SDC disk missing

However, the discovery database is still there. As soon as the iscsi service is started after boot, it will automatically log in to the target already found in the discovery database.

Delete the database of discovery directly

[root@node2 iscsi] # iscsiadm-m node-T iqn.2016-12.com.zxl:store1.disk1-p 192.168.139.2-o delete

[root@node2 iscsi] # ls / var/lib/iscsi/send_targets/192.168.139.2,3260/

St_config\\ 192.168.139.2 there is no record data in the directory 3260. Delete this directory page.

[root@node2 iscsi] # rm-rf / var/lib/iscsi/send_targets/192.168.139.2,3260/

First create an account authenticated by server to client, and bind it to target's tid

[root@node1] # tgtadm-lld iscsi-mode account-op new-user zxl-password 888

The created user is: zxl password: 888

[root@node1] # tgtadm-lld iscsi-mode account-op bind-tid 1-user zxl

[root@node1] # tgtadm-lld iscsi-mode target-op show

Account information:

Zxl

ACL information:

192.168.139.0/24

[root@node2 iscsi] # vim / etc/iscsi/iscsid.conf\\ enable the following three items

Node.session.auth.authmethod = CHAP

Node.session.auth.username = zxl

Node.session.auth.password = 888,

[root@node2 iscsi] # iscsiadm-m discovery-t st-p 192.168.139.2

192.168.139.2 Flux 3260 iqn.2016-12.com.zxl:store1.disk1

OK, as you can find, log in to target

Root@node2 iscsi] # iscsiadm-m node-T iqn.2016-12.com.zxl:store1.disk1-p 192.168.139.2-l

Login to [iface: default, target: iqn.2016-12.com.zxl:store1.disk1, portal: 192.168.139.2 Magi 3260] successful.

OK, logged in successfully

[root@node2 iscsi] # fdisk-l\\ but it becomes sdd. Sdc was used by the last login, and the information was not cleared.

Disk / dev/sdd: 5379 MB, 5379300864 bytes

[root@node2 iscsi] # mount / dev/sdd1 / mnt

[root@node2 iscsi] # cd / mnt

[root@node2 mnt] # ll\\ you can see that the files are all in the

Total 20

-rw-r--r--. 1 root root 47 Dec 21 10:28 issue

Drwx-. 2 root root 16384 Dec 21 10:27 lost+found

Try using node4. Delete node4's discovery database first.

[root@node4 mnt] # iscsiadm-m node-T iqn.2016-12.com.zxl:store1.disk1-p 192.168.139.2-u

[root@node4 mnt] # iscsiadm-m node-T iqn.2016-12.com.zxl:store1.disk1-p 192.168.139.2-o delete

[root@node4 mnt] # ls / var/lib/iscsi/send_targets/192.168.139.2,3260/

St_config

[root@node4 mnt] # rm-rf / var/lib/iscsi/send_targets/192.168.139.2,3260/

At this time, the configuration file of node4 has not been modified to see if it can be found and logged in.

Root@node4 mnt] # iscsiadm-m discovery-t st-p 192.168.139.2

192.168.139.2 Flux 3260 iqn.2016-12.com.zxl:store1.disk1

[root@node4 mnt] # iscsiadm-m node-T iqn.2016-12.com.zxl:store1.disk1-p 192.168.139.2-l

Iscsiadm: initiator reported error (24-iSCSI login failed due to authorization failure)

Iscsiadm: Could not log into all portals

You can see, you can find it, but you can't log in.

[root@node2 iscsi] # vim / etc/iscsi/iscsid.conf\\ enable the following three items

Node.session.auth.authmethod = CHAP

Node.session.auth.username = zxl

Node.session.auth.password = 888,

[root@node4 mnt] # service iscsi restart

[root@node4 mnt] # iscsiadm-m node-T iqn.2016-12.com.zxl:store1.disk1-p 192.168.139.2-l

Login to [iface: default, target: iqn.2016-12.com.zxl:store1.disk1, portal: 192.168.139.2 Magi 3260] successful.

Log in successfully

Iscsi-initiator-utils does not support discovery (cannot be found with discovery when authenticating with an account password). You must first open IP authentication to discovery, and then log in to the discovered target with the account password.

How to automatically create target and lun after shutting down and restarting the tgtd service?

By editing the configuration file

[root@node1 ~] # cp / etc/tgt/targets.conf / etc/tgt/targets.conf.bak\\ back up the files first

[root@node1 ~] # vim / etc/tgt/targets.conf\\ edit as follows

# backing-store / dev/LVM/somedevice

#

Backing-store / dev/sdb1\\ this item can be repeated if there are multiple disks.

Lun 1

Incominguser zxl 888\\ incominguser for server, user authentication for client is\\ incoming,outgoinguser for client to server authentication

Initiator-address 192.168.139.0/24

Log in and exit client before restarting the service.

[root@node2 mnt] # iscsiadm-m node-T iqn.2016-12.com.zxl:store1.disk1-p 192.168.139.2-u

[root@node4 mnt] # iscsiadm-m node-T iqn.2016-12.com.zxl:store1.disk1-p 192.168.139.2-u

[root@node1 ~] # service tgtd restart

Stopping SCSI target daemon: [OK]

Starting SCSI target daemon: [OK]

[root@node1] # tgtadm-lld iscsi-mode target-op show

Target 1: iqn.2016-12.com.zxl:store1.disk1

System information:

Driver: iscsi

State: ready

I_T nexus information:

LUN information:

LUN: 0

Type: controller

SCSI ID: IET 00010000

SCSI SN: beaf10

Size: 0 MB, Block size: 1

Online: Yes

Removable media: No

Prevent removal: No

Readonly: No

Backing store type: null

Backing store path: None

Backing store flags:

Account information:

Zxl

ACL information:

192.168.139.0/24

[root@node2 mnt] # iscsiadm-m node-T iqn.2016-12.com.zxl:store1.disk1-p 192.168.139.2-u

Logout of [sid: 2, target: iqn.2016-12.com.zxl:store1.disk1, portal: 192.168.139.2 iqn.2016 3260] successful.

Log in successfully

You can see that target and lun are built automatically according to the / usr/sbin/tgt-admin command defined in the configuration file, even if shutdown and restart can be created automatically.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report