Create an iSCSI storage server in the rhel5 System

Source: Internet
Author: User
Set up the iSCSI storage server 2010.09.18 tsengyia # 126.com in the rhel5 System

Http://selinux.cublog.cn ####################################### ############################
System Environment: rhel5.5 [2.6.18-194. EL5]
Software Environment (use the RPM package that comes with the rhel5.5 CD ):
Server:
Clusterstorage/scsi-target-utils-0.0.6.20091205snap.el5 _. 1. i386.rpm
Clusterstorage/perl-Config-General-2.40-1.el5.noarch.rpm
Server/libibverbs-1.1.3-2.el5.i386.rpm
Server/openib-1.4.1-5.el5.noarch.rpm
Server/librdmacm-1.0.10-1.el5.i386.rpm
Server/libcxgb3-1.2.5-2.el5.i386.rpm
Client:
Server/iscsi-initiator-utils-6.2.0.871-0.16.el5.i386.rpm -- Note:
1. The SCSI-target-utils package file does not exist on the rhel5.0 disc. It seems that it has been available since rhel5.1. If you want to download the source package, you can get it from the http://iscsitarget.sourceforge.net.
2. The installation of the libibverbs package depends on the libibverbs-driver, which can be obtained by installing the libcxgb3 package (or either of the libmthca, libmlx4, or libnes). Otherwise, an error may occur:
Error: Failed dependencies:
Libibverbs-driver is needed by libibverbs-1.1.3-2.el5.i386 ################################# ################################## 1. Configure the storage server (iSCSI target)
Host Name: host1
IP Address: 192.168.4.77

