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

Linux system deployment ISCSI Network Storage and client use

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

Share

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

1Perfect iSCSI network storage service

ISCSI technology is to realize the combination of physical hard disk equipment and TCP/IP network protocol, so that users can easily access the shared storage resources provided by the remote computer room through the Internet. This time we deploy server programs on linux systems and remotely access storage resources on linux systems and Windows systems respectively.

Overview of 2Det iSCSI technology

In order to further improve the read and write speed and performance of hard disk storage devices, efforts have been made to improve the interface protocol of physical hard disk devices. At present, there are three main types of hard disk interfaces: IDE, SCSI and SATA.

➢ IDE is a mature, stable and cheap parallel transmission interface.

➢ SATA is a serial transmission interface with faster transmission speed and more complete data verification.

➢ SCSI is a general standard for system-level interface between computer, hard disk, optical drive and other devices. It has the advantages of low system resource occupancy, high speed and fast transmission speed.

No matter what type of hard disk interface is used, the data on the hard disk is always exchanged with CPU and memory devices through the bus on the computer motherboard. This physical environment limitation brings all kinds of inconvenience to the sharing of hard disk resources.

Later, IBM began to develop a new storage technology based on TCP/IP protocol and SCSI interface protocol, which is the Internet small computer system interface (iSCSI,Internet Small Computer System Interface). This is a new storage technology that combines SCSI interface with Ethernet technology, which can be used to transmit commands and data of SCSI interface in the network.

3, create a Raid disk array

Since we want to use iSCSI storage technology to provide shared storage resources for remote users, we must first ensure the stability and availability of the server used to store the resources, otherwise, if there is a failure in the use process, the difficulty of maintenance will be more complex and difficult than that of the local hard disk device. Therefore, it is recommended to deploy RAID disk array groups to ensure the security of the data.

Before starting the virtual machine, add 4 hard drives to create the Raid5 disk array, and power on using the madam command to create

The mdadm-Cv / dev/md0-n 3-l 5-x 1 / dev/sdb / dev/sdc / dev/sdd / dev/sde-Cv parameter is the process of creating the array and displaying it, / dev/md0 is the name of the array group generated,-n 3 parameter is the number of hard disks required to create the RAID5 disk array, and the-l 5 parameter is the level of the RAID disk array. The-x 1 parameter is the number of backup disks of the disk array. Write the name of the hard disk one by one after the command.

After success, there will be a new device named / dev/md0, which is a Raid5-level disk array, and a backup disk.

Mdadm-D / dev/md0-View device details

4. Configure the ISCSI server

ISCSI technology is divided into server side (target) and client side (initiator).

ISCSI server is the server used to store hard disk storage resources to provide users with available storage resources. The ISCSI client is the software used by users to access the storage resources of the remote server.

4-1, use the configured Yum software library to install ISCSI server programs and configure command tools.

Parameter yum-y install targetd targetcli-- y. Default is yes for all operations.

Systemctl restart targetd restarts the server program

Systemctl enable targetd is set to boot the service.

4-2, configure ISCSI server-side shared resources. Targetcli is a special configuration command used to manage iSCSI server-side storage resources. It provides interactive configuration functions similar to fdisk commands, and abstracts the configuration contents of ISCSI shared resources into a "directory" form. We only need to fill all kinds of configuration information into the corresponding "directory".

After executing the targetcli command, you can see the interactive configuration interface. There are many Linux commands you can use in this interface, such as using ls to see the structure of directory parameters, and using cd to switch to different directories.

/ backstores/block is the location where the ISCSI server configures the shared device. Add the RAID 5 disk array md0 file you just created to the Resource Pool for configuring shared devices, and rename the file to disk0.

Execute the targetcli command to enter the interactive configuration interface, and ls will view all the following directories

/ > ls

O-/. [...]

O-backstores... [...]

| o-block. [Storage Objects: 0]

| o-fileio... [Storage Objects: 0]

