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

How to use iscsiadm in Linux

2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

In this issue, the editor will bring you about how to use iscsiadm in Linux. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.

1. Storage media

1) disk array: disk array is a kind of high performance and high availability disk storage device manufactured by RAID technology, redundancy technology and online maintenance technology.

2) IP-SAN storage: SAN (Storage Area Network- Storage area Network): an architecture in computer information processing technology that connects a server to remote computer storage devices (such as disk arrays and tape libraries) to make them look local. SAN is understood as storage virtualization, and IP-SAN is a SAN storage area network constructed by iSCSI protocol.

2. # rpm-ivh iscsi-initiator-utils-6.2.0.742-0.5.el5.i386.rpm installs iSCSI initiator and iscsiadm on the server.

3. Iscsiadm is a command-line-based iscsi management tool that provides operations on iSCSI nodes, sessions, connections, and discovery records.

The instructions for using iscsiadm can be viewed at / usr/share/doc/iscsi-initiator-utils-6.2.0.742/README, or you can run man iscsiadm or iscsiadm-- help.

4. Let's talk about the steps to connect an iscsi device:

1. Start the iscsi daemon

# service iscsi start by default, this process runs automatically after the system starts

two。 Find the target.

By default, the iscsi initiator and target are connected through port 3260. Assuming that the known target party IP for iscsi is 192.168.1.1, run the following command:

# chkconfig iscsi on

# chkconfig iscsi-list (check the startup status of ISCSI)

# iscsiadm-m discovery-t sendtargets-p 192.168.1.1pur3260

At this point, we find and have a target (target): 192.168.1.1 Phantom 3260 Magne1 iqn.1997-05.com.test:raid is also called a node.

3. Login node

Take the target found above as an example:

# iscsiadm-m node-T iqn.1997-05.com.test:raid-p 192.168.1.1 iqn.1997 3260-l where iqn.1997-05.com.test:raid is the target name.

