Friday, 1 April 2016

Openfiler: Configure iScsi Target & Initiator on CentOS

Openfiler: Configure iScsi Target & Initiator on CentOSOpenfiler is Linux based operating system forked from rPath Linux distribution. Openfiler provides file-based Network Attached Storage (NAS) and block-based Storage Area Network (SAN).  All common network protocols like NFS, SMB/CIFS, HTTP/WebDAV, FTP and iSCSI (initiator and target) has been supported by Openfiler. It is a free software, licensed under the GNU GPL v2.

iSCSI is an acronym for Internet Small Computer Systems Interface. iSCSI is an IP-based storage networking standard for linking data storage facilities. By carrying SCSI commands over IP networks, iSCSI is used to facilitate data transfers over intranets and to manage storage over long distances. iSCSI can be used to transmit data over Local Area Networks (LAN), Wide Area Networks (WAN), or the Internet and can enable location-independent data storage and retrieval.

The iSCSI  protocol allows clients (called Initiators) to send iSCSI commands to iSCSI storage devices (called Targets) on remote servers. It is a Storage Area Network (SAN) protocol, allowing organizations to consolidate storage into data center storage arrays while providing hosts with the illusion of locally attached disks. Unlike traditional Fibre Channel, which usually requires dedicated cabling, iSCSI can be run over long distances using existing network infrastructure.

Although, Openfiler is a good choice for test environments, but it isn’t resilient enough, for use in production environments, as compare to hardware storage arrays. Hardware storages are quite expensive, however there are a few medium size storage arrays are available in market that are good for small size institutions, one of them is Synology 2 bay NAS DiskStation DS218+ (Diskless).

In this article, we will configure an iSCSI Target using Openfiler and then mount it on a iSCSI Initiator (CentOS) server.

 

System Specification:

Here, we will use the same virtual machine that we have configured during our previous post Installation of Openfiler Appliance.

CPU: 3.4 Ghz (1 core)
Memory: 1 GB
Storage: 80 GB

 

Configuring iScsi Target using OpenFiler:

Openfiler automatically configures a Web Administration GUI during installation and it is running on port 446.

Open Web Administration GUI in your browser to access the Openfiler Admin Console. Browser may display a security warning, because the Openfiler Web UI uses HTTPS protocol and presenting a self-signed SSL certificate. It doesn’t matter, just add this URL to browser’s exception list and continue.

openfiler-web-ui-login-01

Login as openfiler administrator user i.e. openfiler, default password is password. The password can easily be changed using passwd command via Linux shell.

openfiler-web-ui-system-info-01openfiler-web-ui-system-info-02

To check the available storage, click on Volumes in top navigation bar.

openfiler-web-ui-volumes-01

Click on Block Devices in the right sidebar.

openfiler-web-ui-block-devices-01

Click on /dev/sda at edit disk column.

openfiler-web-ui-edit-disk-01

You can see that the 88% storage is free in device /dev/sda. So, we can utilize it for our iScsi Target.

First of all we need to create a Physical Volume

To do this, scroll down to Create a partition in /dev/sda section and add a Physical Volume as follows.

openfiler-web-ui-edit-disk-02

By default, it gives you the maximum cylinders to be used by new volume, but you can change it according to your need.

Click on Create.

openfiler-web-ui-edit-disk-03

Once the Physical Volume is created, it will be displayed in the above partitions list. In my case, it is added as /dev/sda4.

Now, its time to add a Volume Group. To do this, click on Volume Group on the right sidebar.

openfiler-web-ui-volumes-02

Provide a VG (Volume Group) Name, select a PV (Physical Volume) and click on Add volume group.

openfiler-web-ui-volumes-03

Click on Add Volume to Add a Logical Volume.

openfiler-web-ui-volumes-04

Add a Logical Volume as follows:

openfiler-web-ui-volumes-05

Click on Create to add a Logical Volume.

openfiler-web-ui-volumes-06

Now add network access configuration. To do this click on the System at the top navigation bar, and add a network access configuration as follows:

openfiler-web-ui-system-01

Enable the iScsi Target, it is available at the Services page.

openfiler-web-ui-services-01

Finally, go to the Volumes page and add an iScsi Target. Click on iScsi Targets at the right sidebar.

openfiler-web-ui-volumes-07

Click on Add to add an iSCSI Target. Once added, click on LUN Mapping.

openfiler-web-ui-volumes-08

Go on with the default settings and click on Map.

