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 build iSCSI shared Storage under Linux

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

Share

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

This article is about how to build iSCSI shared storage under Linux. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

I. brief introduction

ISCSI (internet SCSI) technology, researched and developed by IBM, is a SCSI instruction set that can be used by hardware devices and can run on the upper layer of IP protocol. This instruction set can run SCSI protocol on IP network and enable it to choose routes on high-speed Gigabit Ethernet. ISCSI technology is a new storage technology, which combines the existing SCSI interface with Ethernet technology, so that the server can exchange data with the storage device using IP network.

ISCSI is a TCP/IP-based protocol used to establish and manage connections between IP storage devices, hosts, and clients, and to create storage area networks (SAN). SAN makes it possible for the SCSI protocol to be used in high-speed data transmission networks, which are carried out at the block level (block-level) between multiple data storage networks. The SCSI structure is based on Candace S mode, and its common application environment is that the devices are close to each other, and these devices are connected by the SCSI bus.

The main function of iSCSI is to encapsulate and transfer a large amount of data between the host system (initiator initiator) and the storage device (target target) on the TCP/IP network.

The topology of the complete iSCSI system is as follows:

In essence, an iSCSI initiator is a client device that connects to a service provided by the server (in this case, the iSCSI target) and initiates a request for that service. The iSCSI initiator software needs to be installed on each Oracle RAC node (rac1 and rac2). The iSCSI initiator can be implemented in either software or hardware. The software iSCSI initiator is available for most major operating system platforms. For this article, we will use the free Linux Open-iSCSI software driver available in iscsi-initiator-utils RPM. ISCSI software initiators are typically used in conjunction with standard network interface cards (NIC) (in most cases Gigabit Ethernet cards). The hardware initiator is an iSCSI HBA (or TCP offload engine (TOE) card), which is essentially a dedicated Ethernet card on which the SCSI ASIC can uninstall all work from the system CPU (TCP and SCSI commands). ISCSI HBA can be purchased from many vendors, including Adaptec, Alacritech, Intel, and QLogic.

The iSCSI target is the "server" component of the iSCSI network. It is usually a storage device that contains the information you need and responds to requests from one or more initiators. For the purposes of this article, the node rac1 will be the iSCSI target.

2. Experimental environment:

1. The operating system turns off the firewall and disables SELinux

2. ISCSI shared storage topology diagram:

3. There are many types of devices that can be shared by iSCSI, including image files (* .img), partitions (partition), physical hard disks, raid devices, logical volumes, and so on. I will only use physical disk partitions for testing, and you can test other types yourself.

Third, the experimental steps

(1) configure iscsi target:

Scenario 1: command line configuration, valid immediately, restart invalid

1. Add a disk device to target: sdb

2. Install the package and start the service

[root@rac1 ~] # yum install-y scsi-target-utils

[root@rac1 ~] # service tgtd start

3. Create target

[root@rac1] # tgtadm-lld / dev/sdb-mode target-op new-tid 1-targetname iqn.2017-04.comcomsys:iscsi.fcdisk

4. Create lun

[root@rac1] # tgtadm-lld iscsi-mode logicalunit-op new-tid 1-lun 1-backing-store / dev/sdb

[root@rac1 ~] # tgtadm-- lld iscsi-- mode logicalunit-- op delete-- tid 1-- lun 1 # method to delete lun

5. Authorization

[root@rac1 ~] # tgtadm-- lld iscsi-- mode target-- op bind-- tid 1-- initiator-address 10.1.1.0 Compact 24 # restricts access only to network segments of 10.1.1.0

6. View the defined information

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

Scenario 2: define in the configuration file, restart is valid

1. Install tgt

RedHat6 comes with scsi-target-utils software, which we use to set up target.

[root@rac1 ~] # yum install scsi-target-utils-y

2. Configure tgt

The main configuration file for tgt is / etc/tgt/targets.conf, so let's set it up.

Add the following settings at the end of the file:

Description:

Iqn = iSCSI Qualified Name

The name rules for iSCSI target are as follows:

Iqn.2014-07.dev.iscsi-target:iscsidisk-> iqn. Year-month. The domain name is written in reverse. Equipment identification