| o-pscsi. [Storage Objects: 0]

| o-ramdisk.. [Storage Objects: 0]

O-iscsi... [Targets: 0]

O-loopback... [Targets: 0]

/ > cd / backstores/block

/ backstores/block > create disk0 / dev/md0

Created block storage object disk0 using / dev/md0.

/ backstores/block > cd /

/ > ls

O-/. ... [...]

O-backstores... [...]

| o-block... [Storage Objects: 1]

| | o-disk0. | [/ dev/md0 (40.0GiB) write-thru deactivated]

| o-fileio.. [Storage Objects: 0]

| o-pscsi... [Storage Objects: 0]

| o-ramdisk.. [Storage Objects: 0]

O-iscsi... [Targets: 0]

O-loopback... [Targets: 0]

4-3, create the ISCSI target name and configure the shared resource. The ISCSI target name is automatically generated by the system. It is a unique string used to describe the shared resource, and you can name it yourself.

/ > cd iscsi

/ iscsi >

/ iscsi > create iqn.2091-10.org.linux

Created target iqn.2019-10.org.linux.

Created TPG 1.

/ iscsi > cd iqn.2019-10.org.linux/

/ iscsi/iqn.2019-10.org.linux > ls

O-iqn.2019-10.org.linux.... [TPGs: 1]

O-tpg1. [no-gen-acls, no-auth]

O-acls... [ACLs: 0]

O-luns... [LUNs: 0]

O-portals... [Portals: 0]

/ iscsi/iqn.2019-10.org.linux > cd tpg1/luns

/ iscsi/iqn.2019-10.org.linux > create / backstores/block/disk0

Created LUN 0.

4-4, set the access control list (ACL). The ISCSI protocol is verified by the client name, that is, users do not need to enter a password when accessing the storage shared resources, as long as the name of the ISCSI client is consistent with a name entry in the access control list set in the server, so it is necessary to write a string of names that can verify user information in the configuration file of the ISCSI server. The acls parameter directory is used to store the names of clients that can access shared storage resources on the ISCSI server. Append a parameter similar to client to the ISCSI target just generated by the system, which ensures that the name of the client is unique.

/ iscsi/iqn.2019-10.org.linux/tpg1/luns > cd.

/ iscsi/iqn.2019-10.org.linux/tpg1 > cd acls

/ iscsi/iqn.2019-10.org.linux/tpg1/acls > create iqn.2019-10.org.linux:client

Created Node ACL for iqn.2019-10.org.linux:client

Created mapped LUN 0.

4-5, set the listening IP address and port number of the ISCSI server. IP address is the IP address of the server.

/ iscsi/iqn.2019-10.org.linux/tpg1/acls > cd.

/ iscsi/iqn.2019-10.org.linux/tpg1 > cd portals

/ iscsi/iqn.2019-10.org.linux/tpg1/portals > create 192.168.13.10

Using default IP port 3260

Created network portal 192.168.13.10:3260.

4-6, after configuration, execute exit exit. This command is saved and exited by default, so don't worry that the previous operation will disappear.

Systemc restart targetd restarts the service to make it effective

4-7, because of our newly added port number, we need to add policy to the firewall configuration.

Firewall-cmd-- add-port=3260/tcp-- permanent adds a network port of 3260 and takes effect permanently

Firewall-cmd-- reload overloads the firewall to make it work

The ISCSI server is configured here. Let's configure the Linux client and the Windows client for comparison.

5. Configure the linux client

5-1 Magi Yum-y install iscsi-initiator-utils installs the ISCSI client service program initiator

The 5-2 ISCSI protocol is verified by the name of the client, so the name is the unique identity of the iSCSI client.

Edit the initiator name file in the ISCSI client, fill in the access control list name of the server, then restart the service program, and set it to boot.

Vim / etc/iscsi/initiatorname.iscsi

InitiatorName=iqn.2019-10.org.linux