1. Install the SCSI-target-utils Software Package
[Root @ host1 ~] # Mount/dev/CDROM/Media/CDROM
[Root @ host1 ~] # Cd/Media/CDROM
[Root @ host1 CDROM] # rpm-IVH clusterstorage/perl-Config-General-2.40-1.el5.noarch.rpm \
> Clusterstorage/scsi-target-utils-0.0.6.20091205snap.el5 _. 1. i386.rpm \
> Server/libibverbs-1.1.3-2.el5.i386.rpm \
> Server/openib-1.4.1-5.el5.noarch.rpm \
> Server/librdmacm-1.0.10-1.el5.i386.rpm \
> Server/libcxgb3-1.2.5-2.el5.i386.rpm-server-side configuration process can refer to the/usr/share/doc/scsi-target-utils-0.0/readme. iSCSI file, the main management tool of the command line is tgtadm, the system service is tgtd. 2. Create a storage target for output
1) Start the tgtd Service (target Daemon)
[Root @ host1 ~] # Service tgtd start
Starting SCSI target daemon: Starting target framework daemon
[Root @ host1 ~] # Chkconfig -- level 35 tgtd on 2) define two targets (for different clients)
[Root @ host1 ~] # Tgtadm -- LLD iSCSI -- op new -- Mode target -- TID 1 -- targetname iqn.2010-09.cn. cnblog. SELinux: target1.raid10. host1
[Root @ host1 ~] # Tgtadm -- LLD iSCSI -- op new -- Mode target -- TID 2 -- targetname iqn.2010-09.cn. cnblog. SELinux: target2.disk6. host1 -- where "iqn.2010-09 ...... "is used to specify the target name that complies with iSCSI specifications, in the format of" iqn. yyyy-mm. reverse Domain Name: Mark "3) confirm the target information of the new definition. By default, Lun 0 is automatically created for each target (not detachable)
[Root @ host1 ~] # Tgtadm -- LLD iSCSI -- op show -- Mode target
Target 1: iqn.2010-09.cn. cnblog. SELinux: target1.raid10. host1
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
Online: Yes
Removable Media: No
Backing store type: rdwr
Backing store path: None
Account Information:
ACL information:
Target 2: iqn.2010-09.cn. cnblog. SELinux: target2.disk6. host1
System Information:
Driver: iSCSI
...... 3. Partitioning Lun (logical unit)
In the same target, multiple Luns can be divided. Each Lun can act as a server-side raid array, a single disk, partition, LVM, or file. If an independent entire disk is used as the Lun allocated to the client, the entire disk is still mapped to the client, and the client can directly use the File System on the original disk. If a disk array, partition, or file is allocated to the client as a Lun, the original data cannot be retained until it is mapped to the client and needs to be partitioned or formatted.
The following operations divide a raid 10 array into Lun 1 in target1, and separate a SCSI disk into Lun 1 in TARGET2 for use by different clients. 1) create a raid 10 disk array (soft RAID, using four SCSI disks)
[Root @ host1 ~] # Mdadm -- create -- verbose/dev/md0 -- Auto yes -- raid-devices = 4 -- level = 10/dev/SD [B-E]
Mdadm: Layout defaults to N1
Mdadm: Chunk Size defaults to 64 K
Mdadm: size set to 8388544 K
Mdadm: array/dev/md0 started [root @ host1 ~] # Ls-L/dev/md0 # // confirm the newly created Array Device File
BRW-r ----- 1 root disk 9, 0 09-18 08:43/dev/md0
[Root @ host1 ~] # Mdadm -- detail -- scan -- verbose # // confirm the array information
Array/dev/md0 level = raid10 num-devices = 4 metadata = 0.90
UUID = 90e8eb47: 420a08e7: e9b43c55: 2600513
Devices =/dev/SDB,/dev/SDC,/dev/SDD,/dev/SDE
[Root @ host1 ~] # Cat/proc/mdstat # // view the array status
Personalities: [raid10]
Md0: Active raid10 SDE [3] SDD [2] SDC [1] SDB [0]
16777088 blocks 64 K Chunks 2 near-copies [4/4] [UUUU]
Unused devices: <none> 2) divide/dev/md0 into Lun 1 in target1. Specify that the client 192.168.4.99 can be used.
[Root @ host1 ~] # Tgtadm -- LLD iSCSI -- op new -- Mode logicalunit -- TID 1 -- Lun 1 -- backing-store/dev/md0
[Root @ host1 ~] # Tgtadm -- LLD iSCSI -- op bind -- Mode target -- TID 1 -- initiator-address 192.168.4.99 3) divide/dev/SDF into Lun 1 in TARGET2 and specify that the client 192.168.4.88 can be used
[Root @ host1 ~] # Tgtadm -- LLD iSCSI -- op new -- Mode logicalunit -- TID 2 -- Lun 1 -- backing-store/dev/SDF
[Root @ host1 ~] # Tgtadm -- LLD iSCSI -- op bind -- Mode target -- TID 2 -- initiator-address 192.168.4.88 4) view the target information again and confirm the allocated Lun information.
[Root @ host1 ~] # Tgtadm -- LLD iSCSI -- op show -- Mode target
Target 1: iqn.2010-09.cn. cnblog. SELinux: target1.raid10. host1
......
Lun: 1 # // Lun 1 Information in target1
Type: Disk
Scsi id: Iet 00010001
SCSI Sn: beaf11
Size: 17180 MB
Online: Yes
Removable Media: No
Backing store type: rdwr
Backing store path:/dev/md0
Account Information:
ACL information:
192.168.4.99
Target 2: iqn.2010-09.cn. cnblog. SELinux: target2.disk6. host1
......
Lun: 1 # // Lun 1 Information in TARGET2
Type: Disk
Scsi id: Iet 00020001
SCSI Sn: beaf21
Size: 17180 MB
Online: Yes
Removable Media: No
Backing store type: rdwr
Backing store path:/dev/SDF
Account Information:
ACL information:
192.168.4.88 4. modify the configuration file and save the preceding key configuration [root @ host1 ~] # Vi/etc/TGT/targets. conf
Default-driver iSCSI
<Target iqn.2010-09.cn. cnblog. SELinux: target1.raid10. host1>
Backing-store/dev/md0
Initiator-address 192.168.4.99
</Target>
<Target iqn.2010-09.cn. cnblog. SELinux: target2.disk6. host1>
Backing-store/dev/SDF
Initiator-address 192.168.4.88
</Target> 2. Configure the storage client (iSCSI initiator)
Host Name: host2
IP Address: 192.168.4.99
Host Name: host3
IP Address: 192.168.4.88
-- The configuration of the storage client is similar. The following uses host2 as an example. 1. Install the iscsi-intiator-utils package [root @ host2 ~] # Mount/dev/CDROM/Media/CDROM
[Root @ host2 ~] # Cd/Media/CDROM/Server
[Root @ host2 server] # rpm-IVH iscsi-initiator-utils-6.2.0.871-0.16.el5.i386.rpm-client configuration process can be referred to/usr/share/doc/iscsi-initiator-utils-6.2.0-871/readme file, command line main administrative tool is iscsiadm, the system service is iSCSI. 2. Find the target information provided by the iSCSI server [root @ host2 ~] # Chkconfig -- level 35 iSCSI on
[Root @ host2 ~] # Service iSCSI start
[Root @ host2 ~] # Iscsiadm -- Mode discovery -- type sendtargets -- Portal 192.168.4.77
192.168.4.77: 3260,1 iqn.2010-09.cn. cnblog. SELinux: target1.raid10. host1 3. log on to the target [root @ host2 ~] provided by the iSCSI Server # Iscsiadm -- Mode node -- Portal 192.168.4.77 -- targetname iqn.2010-09.cn. cnblog. SELinux: target1.raid10. host1 -- Login
Logging in to [iface: Default, target: iqn.2010-09.cn. cnblog. SELinux: target1.raid10. host1, portal: 192.168.4.77, 3260]
Login to [iface: Default, target: iqn.2010-09.cn. cnblog. SELinux: target1.raid10. host1, portal: 192.168.4.77, 3260]: Successful [root @ host2 ~] # Lsscsi # // confirm that the iSCSI disk device has been connected (new) (a SCSI disk already exists, so the new one is/dev/sdb)
......
[1: 0: 0: 0> storage Iet controller 0001-
[1: 0: 0: 1] disk Iet VIRUAL-DISK 0001/dev/SDB [root @ host2 ~] # Sfdisk-S
......
/Dev/SDB: 16777088
Total: 33554304 Blocks 4. Partition and format iSCSI disk devices, and mount and use
If the target is assigned an independent Lun and already contains partitions and a file system, you do not need to partition or format it on the initiator. [Root @ host2 ~] # Fdisk/dev/SDB # // divide an sdb1 partition. The process is omitted.
[Root @ host2 ~] # Partprobe/dev/SDB
[Root @ host2 ~] # Mkfs-T ext3/dev/sdb1
[Root @ host2 ~] # Mkdir/Media/iSCSI
[Root @ host2 ~] # Vi/etc/fstab
......
/Dev/sdb1/Media/iSCSI ext3 _ netdev 0 0
[Root @ host2 ~] # Mount/Media/iSCSI
[Root @ host2 ~] # Mount | grep iSCSI # // view mounting information
/Dev/sdb1 on/Media/iSCSI type ext3 (RW, _ netdev) 5. Confirm the generated configuration file [root @ host2 ~] # Cd/var/lib/iSCSI/nodes/
[Root @ host2 ~] # Cat iqn.2010-09.cn. cnblog. SELinux \: target1.raid10. host1/19.09.4.77 \, 3260 \, 1/Default
# Begin record 2.0-871
Node. Name = iqn.2010-09.cn. cnblog. SELinux: target1.raid10. host1
Node. tpgt = 1
Node. startup = automatic
Iface. iscsi_ifacename = default
Iface. transport_name = TCP
Node. discovery_address = 192.168.4.77
Node. discovery_port = 3260
Node. discovery_type = send_targets
...... Iii. user verification for the iSCSI storage server (optional) 1. server-side (target) settings, taking target1 as an Example
1) Method 1:
[Root @ host1 ~] # Tgtadm -- LLD iSCSI -- op new -- Mode account -- User tsengyia -- Password
PWD @ 123
[Root @ host1 ~] # Tgtadm -- LLD iSCSI -- op bind -- Mode account -- TID 1 -- User tsengyia
[Root @ host1 ~] # Tgtadm -- LLD iSCSI -- op show -- Mode target
Target 1: iqn.2010-09.cn. cnblog. SELinux: target1.raid10. host1 # // confirm the authenticated user information of target1
......
Account Information:
Tsengyia
ACL information:
192.168.4.99 2) Method 2:
[Root @ host1 ~] # Vi/etc/TGT/targets. conf
Default-driver iSCSI
<Target iqn.2010-09.cn. cnblog. SELinux: target1.raid10. host1>
Backing-store/dev/md0
Incominguser tsengyia PWD @ 123
Initiator-address 192.168.4.99
</Target>
......
[Root @ host1 ~] # Service tgtd restart # // note that all initiator ends are disconnected first. 2. Set the client (intiator), as shown in host2.

[Root @ host2 ~] # Cd/var/lib/iSCSI/nodes/
[Root @ host2 ~] # Vi iqn.2010-09.cn. cnblog. SELinux \: target1.raid10. host1/19.09.4.77 \, 3260 \, 1/Default
# Begin record 2.0-871
Node. Name = iqn.2010-09.cn. cnblog. SELinux: target1.raid10. host1
Node. tpgt = 1
Node. startup = automatic
Iface. iscsi_ifacename = default
Iface. transport_name = TCP
Node. discovery_address = 192.168.4.77
Node. discovery_port = 3260
Node. discovery_type = send_targets
......
Node. session. Auth. authmethod = chap # // The default value is none. authentication is not used.
Node. session. Auth. Username = tsengyia
Node. session. Auth. Password = PWD @ 123
......
[Root @ host2 ~] # Service iSCSI restart

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.