利用 Openfiler 构建云端虚拟存储实验笔记

───────────────────────────
利用 Openfiler 构建云端虚拟存储
───────────────────────────
简介: 本文将介绍一种目前流行的存储虚拟化开源软件Openfiler。

Openfiler 是一个定制化的操作系统(以前是基于CentOS构建,现在基于rPath Linux版本),它提供了基于文件的 网络附加存储 NAS(Network-Attached Storage) 和基于块(Block)的存储区域网络 SAN (Storage Area Network)存储解决方案。

Openfiler所提供的强大的虚拟存储功能特性(通过iSCSI Target软件虚拟出iSCSI存储设备),使其在以动态,灵活,可伸缩为特质的云计算环境中,成为一个非常有力的云端存储解决方案。它也可作为实验环境下的一种高效存储模拟解决方案,具有很高的成本节约优势和实用价值。在生产环境中,它大大的降低了花费在网络存储硬件设备上的部署和维护成本。

本文将通过一个基于Openfiler的虚拟镜像创建和配置实例,一步步的引导读者创建基于自己云端环境需求的自定制虚拟存储解决方案。

参考:http://www.openfiler.com/products
───────────────────────────
Protocol Rich:
───────────────────────────
With a range of file-based and block-based storage export protocols, there is
something in Openfiler for everyone. Openfiler provides both block-level and
file-level storage networking capabilities.

Openfiler是一个定制化的操作系统,它是一个基于Web方式进行存储管理的网络存储操作系统。
Openfiler 在单一框架中提供了基于文件的网络附加存储(Network-Attached Storage)和基于块的存储区域网络(Storage Area Network)存储解决方案。

Openfiler 是基于 rPath Linux 的分发,它是由 GNU General Public License version 2
进行授权的一种自由软件。同时,它的软件接口是基于使用开放源码的第三方软件(例如Apache、Samba、LVM2、ext3、Linux NFS 和 iSCSI Enterprise Target 等等)。Openfiler通过将这些开源技术整合到一个统一的架构体系架构中,以一个基于 Web 方式的功能强大的管理界面来提供虚拟存储功能。

Openfiler的强大之处在于其提供了对多种网络协议的支持,并通过统一标准的接口,使基于各种网络文件系统协议的共享资源分配变得更容易、快捷与高效。这些网络协议包括:

At the block-level, storage can be exported via:
  * iSCSI
  * Fibre Channel

At the file-level, Openfiler supports:
  * NFS
  * CIFS
  * HTTP/DAV
  * FTP
  * rsync

对于网络目录的支持,Openfiler 包括了:
 NIS,Active Directory,LDAP,基于 Windows NT 的域控制器和 Hesiod;

对于认证协议的支持,它支持 Kerberos 5 的认证协议;

对于分区技术的支持, Openfiler 支持:
  * 基于卷的分区技术,如本地文件系统的 ext3、XFS 和 JFS 格式,
  * 实时快照
  * 相应的磁盘配额管理。

操作系统架构,Openfiler 支持 x86 和 x86-64

虚拟机监控器它支持:
  * Citrix 的 XenServer
  * VMware 的 ESX,
  * QEMU,
  * Virtual Iron
  * Parallels
    等等

───────────────────────────
存储虚拟化概述
───────────────────────────

存储虚拟化 (Storage Virtualization),简单来说就是通过对底层的存储硬件资源进行抽象化,而展现出来的一种逻辑表现。它通过将实体存储空间(例如硬盘)进行逻辑的分隔,组成不同的逻辑存储空间。它通过一个逻辑存储实体代表底层复杂的物理驱动器,屏蔽掉了单个存储设备的容量、速度等物理特性,而且也屏蔽了底层驱动器的复杂性以及存储系统后端拓扑结构的多样性,从而很大的增强了数据的存储能力,可恢复性和性能表现。

通过存储虚拟化技术,对服务器和应用程序来说,无论后端的物理存储是什么,面对它们的是存储设备的逻辑映像;对于用户来说,他们所面对的是一种物理磁盘的抽象,他们与存储资源中大量的物理特性隔离开来。用户不必去关心实际的后端存储,只需要去专注于管理存储空间本身,用户所看到的逻辑存储单元和本地的硬盘没有什么差别。

因此,存储虚拟化技术与传统技术相比,它具有更少的运营费用和更低的复杂性。它简化了物理存储设备的配置和管理任务,同时还能够充分利用现有的物理存储资源,避免了存储资源的浪费。

───────────────────────────
Install openfiler
───────────────────────────

下载ISO档案,按照普通Linux一样安装即可  ...  安装步骤在此省略  ...

───────────────────────────
配置系统安全访问控制列表
───────────────────────────
https://192.168.0.2:446
Username: openfiler
Password: *********

在系统菜单“System”菜单下,可以检查当前系统的 IP 等网络信息设置情况。
如果想重新设置网络信息,可以点击“Configure”功能连接对系统网络进行重新配置。

在系统菜单“System”菜单下的“Network Access Configuration”区域,
配置允许访问 Openfiler 系统的安全访问控制列表。

值得注意的是只有加入到 Openfiler 的网络访问控制列表中的网络或者主机地址,才允许访问 Openfiler 系统所提供的虚拟存储服务。
在网络访问控制列表中,既可以配置网段地址也可以配置单个主机地址。
在本例填入 192.168.130.0 网段,设置类型为“Share”方式,
添加完成后点击“Update”完成系统配置更新。

Network Access Configuration:
--------------------------------------------------------------------------------
NameNetwork/HostNetmaskType
VMServers192.168.57.0255.255.255.0Share
--------------------------------------------------------------------------------

然后点击"Volumes"->"iSCSI Targets"->“Network ACL”标签,
将访问控制从默认禁止访问更新为允许访问“Allow”,
最后点击“Update”选项更新系统配置。

───────────────────────────
配置系统磁盘
───────────────────────────
当配置好系统和安全访问控制后,接下来的一步是配置系统磁盘,实现虚拟存储服务。

在 Openfiler 中,有三类存储概念:

  * Block Device表示的是实际的物理磁盘
  * Physical Volume 表示的是物理磁盘的分区,是组成 Volume Group 的单元
  * Volume Group由一个或多个PhysicalVolume组成,它又是组成LogicalVolume的单元


首先点击菜单“Volumes”标签,在右侧的“Volumes section”区域选择“Block Devices”,然后系统会显示当前所挂载的硬盘信息。然后点击磁盘“/dev/sda”,系统会显示当前磁盘的详细分区信息。

创建一个新的分区。首先在“Create a partition in /dev/sda”处设置“Partition Type”
属性的值为“Physical volume”,在“Ending cylinder”属性处选择默认值,从而设置当前所有的剩余空间划为一个分区,最后点击“Create”选项。

接着在右侧的“Volumes section”区域选择“Volume Groups”来创建一个卷组。
在区域“Create a new volume group”处填写卷组 volume group 的名称为“volume_group_iscsi”,同时勾选刚刚在上一步所创建的物理卷 /dev/sda4,最后点击“Add volume group”。

接下来在右侧的“Volumes section”区域选择“Add Volume”选项,在刚刚创建好的卷组“volume_group_iscsi”中新创建一个 iSCSI 卷。
注意在属性“Filesystem / Volume type”中设置属性值为“iSCSI”。
右侧的“Volumes section”区域选择“Manage Volumes”,可以看到刚刚创建的iSCSI卷信息。

───────────────────────────
Check LVM status
───────────────────────────
# /bin/ls -l /dev/vg_iscsi/
lrwxrwxrwx  1 root root 24 Aug 26 15:38 lv1 -> /dev/mapper/vg_iscsi-lv1


# /bin/ls -l /dev/mapper/
--------------------------------------------------------------------------------
crw-rw----  1 root root  10, 60 Aug 26 15:29 control
brw-------  1 root root 253,  0 Aug 26 15:38 vg_iscsi-lv1
--------------------------------------------------------------------------------


# /sbin/vgscan
--------------------------------------------------------------------------------
  Reading all physical volumes.  This may take a while...
  Found volume group "vg_iscsi" using metadata type lvm2
--------------------------------------------------------------------------------


# /usr/sbin/lvscan
--------------------------------------------------------------------------------
  ACTIVE            '/dev/vg_iscsi/lv1' [32.00 MB] inherit
--------------------------------------------------------------------------------


# /sbin/pvscan
--------------------------------------------------------------------------------
  PV /dev/hdb1   VG vg_iscsi        lvm2 [480.00 MB / 448.00 MB free]
  PV /dev/hdc1                      lvm2 [510.86 MB]
  PV /dev/hdd1                      lvm2 [510.86 MB]
  Total: 3 [1.47 GB] / in use: 1 [480.00 MB] / in no VG: 2 [1021.72 MB]
--------------------------------------------------------------------------------

 


────────────────────────────────────────────────────────────────────────────────
开启“iSCSI target server”系统服务
─��──────────────────────────────────────────────────────────────────────────────
当 iSCSI 卷创建完成后,接下来是开启“iSCSI target server”系统服务。
点击“Services”菜单,在右侧的“Services section”区域选择“Manage Services”。
然后将系统服务列表中的“iSCSI target server”设置为“Enabled”状态,
从而使得系统能够对外提供基于 iSCSI 协议的虚拟存储服务。


# netstat -nltu | egrep '3260|860'
--------------------------------------------------------------------------------
tcp        0      0 0.0.0.0:3260            0.0.0.0:*               LISTEN    
tcp        0      0 :::3260                 :::*                    LISTEN  
--------------------------------------------------------------------------------
Note: waiting 1 minute, the iSCSI target service will start automatically.


# lsof -P -n | grep 3260
--------------------------------------------------------------------------------
ietd      4656      root    8u     IPv6      17294                TCP *:3260 (LISTEN)
ietd      4656      root    9u     IPv4      17295                TCP *:3260 (LISTEN)
--------------------------------------------------------------------------------


# /etc/init.d/iscsi-target status
# /etc/init.d/iscsi-scst status