[if you want to log in automatically when the system starts:

# iscsiadm-m node-T iqn.1997-05.com.test:raid-p 192.168.1.1 iqn.1997 3260-- op update-n node.startup-v automatic]

4. After logging in to the node, view the disk information

# fdisk-l

You should be able to see the storage device information of the target party, such as:

Disk / dev/sdb: 3489.8 GB, 3489862254592 bytes 255 heads, 63 sectors/track, 424284 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Disk / dev/sdb doesn't contain a valid partition table [/ dev/sdb is the connected iscsi storage device]

5. Log in to the node requiring CAPTCHA:

(1) enable authentication

Iscsiadm-m node-T [device]-o update-- name node.session.auth.authmethod-- value=CHAP *. Use-o as-- op

(2) add users

Iscsiadm-m node-T [device]-- op update-- name node.session.auth.username-- value= [user name]

(3) add password

Iscsiadm-m node-T [device]-op update-name node.session.auth.password-value= [password]

6. Formatting device

To format the device as an ext3 file system, run: # mkfs.ext3 / dev/sdb

7. Hook-up equipment

Create the iscsi directory under / mnt and run the mount command:

# mount-t / dev/sdb / mnt/iscsi Special mount options for iscsi devices

Run df-h to see:

/ dev/sdb 3.4T186M 3.4T 1% / mnt/iscsi

The iscsi device is successfully attached and can be used as a regular storage device.

8. If you want to hang up automatically when the system starts

Edit / etc/fstab

Add a line: / dev/sdb / mnt/iscsi ext3 default 0 0

9. Logout node

First unhook: # umount / mnt/iscsi

Log out: # iscsiadm-m node-T iqn.1997-05.com.test:raid-p 192.168.1.1 iqn.1997 3260-u

"" = "" | "" = "

1. If a new SAN resource is mounted under the Target on the storage, how to connect and identify it on the server?

If a new SAN resource is added under a Target, the server can use the iscsiadm-m session-R command to refresh (rescan) the connected iSCSI session to identify the new SAN resource:

[root@pe03 /] # iscsiadm-m session-R

You can use cat / proc/scsi/scsi or fdisk-l to view the connected volumes. For example, the following scsi7 Channel: 00 Id: 00 Lun: 01 is the newly attached SAN volume:

[root@pe03 /] # cat / proc/scsi/scsi

...

Host: scsi7 Channel: 00 Id: 00 Lun: 00

Vendor: H3C Model: H3C ISCSI DISK Rev: v1.0

Type: Direct-Access ANSI SCSI revision: 04

Host: scsi7 Channel: 00 Id: 00 Lun: 01

Vendor: H3C Model: H3C ISCSI DISK Rev: v1.0

Type: Direct-Access ANSI SCSI revision: 04

2. How do I log out of my connection to target?

If you want to log out of a connection to a specific Target, you can use the following command:

[root@pe03 /] # iscsiadm-m node-T iqn.2007-04.acme.com:h4c:200realm.rhel5-p 200.200.10.200 purl 3260-u

Where iqn.2007-04.acme.com:h4c:200realm.rhel5 is the name of Target and 200.200.10.200 is the IP of Target server. Please modify it according to the actual situation.

If you want to log out of connections to all targets, you can use the following command:

[root@pe03 /] # iscsiadm-m node-- logoutall=all

Note: please stop reading and writing to the iSCSI disk before logging out of target, unmount the file system on the disk, and if you use LVM, you also need to activate the VG that uses the disk.

3. How to restart the iscsi service?

Stop reading and writing to the iSCSI disk, unmount the file system on the disk, and if you use LVM, you also need to activate the VG that uses the disk, and then restart the iscsi service using service iscsi restart.

4. How to stop the iscsi service?

Stop reading and writing to the iSCSI disk, unmount the file system on the disk, and if you use LVM, you also need to activate the VG that uses the disk, and then use service iscsi stop to stop the iscsi service.

5. How to set different target authentication for different CHAP?

If there are multiple target servers that have CHAP authentication enabled and their usernames and passwords are different, you need to change the node file manually.

When Target is discovered through the iscsiadm-m node-t sendtargets command, one or more folders named after the Target name on the destination server are generated in the / var/lib/iscsi/nodes directory with a file in it. This file contains the configuration parameters to be used by the initiator login target, and the CHAP authentication information logged in to each Target can be configured by changing this parameter file.

You can edit the file directly to add (or modify) the CHAP authentication username and password for this Target:

Node.session.auth.authmethod = CHAP

Node.session.auth.username = xxxxxx-- CHAP authenticated user name

Node.session.auth.password = xxxxxx-- CHAP authentication password (at least 12 characters)

After the modification, log in to Target again.

You can also use the iscsiadm command to modify the CHAP authentication parameters for logging in to a target

Such as:

[root@pe03 /] # iscsiadm-m node-T iqn.2000-03.com.h4c:.h4c-1.pe05-61-p 200.200.10.101 node 3260-o update-- name=node.session.auth.authmethod-- value=CHAP

[root@pe03 /] # iscsiadm-m node-T iqn.2000-03.com.h4c:.h4c-1.pe05-61-p 200.200.10.101 node 3260-o update-- name= node.session.auth.username-- value=xxxxxxx

[root@pe03 /] # iscsiadm-m node-T iqn.2000-03.com.h4c:.h4c-1.pe05-61-p 200.200.10.101 node 3260-o update-- name= node.session.auth.password-- value=xxxxxxx

It should be noted that the command to find Target (iscsiadm-m node-t sendtargets) will automatically refresh the parameter file to be used by initiator login target under / var/lib/iscsi/nodes according to the parameter configuration in / etc/iscsi/iscsi.conf file, so if you modify the file under / var/lib/iscsi/nodes to set up CHAP authentication and then perform the operation of discovering target to the storage server, you need to modify the file again.

6. How to delete a target message from the operating system?

Use the following command:

[root@pe03 /] # iscsiadm-m node-o delete-T iqn.2005-03.com.max-p 192.168.0.4 node 3260

Where iqn.2005-03.com.max represents the name of target and 192.168.0.4 represents the IP address of target

7. How to check which target is recorded in the Open-iSCSI database?

Use the iscsiadm-m node command

8. How do I use LVM to manage disks on Linux?

See KMS-12578, "using LVM to manage disks and create file systems on RedHat linux"

9. How to create a file system that exceeds 2TB on RHEL5?

RedHat claims that the maximum capacity supported by the ext3 file system on RHEL5 is 16TB.

When the disk size allocated from the storage system exceeds 2TB, you can use LVM to manage the disk, create a LV that exceeds the size of 2TB, and create a file system that exceeds 2TB on LV.

When the amount of disk space allocated from the storage system is less than 2TB, you can use LVM to manage disks, add multiple disks to a VG and create a LV that exceeds the size of the 2TB, and then create a file system that exceeds the 2TB on the LV.

Note: the partition of the disk using fdisk is MBR partition, and the maximum partition size is 2TB.

10. What is the tool for expanding the ext3 file system?

In the previous RHEL4 version, the ext2online command was used to extend logical volumes online, but in RHEL5, the ext2online command has been replaced by resize2fs.

The resize2fs program can be used to change the size of the ext2/ext3 file system. It can expand or shrink the ext2/ext3 file system in the umount state. If the file system is in the mount state, then it can only be expanded online, and the prerequisite is that the kernel supports online resize. (linux kernel 2.6 supports expansion in mount but is limited to ext3 file systems. )

Command format:

Resize2fs [- d debug-flags] [- S RAID-stride] [- f] [- F] [- p] device [size]

When the resize2fs tool does not take the size parameter, it automatically adjusts the new capacity of the file system to the partition.

When running the resize2fs tool to expand the file system, resize2fs may prompt you to use e2fsck-f to check the file system first, and then follow the prompts to check the file system.

This is how iscsiadm is used in Linux shared by the editor. If you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.

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

Servers

Wechat

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

12
Report