Click on the Network ACL, and allow the Network Access Configuration that we have created above.

openfiler-web-ui-volumes-09

Click on update.

Our iScsi Target has been configured successfully.

 

Configuring iScsi Initiator on CentOS:

Connect to another CentOS machine and configure it as iScsi Initiator.

To configure this machine as iSCSI Initiator, we require commands provided in iscsi-initiator-utils package. Therefore, install it using yum command.

[root@appserver ~]# yum install iscsi-initiator-utils
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: centos-hcm.viettelidc.com.vn
* extras: centos-hn.viettelidc.com.vn
* updates: centos.excellmedia.net
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package iscsi-initiator-utils.x86_64 0:6.2.0.873-14.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=============================================================================================================================================================
Package                                       Arch                           Version                                     Repository                    Size
=============================================================================================================================================================
Installing:
iscsi-initiator-utils                         x86_64                         6.2.0.873-14.el6                            base                         723 k
Transaction Summary
=============================================================================================================================================================
Install       1 Package(s)
Total download size: 723 k
Installed size: 2.4 M
Is this ok [y/N]: y
Downloading Packages:
iscsi-initiator-utils-6.2.0.873-14.el6.x86_64.rpm                                                                                     | 723 kB     00:30
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : iscsi-initiator-utils-6.2.0.873-14.el6.x86_64                                                                                             1/1
  Verifying  : iscsi-initiator-utils-6.2.0.873-14.el6.x86_64                                                                                             1/1
Installed:
  iscsi-initiator-utils.x86_64 0:6.2.0.873-14.el6
Complete!
[root@appserver ~]#

Discover iSCSI Target using  iscsiadm command.

[root@appserver ~]# iscsiadm --mode discovery --op update --type sendtargets --portal 192.168.79.131
Starting iscsid:                                           [  OK  ]
192.168.79.131:3260,1 iqn.2006-01.com.openfiler:tsn.83f292b7b1f4
[root@appserver ~]#

Logging into iScsi Target using iscsiadm command.

[root@appserver ~]# iscsiadm -m node --targetname "iqn.2006-01.com.openfiler:tsn.83f292b7b1f4" --portal "192.168.79.131:3260" --login
Logging in to [iface: default, target: iqn.2006-01.com.openfiler:tsn.83f292b7b1f4, portal: 192.168.79.131,3260] (multiple)
Login to [iface: default, target: iqn.2006-01.com.openfiler:tsn.83f292b7b1f4, portal: 192.168.79.131,3260] successful.
[root@appserver ~]#

Use the fdisk to check that the available disks.

[root@appserver ~]# fdisk -l
Disk /dev/sda: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 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: 0x000b6ed9
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64        6528    51915776   8e  Linux LVM
Disk /dev/mapper/vg_appserver-lv_root: 49.0 GB, 48964304896 bytes
255 heads, 63 sectors/track, 5952 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: 0x00000000
Disk /dev/mapper/vg_appserver-lv_swap: 4194 MB, 4194304000 bytes
255 heads, 63 sectors/track, 509 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: 0x00000000
Disk /dev/sdb: 71.7 GB, 71705821184 bytes
255 heads, 63 sectors/track, 8717 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: 0x00000000
[root@appserver ~]#

You can notice the /dev/sdb is available now as a directly attached storage.

Use fdisk to create partitions on /dev/sdb.

[root@appserver ~]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x9b081c36.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').
Command (m for help): m
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)
Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-8717, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-8717, default 8717):
Using default value 8717
Command (m for help): p
Disk /dev/sdb: 71.7 GB, 71705821184 bytes
255 heads, 63 sectors/track, 8717 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: 0x9b081c36
   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        8717    70019271   83  Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.

Create filesystem on partition /dev/sdb1 using mke2fs command.

[root@appserver ~]# mke2fs /dev/sdb1
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
4382720 inodes, 17504817 blocks
875240 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
535 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000, 7962624, 11239424
Writing inode tables: done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 20 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

Mount the partition /dev/sdb1 to /u01 using mount command.

[root@appserver ~]# mkdir /u01
[root@appserver ~]# mount /dev/sdb1 /u01

Our iSCSI partition has been mounted and ready to use.

We have successfully configured an iSCSI Target and iSCSI Initiator using Openfiler on CentOS.

Openfiler: Configure iScsi Target & Initiator on CentOS


YOU MIGHT ALSO LIKE:

No comments:

Post a Comment