Systemctl restart iscsid

Systemctl enable iscsid

The steps to access and use shared storage resources by the 5-3 Magi iSCSI client are "first discover, then log in, and then mount."

Iscsiadm is a command line tool for managing, querying, inserting, updating or deleting iSCSI database configuration files. Users need to use this tool to scan to find the remote iSCSI server, and then to see what shared storage resources are available on the server.

The purpose of the-m discovery parameter is to scan and discover the available storage resources, the-t sendtarget parameter is the type of scan operation, and the-p 192.168.13.10 parameter is the IP address of the iSCSI server.

Iscsiadm-m discovery-t sendtarget-p 192.168.13.10

Prepare to log in to the ISCSI server. The-m node parameter is to take the host where the client resides as a node server, and the-T iqn.2019-10.org.linux parameter is the storage resource to be used (you can directly copy the results found by scanning in the previous command to avoid typing errors), and the-p 192.168.13.10 parameter is still the IP address of the other iSCSI server. Finally, use the-- login or-l parameters for login authentication

Iscsiadm-m node-T iqn.2019-10.org.linux-p 192.168.13.10-login

The word "successful" appears, that is, the login is successful.

5-4, after successful login, you will see an extra device file named / dev/sdb on the client host.

File / dev/sdb file commands for viewing files

/ dev/sdb: block special special block device file

5-5, and then there is the standard disk operation process, which is formatted and then mounted.

Mkfs.xfs / dev/sdb file system formatted into xfs

Mkdir / iscsi create mount directory

Mount / dev/sdb / iscsi execute mount command

Df-h to check whether the mount is successful. If it is successful, you can see the device of sdb at the bottom.

5-6, because the udev service names hard disk devices in the order in which the system identifies hard disk devices, when the client host uses multiple remote storage resources at the same time, if the order of identifying remote devices changes next time, the files in the client mount directory will also be confused. To prevent this from happening, we should mount the device using the UUID unique identifier of the device in the / etc/fstab configuration file

Blkid | grep / dev/sdb blkid command to view the device name, file system, and UUID.

Because / dev/sdb is a network storage device, and the ISCSI protocol transmits data based on the TCP/IP network, the parameter _ netdev is added to the fstab configuration file to indicate that the system is mounted and used after networking, so as to avoid too long starting time or boot failure.

Vim / etc/fstab

UUID=eb9cbf2f-fce8-413a-b770-8b0f243e8ad6 / iscsi xfs defaults,_netdev 0 0

5-7, if you no longer use ISCSI shared storage resources, you can uninstall them with the-u parameter of the iscsiadm command

Iscsiadm-m node-T iqn.2019-10.org.linux-u

The word "successful" appears, that is, the uninstall is successful.

6. Configure the Windows client

6-1, find Control Panel-- > system and Security-- > Administrative tools-- > iSCSI initiator, double-click to open it; the first time it starts, it will prompt "Microsoft iSCSI server is not running" and click "Yes" to start the program.

6-2, after running the iSCSI initiator, write the IP address of the iSCSI server in the "Target" text box of the "Target" tab, and then click the "Quick Connect" button. You can see the shared hard disk storage resources in the pop-up "Quick Connect" prompt box. Click the "finish" button.

6-3. Because ACL is set on the iSCSI server program, remote storage resources can only be used if the client name is consistent with the name in the ACL policy, so you need to click the change button in the configuration tab to modify the name of the iSCSI initiator to the name defined by the server ACL.

6-4, after confirming that the name of the client initiator has been modified correctly, you can return to the "destination" tab page, and then click the "Connect" button to make a connection request and successfully connect to the page of the remote shared storage resource.

6-5, right-click the "computer" icon on the desktop, open the computer management program, start initializing the disk, and then create a new simple volume, click next, select the drive letter, click next, set the disk device format and volume label, and click next to finish.

When you are finished, you can see our newly created disk in the computer, and you can use it.

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