6
Set up an iSCSI Server in RHEL 6.x Prabir Meher <[email protected]> Page 1 What is iSCSI? iSCSI is a network storage protocol above TCP/IP suite. iSCSI protocol encapsulates SCSI data into TCP packets. It allows a host to connect to a storage array via a simple Ethernet connection. This solution is quite cheaper than the Fibre Channel SAN as Fibre Channel HBAs and switches are pretty expensive. The user of the client system sees the storage array’s LUNs like a local disk. iSCSI devices should not be confused with NAS (Network Attached Storage) devices e.g. NFS (Network File System). Note: The most important difference is that NFS volumes can be accessed by multiple hosts, but one iSCSI volume should be accessed by one host. iSCSI Terminology Initiator: It’s the name of the iSCSI client. The iSCSI client has a block level access to the iSCSI devices, which can be a disk, tape drive or CD/DVD writer. One client can use multiple iSCSI devices. Target: It’s the iSCSI Server. It offers the devices like disks, tape drives, cd/dvd drives to the clients. One device can be accessed by one client. Discovery: It’s the process which shows the targets for the initiator. Naming Rule [ iqn.year-month.domain:anyname ] iSCSI Target can be used to Setup stateless server/client (used in diskless setup) Share disks and tape drives with remote client over LAN, WAN or the Internet. Setup SAN – Storage Array etc… Test Environment In my test setup, I am using two virtual hosts viz., server1 (192.168.150.140) and station1 (192.168.150.142) and both runs RHEL 6.3 64-bit. Here, server1 will be my iSCSI target and station1 will be the iSCSI initiator.

Set Up an iSCSI Server in RHEL 6.x

Embed Size (px)

DESCRIPTION

Learn how to export a block level device e.g. /dev/sda or sdb using iSCSI protocol over the network. If you have a storage device array, you can configure multiple Logical Units (LUNs) and distribute it across the networks to different clients for data storage or you can even install OS on this particular exported partition using the Advanced OS Install Option of the OS you are going to install which allow you to choose a network based storage.

Citation preview

Page 1: Set Up an iSCSI Server in RHEL 6.x

Set up an iSCSI Server in RHEL 6.x

Prabir Meher <[email protected]> Page 1

What is iSCSI?

iSCSI is a network storage protocol above TCP/IP suite. iSCSI protocol encapsulates SCSI data into TCP

packets. It allows a host to connect to a storage array via a simple Ethernet connection. This solution is

quite cheaper than the Fibre Channel SAN as Fibre Channel HBAs and switches are pretty expensive.

The user of the client system sees the storage array’s LUNs like a local disk.

iSCSI devices should not be confused with NAS (Network Attached Storage) devices e.g. NFS (Network

File System).

Note: The most important difference is that NFS volumes can be accessed by multiple hosts, but one

iSCSI volume should be accessed by one host.

iSCSI Terminology

Initiator: It’s the name of the iSCSI client. The iSCSI client has a block level access to the iSCSI devices,

which can be a disk, tape drive or CD/DVD writer. One client can use multiple iSCSI devices.

Target: It’s the iSCSI Server. It offers the devices like disks, tape drives, cd/dvd drives to the clients. One

device can be accessed by one client.

Discovery: It’s the process which shows the targets for the initiator.

Naming Rule

[ iqn.year-month.domain:anyname ]

iSCSI Target can be used to

• Setup stateless server/client (used in diskless setup)

• Share disks and tape drives with remote client over LAN, WAN or the Internet.

• Setup SAN – Storage Array etc…

Test Environment

In my test setup, I am using two virtual hosts viz., server1 (192.168.150.140) and station1

(192.168.150.142) and both runs RHEL 6.3 64-bit. Here, server1 will be my iSCSI target and station1 will

be the iSCSI initiator.

Page 2: Set Up an iSCSI Server in RHEL 6.x

Set up an iSCSI Server in RHEL 6.x

Prabir Meher <[email protected]> Page 2

Creating the iSCSI Target

• First, we need to add an additional hard drive to create an iSCSI Target. In my case, it’s /dev/sdb

and has only one partition /dev/sdb1 of size around 50 GB.

• Here I am creating a LVM based storage because of the flexibility it provides, you can proceed

without LVM if you want.

Create a physical volume:

Create a volume group:

Create a logical volume:

Now, we need to install the package which will provide the iSCSI utils for our setup.

# yum install scsi-target-utils

Add the following at the end of the file: /etc/tgt/targets.conf

<target iqn.2013-02.com.example:target1> backing-store /dev/target/target_01 initiator-address 192.168.150.142 </target>

Now start the server

# service tgtd start

OR

# /etc/init.d/tgtd start

Page 3: Set Up an iSCSI Server in RHEL 6.x

Set up an iSCSI Server in RHEL 6.x

Prabir Meher <[email protected]> Page 3

IPTables Configuration

If your host is using iptables, open port 3260 for iSCSI access:

# iptables -I INPUT -p tcp -m tcp --dport 3260 -j ACCEPT # service iptables save # service iptables restart

Verify the new iSCSI Targets

View the new targets to ensure the setup was successful, by using the tgt-admin command:

# tgt-admin --show

LUN 0 will appear as a device of type "controller".

Page 4: Set Up an iSCSI Server in RHEL 6.x

Set up an iSCSI Server in RHEL 6.x

Prabir Meher <[email protected]> Page 4

Notice that the ACL information is set to station2 (192.168.150.142) that means this particular LUN1 is

accessible to only station2.

Now we will configure iSCSI initiator

Install the following package:

# yum install iscsi-initiator-utils

Testing the targets

Now we can test whether the new iSCSI device is discoverable from client1.example.com:

Discover the targets as follows:

So far so good!

Confirm status after discovery

# iscsiadm -m node -o show

Login to target

Confirm session

Page 5: Set Up an iSCSI Server in RHEL 6.x

Set up an iSCSI Server in RHEL 6.x

Prabir Meher <[email protected]> Page 5

Confirm partitions:

You can see that a new block device /dev/sdc has been added to the system.

Success! Now the target is enabled to be accessed upon reboots (persistent) and it's added to a node

database in /var/lib/iscsi. The iscsid service will access this database upon system startup and re-attach

your iSCSI Targets.

To disconnect the iSCSI Target, you will need to log out:

# iscsiadm -m node -T iqn.2013-02.com.example:target1 -p server1 –u

You could also log out of all attached targets by using this command:

# iscsiadm -m node -U all

Page 6: Set Up an iSCSI Server in RHEL 6.x

Set up an iSCSI Server in RHEL 6.x

Prabir Meher <[email protected]> Page 6

To again list the target, you need to login to the target system as follows:

# iscsiadm –m node --login