# cat /etc/iscsi/iscsid.conf  | grep -v ^# | grep .
--------------------------------------------------------------------------------
node.startup = manual
node.session.timeo.replacement_timeout = 120
node.conn[0].timeo.login_timeout = 15
node.conn[0].timeo.logout_timeout = 15
node.conn[0].timeo.noop_out_interval = 5
node.conn[0].timeo.noop_out_timeout = 5
node.session.err_timeo.abort_timeout = 15
node.session.err_timeo.lu_reset_timeout = 20
node.session.initial_login_retry_max = 8
node.session.cmds_max = 128
node.session.queue_depth = 32
node.session.xmit_thread_priority = -20
node.session.iscsi.InitialR2T = No
node.session.iscsi.ImmediateData = Yes
node.session.iscsi.FirstBurstLength = 262144
node.session.iscsi.MaxBurstLength = 16776192
node.conn[0].iscsi.MaxRecvDataSegmentLength = 262144
discovery.sendtargets.iscsi.MaxRecvDataSegmentLength = 32768
node.session.iscsi.FastAbort = Yes
--------------------------------------------------------------------------------

 

# cat /etc/iscsi/iscsid.conf  | grep -v ^# | grep .
--------------------------------------------------------------------------------
node.startup = manual
node.session.timeo.replacement_timeout = 120
node.conn[0].timeo.login_timeout = 15
node.conn[0].timeo.logout_timeout = 15
node.conn[0].timeo.noop_out_interval = 5
node.conn[0].timeo.noop_out_timeout = 5
node.session.err_timeo.abort_timeout = 15
node.session.err_timeo.lu_reset_timeout = 20
node.session.initial_login_retry_max = 8
node.session.cmds_max = 128
node.session.queue_depth = 32
node.session.xmit_thread_priority = -20
node.session.iscsi.InitialR2T = No
node.session.iscsi.ImmediateData = Yes
node.session.iscsi.FirstBurstLength = 262144
node.session.iscsi.MaxBurstLength = 16776192
node.conn[0].iscsi.MaxRecvDataSegmentLength = 262144
discovery.sendtargets.iscsi.MaxRecvDataSegmentLength = 32768
node.session.iscsi.FastAbort = Yes
--------------------------------------------------------------------------------

# cat /etc/iscsi/initiatorname.iscsi;
--------------------------------------------------------------------------------
InitiatorName=iqn.2005-03.org.open-iscsi:7c21b14b9988
--------------------------------------------------------------------------------

───────────────────────────
接下来是添加一个 iSCSI Target
───────────────────────────
首先点击菜单“Volumes”,然后在右侧的“Volumes section”区域中选择“iSCSI Targets”。
在“Target Configuration”子菜单中的“Add new iSCSI Target”区域,选择列出的“Target IQN”。
最后点击“Add”按钮,从而添加了一个 iSCSI Target。

Target IQN:
iqn.2006-01.com.openfiler:tsn.00d44b84d657
注意,此处的 Target IQN 信息在后面的对 ESX 服务器的存储配置过程中会用到。


接下来点击“LUN Mapping”子菜单,保持其余默认选项,点击“Map”选项。
从而实现从 LUN 到刚刚配置好的 iSCSI Target 之间的映射。

LUNs mapped to target: iqn.2006-01.com.openfiler:tsn.00d44b84d657
--------------------------------------------------------------------------------
LUN Id.LUN Path  R/W Mode   SCSI Serial No.  SCSI Id.       Transfer Mode
0/dev/vg_iscsi/lv1 write-thru 7psMt4-KrmM-E2d8 7psMt4-KrmM-E2d8 blockio
--------------------------------------------------------------------------------

至此为止,在 Openfiler 系统上对 iSCSI 虚拟存储的配置过程完毕。

───────────────────────────
Install iscsi-initiator-utils on cluster's node servers
───────────────────────────
我将在实验用的Virtualbox虚拟主机中使用Openfiler所提供的iSCSI虚拟云端存储配置
Virtualbox VM Guest:
OS: CentOS6
IP: 192.168.57.101

# yum install iscsi-initiator-utils ;

# cat /proc/partitions;
# iscsiadm -m discovery -t sendtargets -p 192.168.0.2
--------------------------------------------------------------------------------
正在启动 iscsid:                                          [确定]
192.168.0.2:3260,1 iqn.2006-01.com.openfiler:tsn.00d44b84d657
192.168.0.100:3260,1 iqn.2006-01.com.openfiler:tsn.00d44b84d657
--------------------------------------------------------------------------------
# cat /proc/partitions;
# iscsiadm -m node --login;
# cat /proc/partitions;#Note: after login, the device will show in /dev/sd*;
# fdisk -l /dev/sdc;
# iscsiadm -m node -o show;
# iscsiadm -m node -o show --targetname iqn.2006-01.com.openfiler:tsn.00d44b84d657

# chkconfig iscsi on;
# chkconfig iscsid on;
# service iscsid restart;
# service iscsi restart;
# /etc/init.d/iscsi status;
# cat /proc/partitions;

After connect to iSCSI target successfully, check https://openfiler-server:446/
Status -> iSCSI Targets => Open sessions for iSCSI target iqn.xxxx-xx.xxx...
You will see the current active connections on this page.