Search Suggest

Bài đăng

Configuring iSCSI Target & Inititator on CentOS

iSCSI (Internet Small Computer System Interface) is a IP-based storage networking standard for linking data storage facilities like SAN (Storage Area Networks).

iSCSI Target - It is the target or provider of the disks to the clients.
iSCSI Initiator - It is the client requesting the disks from the server(target).

Here we are going to use 2 machines for this demo, one will be the server and other one will be the initiator client.
Server IP : 192.168.1.100
Server Name : server.example.com

Client IP : 192.168.1.101
Server Name : client.example.com

Configuring iSCSI Target:
Install the iSCSI target software on the server machine using YUM.
# yum install scsi-target-utils -y
Start the iSCSI target daemon and make sure the service is available after restart.
# service tgtd start && chkconfig tgtd on




Create an LVM for presenting the disk to the clients. The reason why choose LVM is because the disk can be extended incase we need to without disrupting the services, i.e. online extending of disk can be done with LVM.


Creating a LVM:
# fdisk /dev/sda




# partprobe /dev/sda

Check whether the newly created partition is read by the kernel are not.
# cat /proc/partitions


# pvcreate /dev/sda5
 

# pvdisplay

 



# vgcreate myvolgrp /dev/sda5




# vgdisplay /dev/myvolgrp




Creating Logical Volume using the extents
# lvcreate -l 478 -n mylogvol myvolgrp




# lvdisplay /dev/myvolgrp/mylogvol



Format the newly created partition /dev/myvolgrp/mylogvol
# mkfs.ext3 /dev/myvolgrp/mylogvol

Now we will configure the iSCSI Target for presenting this LVM to the clients. At the end of the file type the below configuration.
# vim /etc/tgt/targets.conf
<target iqn.2012.07.com.example:server.target1>
              backing-store /dev/myvolgrp/mylogvol
</target>




Reload the iSCSI Target service.
# service tgtd reload

If firewall is enabled, make sure 3260 and 860 both TCP & UDP ports are allowed through the firewall.


# netstat -ntlup | grep 3260




Configuring iSCSI Initiator:

Install the iSCSI Initiator package in the client system.

# yum install iscsi-initiator-utils -y

Start the iscsi daemon and make sure service is available even after restart.
# service iscsi start && chkconfig iscsi on

Configure the initiator using the following commands.

# iscsiadm --mode discovery --type sendtargets --portal 192.168.1.100




# iscsiaadm --mode node --targetname iqn.2012.07.com.example:server.target1 --portal 192.168.1.100:3260 --login




From the output of the previous command we know the SCSI disk is /dev/sdb and its of 2GB in size, now lets create a partition and mount it
# fdisk /dev/sdb

# partprobe /dev/sdb

Create a EXT3 partition of the newly created partition and mount it on /data.
# mkdir /data
# mkfs.ext3 /dev/sdb1

# mount /data /dev/sdb1

# vim /etc/fstab
/dev/sdb1        /data         ext3           defaults         0   0 

Đăng nhận xét