Install iSCSI in CentOS 6.6
I. Introduction to ISCSI
ISCSI, internet SCSI, also known as IP-SAN, is a standard developed by IETF to map SCSI data blocks into Ethernet packets. ISCSI is a TCP/IP-based protocol used to establish and manage the connection between IP storage devices, hosts and clients, and create a storage area network (SAN ). SAN makes it possible to apply the SCSI protocol to high-speed data transmission networks. Such transmission is performed between multiple data storage networks at the block-level. The SCSI structure is based on the C/S mode. The common application environment is that devices are close to each other and these devices are connected by the SCSI bus.
The main function of iSCSI is to encapsulate and reliably transmit large amounts of data between the host system (initiator) and the storage device (target) on the TCP/IP network.
Basically, the iSCSI protocol is a method to transmit SCSI data blocks with short latencies over an IP network.
The complete iSCSI system topology is as follows:
Compared with traditional SCSI technology, iSCSI technology has the following three revolutionary changes:
- The original SCSI used only on the local machine is transmitted through the TCP/IP network, so that the connection distance can be extended in an unlimited region;
-
- The number of connected servers is infinite (the upper limit of the original SCSI-3 is 15 );
-
- Because it is a server architecture, online resizing and dynamic deployment can also be realized.
ISCSI protocol structure:
-------------------------------------- Split line --------------------------------------
Mount iSCSI network storage in CentOS 6.4
Web Service shared storage cluster architecture based on RHCS + iSCSI + CLVM
Configure iSCSI storage and multi-path functions in Linux
Build an ip san-based iSCSI Storage System
ISCSI connection failure Solution
Install CentOS 6.0 and configure the iSCSI service in Citrix XenServer
CentOS 5.3 mounts storage cabinets with iSCSI
Takes you three steps to quickly learn how to build iSCSI
-------------------------------------- Split line --------------------------------------
2. Build an ip san-based ISCSI Storage System
- Planning:
-
- Environment: CentOS 6.6 32-bit
-
- Server IP Address: 192.168.1.43
-
- Client IP Address: 192.168.1.111
-
- Shared Disk:/dev/sdb
1. Configure the server
- [Root @ localhost ~] # Yum-y install scsi-target-utils # install the server software
-
- [Root @ node1 iscsi] # rpm-ql scsi-target-utils
- /Etc/rc. d/init. d/tgtd
- /Etc/sysconfig/tgtd
- /Etc/tgt/targets. conf # configuration file
- /Usr/sbin/tgt-admin
- /Usr/sbin/tgt-setup-lun
- /Usr/sbin/tgtadm
- /Usr/sbin/tgtd
- /Usr/sbin/tgtimg
- /Usr/share/doc/scsi-target-utils-1.0.24
- /Usr/share/doc/scsi-target-utils-1.0.24/README
- /Usr/share/doc/scsi-target-utils-1.0.24/README. iscsi
- /Usr/share/doc/scsi-target-utils-1.0.24/README. iser
- /Usr/share/doc/scsi-target-utils-1.0.24/README. lu_configuration
- /Usr/share/doc/scsi-target-utils-1.0.24/README. mmc
- /Usr/share/man/man5/targets.conf.5.gz
- /Usr/share/man/man8/tgt-admin.8.gz
- /Usr/share/man/man8/tgt-setup-lun.8.gz
- /Usr/share/man/man8/tgtadm.8.gz
-
- [Root @ localhost ~] # Lsmod | grep scsi
- Mptscsih 31330 1 mptspi
- Mptbase 86744 2 mptspi, mptscsih
- Scsi_transport_spi 19726 1 mptspi # Advanced Driver
Iscsi can be configured using commands or configuration files. We first use the command line for Configuration:
- [Root @ node1 iscsi] # service tgtd start
- Starting SCSI target daemon: [OK]
-
- [Root @ node1 iscsi] # ss-tlnp | grep 3260 # Listening on port 3260
- LISTEN 0 128: 3260: * users :( ("tgtd", 1188), ("tgtd", 11885 ))
- LISTEN 0 128 *: 3260 *: * users :( ("tgtd", 11882, 4), ("tgtd", 11885, 4 ))
-
- [Root @ localhost ~] # Tgtadm-L iscsi-o new-m target-t 1-T iqn.2015-08.com. feiyu. testsan: 1 # create a target,-t specify TID,-T specify name
Iqn indicates "ISCSI Qualified Name", or iqn for short.
- [Root @ localhost ~] # Tgtadm-L iscsi-o show-m target
- Target 1: iqn.2015-08.com. feiyu. testsan: 1
- System information:
- Driver: iscsi
- State: ready
- I _T nexus information:
- LUN information:
- LUN: 0
- Type: controller
- Scsi id: IET 00010000
- Scsi sn: beaf10
- Size: 0 MB, Block size: 1
- Online: Yes
- Removable media: No
- Prevent removal: No
- Readonly: No
- Backing store type: null
- Backing store path: None
- Backing store flags:
- Account information:
- ACL information:
Then, set the LUN (Logical Unit Number). On the server side, you only need to create partitions without formatting:
- [Root @ localhost ~] # Tgtadm-L iscsi-o new-m logicalunit-t 1-l 1-B/dev/sdb5 # create a LUN,-m indicates the mode,-l: LUN, -B: Device
-
- [Root @ localhost ~] # Tgtadm-L iscsi-o bind-m target-t 1-I 192.168.0.0/16
-
- [Root @ node1 iscsi] # tgtadm-L iscsi-o show-m target
- Target 1: iqn.2015-08.com. feiyu. testsan: 1
- System information:
- Driver: iscsi
- State: ready
- I _T nexus information:
- LUN information:
- LUN: 0
- Type: controller
- Scsi id: IET 00010000
- Scsi sn: beaf10
- Size: 0 MB, Block size: 1
- Online: Yes
- Removable media: No
- Prevent removal: No
- Readonly: No
- Backing store type: null
- Backing store path: None
- Backing store flags:
- LUN: 1
- Type: disk
- Scsi id: IET 00010001
- Scsi sn: beaf11
- Size: 2107 MB, Block size: 512
- Online: Yes
- Removable media: No
- Prevent removal: No
- Readonly: No
- Backing store type: rdwr
- Backing store path:/dev/sdb5
- Backing store flags:
- Account information:
- ACL information:
-
- [Root @ node1 iscsi] # tgtadm-L iscsi-o bind-m target-t 1-I 192.168.0.0/16 # Set the shared area
- [Root @ node1 iscsi] # tgtadm-L iscsi-o show-m target
- Target 1: iqn.2015-08.com. feiyu. testsan: 1
- System information:
- Driver: iscsi
- State: ready
- I _T nexus information:
- LUN information:
- LUN: 0
- Type: controller
- Scsi id: IET 00010000
- Scsi sn: beaf10
- Size: 0 MB, Block size: 1
- Online: Yes
- Removable media: No
- Prevent removal: No
- Readonly: No
- Backing store type: null
- Backing store path: None
- Backing store flags:
- LUN: 1
- Type: disk
- Scsi id: IET 00010001
- Scsi sn: beaf11
- Size: 2107 MB, Block size: 512
- Online: Yes
- Removable media: No
- Prevent removal: No
- Readonly: No
- Backing store type: rdwr
- Backing store path:/dev/sda5
- Backing store flags:
- Account information:
- ACL information:
- 192.168.0.0/16
-
- [Root @ localhost ~] # Tgtadm-L iscsi-o new-m logicalunit-t 1-l 2-B/dev/sdb6 # bind the second LUN
2. Configure the client
- [Root @ node1 ~] # Yum install-y iscsi-initiator-utils # install the client
-
-
- [Root @ node1 iscsi] # echo "InitiatorName = 'iscsi-iname-p iqn.2013-05.com. feiyu '">/etc/iscsi/initiatorname. iscsi # generate iqn
- [Root @ node1 iscsi] # echo "InitiatorAlias = initiator1">/etc/iscsi/initiatorname. iscsi # define an alias
-
- [Root @ node1 iscsi] # ls
- Initiatorname. iscsi iscsid. conf
- [Root @ node1 iscsi] # cat initiatorname. iscsi # view the defined data
- InitiatorName = iqn.2015-08.com. feiyu: 201734bd52221
- InitiatorAlias = initiator1
-
- [Root @ node1 ~] # Service iscsi start # start the service. You need to start two services.
- [Root @ node1 ~] # Service iscsid start
- [Root @ node1 ~] # Chkconfig iscsi on
- [Root @ node1 ~] # Chkconfig iscsid on
If the following error occurs, the firewall on the server may be irrelevant!
- [Root @ node1 ~] # Iscsiadm-m discovery-t st-p 192.168.1.43
- Starting iscsid: [OK]
- Iscsiadm: cannot make connection to 192.168.1.43: No route to host
-
- [Root @ node1 ~] # Iscsiadm-m discovery-t st-p 192.168.1.43 # Test
- 192.168.1.43: 3260,1 iqn.2015-08.com. feiyu. testsan: 1
-
- [Root @ node1 ~] # Iscsiadm-m node-T iqn.2015-08.com. feiyu. testsan: 1-p 192.168.1.43-l # login node
- Logging in to [iface: default, target: iqn.2015-08.com. feiyu. testsan: 1, portal: 192.168.1.43, 3260] (multiple)
- Login to [iface: default, target: iqn.2015-08.com. feiyu. testsan: 1, portal: 192.168.1.43, 3260] successful.
-
- [Root @ node1 ~] # Fdisk-l # a hard disk is added after logon,
-
- Disk/dev/sda: 21.5 GB, 21474836480 bytes
- 255 heads, 63 sectors/track, 2610 cylinders
- Units = cylinders of 16065*512 = 8225280 bytes
- Sector size (logical/physical): 512 bytes/512 bytes
- I/O size (minimum/optimal): 512 bytes/512 bytes
- Disk identifier: 0x0006d052
-
- Device Boot Start End Blocks Id System
- /Dev/sda1*1 39 307200 83 Linux
- Partition 1 does not end on cylinder boundary.
- /Dev/sda2 39 2354 18598912 83 Linux
- /Dev/sda3 2354 2610 2057689 5 Extended
- /Dev/sda5 2354 2610 2057657 + 83 Linux
-
- Disk/dev/sdc: 10.7 GB, 10742183424 bytes -------> iscsi Device
- 64 heads, 32 sectors/track, 10244 cylinders
- Units = cylinders of 2048*512 = 1048576 bytes
- Sector size (logical/physical): 512 bytes/512 bytes
- I/O size (minimum/optimal): 512 bytes/512 bytes
- Disk identifier: 0x00000000
Create a partition for the disk and format it.
- [Root @ node1 ~] # Mke2fs-t ext4/dev/sdc1
For more details, please continue to read the highlights on the next page: