[Linux study notes 24-3] network file system iscsi disk sharing

0 Experimental environment

  • Server side: node1: 192.168.43.101

An iSCSI Target
is an iSCSI target. It is a server component of an iSCSI network, usually a storage device, used to contain required data and respond to requests from an iSCSI initiator.

  • Client: node2: 192.168.43.111

iSCSI Initiator:
iSCSI initiator, essentially, an iSCSI initiator is a client device that connects and initiates requests to the server (iSCSI target)

1. Introduction to iscsi

Insert picture description here

SCSI (Internet Small Computer System Interface, Internet Small Computer System Interface) is an IP SAN technology researched and developed by IBM. This technology combines the existing SCSI interface with Ethernet technology and is based on a TCP/IP protocol Connect the iSCSI server (Target) and the client (Initiator), so that the encapsulated SCSI data packet can be transmitted on the general Internet, and finally realize the mapping of the iSCSI server to a storage space (disk) for the client after authentication.

2. iscsi configuration

2.1 Server configuration:

  1. fdisk /dev/sdb:Division partition ===>/dev/sdb1
  2. dnf install targetcli -y:installation
  3. systemctl enable --now target: Start the target service
  4. targetcli
#查看可用的命令
===>help
#查看
===>ls
#
===>/backstores/block create westos:storage1 /dev/sdb1

===>/iscsi create iqn.2020-12.org.westos:storage1
===>iscsi/iqn.2020-12.org.westos:storage1/tpg1/luns create /backstores/block/westos:storage1
===>iscsi/iqn.2020-12.org.westos:storage1/tpg1/acls create iqn.2020-12.org.westos:westoskey
#退出
===>exit
  1. firewall-cmd --permanent --add-port=3260/tcp
  2. firewall-cmd --reload

Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here

2.2 Client configuration:

  1. dnf search iscsi: Find
    dnf install iscsi-initiator-utils.x86_64 -y: Install
  2. tree /var/lib/iscsi/
  3. vim /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.2020-12.org.westos:westoskey
  1. systemctl restart iscsid
  2. fdisk -l: No /dev/sdb
  3. iscsiadm -m discovery -t st -p 192.168.43.101
  4. iscsiadm -m node -T iqn.2020-12.org.westos:storage1 -p 192.168.43.101 -l : Synchronized /dev/sdb (because there is already /dev/sda)
  5. fdisk /dev/sdb: Create partition ===>/dev/sdb1
  6. mkfs.xfs -K /dev/sdb1:format
  7. mount /dev/sdb1 /mnt/: Mount
#开机自动挂载
vim /etc/fstab
/dev/sdb1       /mnt    xfs     defaults,_netdev        0 0

Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here

3. Completely delete iscsi

3.1 Client delete:

  1. iscsiadm -m node -T iqn.2020-12.org.westos:storage1 -p 192.168.43.101 -u
  2. iscsiadm -m node -T iqn.2020-12.org.westos:storage1 -p 192.168.43.101 -o delete
    (If you don't execute this command, you will only uninstall it, delete the partition, and resynchronize after -u, systemctl restart iscsi)

3.2 Server delete:

targetcli

> clearconfig confirm=true
> exit

Guess you like

Origin blog.csdn.net/weixin_46069582/article/details/110681992
Recommended