Iscsiadm is an iscsi management tool based on the command line, which provides operations on iscsi nodes, sessions, connections and discovery records.
See/usr/share/doc/iscsi-initiator-utils-6.2.0.742/readme for instructions on iscsiadm, or run man iscsiadm or iscsiadm-help.
#yum Install iscsi-initiator-utils*
use
Let's talk about the steps to connect iscsi devices:
1 Start the iscsi daemon
# Service iscsi startup
By default, this process runs automatically after the system is started.
2 find the target
By default, iscsi initiators and targets are connected through port 3260. Assuming that the target IP of iscsi is192.168.1.1,run the following command:
# chkconfig ISCSI on chkconfig iscsi-list (view iscsi startup status)
#iscsiadm -m discovers -t sending target-p192.168.1.1:3260.
At this time, I found that I had a goal.
# 192. 168. 1. 1:3260,2 iqn . 1995-03 . com . dot hill:0 1 . array . 00 c0ff 137675
3 login node
Take the target found above as an example.
# iscsi ADM-m node–T iqn . 1995-03 . com . dot hill:0 1 . array . 00 c0ff 137675-p 192. 168. 1. 1:3260-l
Where iqn.1997-05.com.test: raid is the target name.
If you want to log in automatically when the system starts
# iscsi ADM-mnode–t iqn.1995-03.com.dothill: 01.array.00c0ff137675-p192.168.
After logging in to the node, run.
# fdisk–l
You should be able to see the storage device information of the target party, such as
Disk /dev/sdb: 3489.8 GB, 348962254592 bytes.
255 heads, 63 sectors/tracks, 424,284 cylinders.
Unit =16065 * 512 = 8225280 bytes cylinder.
Disk /dev/sdb does not contain a valid partition table.
/dev/sdb is the attached iscsi storage device.
Log in to the node that needs verification code:
(1) open authentication
Iscsi ADM-m node-T[ device]-o update-namenode.session.auth.authmethod-value = chap.
*. Use -o with-op..
(2) Add users
Iscsi ADM-m node-T[ device]-opupdate-namenode.session.auth.username-value = [username]
(3) Add a password
iscsi ADM–mnode–t[device]–op update–NameNode . session . auth . password–value =[password]。
4 formatting device
To format the device as an ext3 file system, run
# mkfs.ext4 /dev/sdb
5 hook equipment
Create an iscsi directory under /mnt.
#mkdir /mnt/iscsi
Run the mount command:
# Load/Develop /sdb /mnt/iscsi
Special mounting options for iscsi devices.
Run df–h to view:
/dev/sdb 3.4T 186m 3.4T 1%/mnt/iscsi
Iscsi devices have been successfully connected and can be used as regular storage devices.
If you want to connect automatically when the system starts
Edit /etc/fstab
Add a line:
/dev/sdb /mnt/iscsi ext4 default value 0 0
6 logout node
Untie it first.
# Uninstall/Manage /iscsi
cancel
# iscsi ADM-m node–T iqn . 1995-03 . com . dot hill:0 1 . array . 00 c0ff 137675-p 192. 168. 1. 1:3260–u
Use LVM to create and set up LUNs on iSCSI target servers.
Why use LUN?
Luns are used for storage. SAN storage is mainly composed of a cluster of LUNs, which are composed of several physical drives of the target. We can use LUN as the physical drive of the system to install the operating system. Luns can be used for clusters, virtual servers, and SAN. The main purpose of using LUN in virtual server is to serve as storage for operating system. The performance and reliability of a LUN depends on the drive used when the target storage server was created.
Early reading
To learn how to create an iSCSI target, click the link below.
Create centralized secure storage using iSCSI targets (1)
Primary server settings
The system information and network settings are the same as the iSCSI target mentioned above-we define the LUN on the same server.
Operating system? CentOS? 6.5 (final version)
ISCSI target IP–192.168.0.200
Ports used: TCP 860, 3260
Configuration file: /etc/tgt/targets.conf
Use LVM to create a LUN on an iSCSI target.
First, use the fdisk -l command to find out the drive list, which will list all the partitions in the system.
# fdisk -l
The above command only gives the drive information of the basic system. To get information about storage devices, use the following command to get a list of storage devices.
# fdisk-l/dev/vda & amp; & ampfdisk -l /dev/sda
List storage devices
Note: vda here is a virtual machine hard disk, because I use a virtual machine to demonstrate. /dev/sda? This is extra storage space.
Step 1: Create LVM drive for LUN.
We use the /dev/sda drive to create LVM.
# fdisk -l /dev/sda
List LVM drives
Now let's list the drive partitions using the following fdisk command.
# fdisk -cu /dev/sda
Option' -c' turns off DOS compatibility mode.
Option' -u' is used to list partition tables and give the size of sectors instead of cylinders.
Use n to create a new partition.
Command (m? For what? Help):? n
Use p to create a primary partition.
Command? behaviour
E extension
P main partition? ( 1-4)
Give the partition we created a partition number.
Partition? Number? ( 1-4): 1
At this point, we will set up the LVM drive. Therefore, we need to use the default settings to use the entire drive.
First of all? Department? (2048-37748735, default 2048):
Use default values? Value? 2048
Finally? Sector,+sector? Or+size{K, m, G}(2048-37748735, default 37748735):
Use default values? Value? 37748735
Select the type of partition, here we want to set LVM, so we use 8e. Use l to list all types.
Command (m? For what? Help):? t
Select the partition whose type you want to change.
Selected? Partition? 1
Black magic? Code? (type l to list codes): 8e
Changed? What is the system type of the partition? 1? Where to? 8e(Linux? LVM)
After changing the type, list the partition table by printing (p) option.
Command (m? For what? Help):? p
Disk/dev/sda: 19.3? GB, 19327352832? byte
255? Heads, 63? Sector/track, 2349? Cylinders? Total? 37748736? department
Unit =? Department? 1*5 12=5 12? byte
Department? Size? (logic/physics): 5 12? Bytes? /5 12? byte
I/O size? (Minimum/Optimal): 5 12? Bytes? /5 12? byte
Disk? Identifier: 0x9fae99c8
DeviceBootStartEndBlocksIdSystem
/dev/sda 1? 204837748735 188733448 Linux? LVM
Use w to write the settings and exit the fdisk tool, then restart the system for the settings to take effect.
For reference, I attach the following screenshot to give you a clear guide when creating LVM drives.
Create LVM partition
After the system restarts, use the fdisk command to list the partition tables.
# fdisk -l /dev/sda
Verify LVM partition
Step 2: Create a logical volume for the LUN.
Now, we use the "pvcreate" command to create a physical volume.
# pvcreate /dev/sda 1
Create a volume group named iSCSI to distinguish it.
# vgcreate VG _ iscsi/dev/sda 1
I have defined four logical volumes here, so there will be four LUNs on my iSCSI target.
# LV create-L 4G-n LV _ iscsi VG _ iscsi
# LV create-L 4G-n LV _ iscsi- 1 VG _ iscsi
# LV create-L 4G-n LV _ iscsi-2 VG _ iscsi
# LV create-L 4G-n LV _ iscsi-3 VG _ iscsi
List physical volumes, volume groups, and logical volume determinations.
# pvs & amp& ampvgs & amp& amplvs
# lvs
In order to better understand the above command, I attach a screenshot below for your reference.
Create LVM logical volume
Verify LVM logical volumes
Step 3: Define the LUN in the target.
We have created the logical volume and are ready to use the LUN. Now we define the LUN in the target configuration, so that it can be used in the client (initiator).
Open the target configuration file at "/etc"/etc/TGT/targets.conf "with the editor of your choice.
# vim /etc/tgt/targets.conf
Attach the definition to the target configuration file below. Save and close the file.
& lttarget iqn . 20 14-07 . com . tec mint:TGT 1 & gt;
Backing storage /dev/vg_iscsi/lv_iscsi
& lt/target & gt;
& lttarget iqn . 20 14-07 . com . tec mint:TGT 1 & gt;
Backup storage/dev/VG _ iscsi/LV _ iscsi-1
& lt/target & gt;
& lttarget iqn . 20 14-07 . com . tec mint:TGT 1 & gt;
Backup storage /dev/vg_iscsi/lv_iscsi-2
& lt/target & gt;
& lttarget iqn . 20 14-07 . com . tec mint:TGT 1 & gt;
Backup storage /dev/vg_iscsi/lv_iscsi-3
& lt/ target
Configure the LUN in the target.
The above picture shows:
ISCSI adopts a qualified name (iqn.2014-07.com.tecmint: TGT1).
Whatever you say.
Used to determine the target name, which is the first target in this server.
LVM*** enjoys a special LUN.
Next, use the following command to overload the tgd service configuration.
# /etc/init.d/tgtd reload
Overload configuration
Next, verify the available LUNs using the following command.
# tgtadm-mode target operation display
List available LUNs.
LUN information
The above command lists the following information about available LUNs.
ISCSI qualified name
ISCSI is ready.
The default LUN 0 is reserved by the controller.
LUN 1 is our defined goal.
Here, I have defined 4GB for each LUN.
Online: Yes, this is an available LUN.
Now, we have defined LUN with LVM as the target, which is extensible and supports many functions, such as snapshots. In the third part, we will learn how to authorize the target and mount the remote storage locally.