Each backing-store on the same target is called a logical unit number (Logical Unit Number,LUN), and there is a LUN in this experiment.

Other advanced settings such as initiator-address and incominguser are configured by yourselves.

3. Start iSCSI target

[root@rac1 ~] # / etc/init.d/tgtd start

[root@rac1 ~] # chkconfig tgtd on

[root@rac1 ~] # netstat-tulnp | grep tgt

4. View iSCSI target

[root@rac1 ~] # tgt-admin-show

LUN0 is the controller, and you can see the size and disk path of each LUN.

At this point, the iSCSI Target is set.

(2) configure iSCSI Initiator

1. Install initiator

[root@rac1 ~] # yum-y install iscsi-initiator-utils

2. Set up boot boot

[root@rac1 ~] # chkconfig iscsid on

[root@rac1 ~] # chkconfig iscsi on

3. Modify the configuration file

Initiator configuration document is located in / etc/iscsi/, this directory has two files, initiatorname.iscsi and iscsid.conf, where iscsid.conf is its configuration file, initiatorname.iscsi is the name marked initiator, its default name is InitiatorName= InitiatorName=iqn.1994-05.com.redhat:2f897b321a2, we can change it according to the actual situation, it is easy to distinguish, here we modify to InitiatorName= iqn.2017-04.com.comsys:fcdisk.sdb.

Because we do not set access restrictions in target, the iscsid.conf file does not need to be modified.

A little knowledge:

[root@rac2 iscsi] # echo "InitiatorName= `iscsi-iname-p iqn.2017-04.com.comsys: fcdisk.sdb`" > / etc/iscsi/initiatorname.iscsi (use the iscsi-iname command to generate random numbers)

4. Detect target

If we don't know the target name of the target host in advance, we need to detect it.

Basic format: iscsiadm-m discovery-d #-t sendtargets-p IP [: PORT]

[root@rac2 iscsi] iscsiadm-m discovery-t sendtargets-p 10.1.1.51

Description:

-m discovery / / detect target

-t sendtargets / / through iscsi protocol (sendtargets can be abbreviated to st)

-p IP:port / / specify the IP and port of target. If port is not written, the default is 3260.

5. View nodes

The results detected by iscsiadm are written to / var/lib/iscsi/nodes/, so just start / etc/init.d/iscsi and automatically connect to the correct target the next time you boot.

[root@rac2 iscsi] ll-R / var/lib/iscsi/nodes/

The detection information is written into the file / var/lib/iscsi/nodes/ iqn.2017-04.com.comsys:iscsi.fcdisk / 10.1.1.51, 3260, and reference 1 default.

6. Connect target

View all the target on the current system

[root@rac2 iscsi] iscsiadm-m node

Additional knowledge:

Connect and exit

Basic format: iscsiadm-m node [- d debug_level] [[- T targetname-p ip:port-I ifaceN] [- l |-u |-R |-s]] [[- o operation]

[root@rac2 iscsi] iscsiadm-m node-d 1-T iqn.2017-04.com.comsys:iscsi.fcdisk-p 10.1.1.51Rose 3260-u # exit

[root@rac2 iscsi] iscsiadm-m node-d 1-T iqn.2017-04.com.comsys:iscsi.fcdisk-p 10.1.1.51purl 3260-o # Delete the specified entry

Connect target

[root@rac2] iscsiadm-m node-d 1-T iqn.2017-04.com.comsys:iscsi.fcdisk-p 10.1.1.51pur3260-l

7. Check the disk condition

[root@rac2 ~] fdisk-l

You can see that there is an extra hard drive on the initiator, which is the same size as the LUN on the target. At this point, you can use these iSCSI devices as if you were using a local disk, so let's test it.

8. View target information

[root@rac1] tgt-admin-- show

(3) testing

Partition / dev/sdb on the target side, and then view the specific partition situation on the client side.

[root@rac1 ~] # fdisk / dev/sdb

Destination side partition:

The client views the partition results:

Thank you for reading! This is the end of the article on "how to build iSCSI shared storage under Linux". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

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