Openfiler 安装+iSCSI配置

简介: Openfiler是一款非常好的存储管理操作系统,开源免费,通过web界面对存储磁盘的管理,支持现在流行的网络存储技术IP-SAN和NAS,支持iSCSI、NFS、SMB/CIFS及FTP等协议。

Openfiler是一款非常好的存储管理操作系统,开源免费,通过web界面对存储磁盘的管理,支持现在流行的网络存储技术IP-SAN和NAS,支持iSCSI、NFS、SMB/CIFS及FTP等协议。

Openfiler能把标准x86/64架构的系统变成一个强大的NAS、SAN存储和IP存储网关,为管理员提供一个强大的管理平台,并能能应付未来的存储需求。依赖如VMware,Virtual Iron和Xen服务器虚拟化技术,Openfiler也可部署为一个虚拟机实例。

  Openfiler这种灵活高效的部署方式,确保存储管理员能够在一个或多个网络存储环境下使系统的性能和存储资源得到最佳的利用和分配。

Openfiler的主要性能和优点:


  ● 可靠性---Openfiler可以支持软件和硬件的RAID,能监测和预警,并且可以做卷的快照和快速恢复。

  ● 高可用性--Openfiler支持主动或被动的高可用性集群、多路径存储(MPIO)、块级别的复制。

  ● 性能--及时更新的Linux内核支持最新的CPU、网络和存储硬件。

  ● 可伸缩性---文件系统可扩展性最高可超出60TB,并能使文件系统大小可以在线的增长。


免费的存储服务器软件有FreeNAS 和 Openfiler。 其中Freenas的网站上只有i386及amd64的版本,也就是说Freenas不能支持64位版本的Intel CPU,而Openfiler则提供更全面的版本支持,在其网站上可以看到支持多网卡、多CPU,以及硬件Raid的支持,还有10Gb网卡的支持。

 

Freenas 官网地址:http://freenas.org/doku.php

       Openfiler 官网:http://www.openfiler.com/

 

 

Openfiler是在rPath Linux基础上开发的,它能够作为一个独立的Linux操作系统发行。Openfiler是一款非常好的存储管理操作系统,开源免费,通过web界面对存储磁盘的管理,支持现在流行的网络存储技术IP-SAN和NAS,支持iSCSI(Internet Small Computer System Interface, 学名ISCSI HBA)、NFS、SMB/CIFS及FTP等协议。

Openfiler版本: Openfiler NSA (x86_64) , version 2.3


我们可以从openfiler官网上下载此版本的安装镜像安装一个openfile操作系统,安装步骤参照:

http://download.csdn.net/detail/changyanmanman/6237653


不过现在很好的是,openfiler官网是直接提供了虚拟机文件,下载下来那个文件,可以直接用vmware workstation打开,自己连安装都省了。。。。


Openfiler在安装完成后,不需要在控制台操作,所有对Openfiler的控制都可以远程使用Web界面进行管理。https://IP:446就是默认的web登陆地址。Openfiler的默认用户名为openfiler,密码为password 登陆成功后显示如下:


二.存储端(target)配置


Openfiler 的配置,可以参考Oracle 的这遍文档:

       http://www.oracle.com/technology/global/cn/pub/articles/hunter_rac10gr2_iscsi.html#9

 

http://www.oracle.com/technetwork/cn/articles/hunter-rac11gr2-iscsi-083834-zhs.html#11

 

2.1 启动iscsi target服务

       在Service 里面启动iscsi target。 启动之后,下次重启会自动启该服务。

   

 

 

2.2 配置iscsi initiator访问IP

       只有配置了IP 才有权限访问openfiler 存储。在system 选项的最下面有配置选项,把IP 写上即可。 注意这里的子网掩码,写的是255.255.255.255

 

  



2.3、建立物理分区 Physical volume


现在我们来配置共享设备。 先对我们没有格式的分区格式化成扩展分区,一定要扩展分区

 

[root@san ~]# fdisk /dev/sda

The number of cylinders for this disk is set to 5221.

There is nothing wrong with that, but this is larger than 1024,

and could in certain setups cause problems with:

1) software that runs at boot time (e.g., old versions of LILO)

2) booting and partitioning software from other OSs

   (e.g., DOS FDISK, OS/2 FDISK)

 

Command (m for help): n

Command action

   e   extended

   p   primary partition (1-4)

e

Partition number (1-4): 3

First cylinder (383-5221, default 383):

Using default value 383

Last cylinder or +size or +sizeM or +sizeK (383-5221, default 5221):

Using default value 5221

 

Command (m for help): w

The partition table has been altered!

 

Calling ioctl() to re-read partition table.

 

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.

The kernel still uses the old table.

The new table will be used at the next reboot.

Syncing disks.

[root@san ~]# fdisk -l

 

Disk /dev/sda: 42.9 GB, 42949672960 bytes

255 heads, 63 sectors/track, 5221 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1         255     2048256   83  Linux

/dev/sda2             256         382     1020127+  82  Linux swap / Solaris

/dev/sda3             383        5221    38869267+   5  Extended

 


1、依次点击主菜单Volumes,右侧菜单Block Devices,点击磁盘/dev/hda



2、新页面中,选择分区类型为扩展分区Extended partition,点击Create按钮,创建该扩展分区。

注:此处根据需要,也可以选择分区类型为物理分区Physical volume,这样整个磁盘建立一个卷组,在一个卷组上建立多个逻辑卷。

 

扩展分区被创建,见下图

3、建立物理分区 Physical volume

在Create a partition in /dev/had中,选择分区类型为物理分区Physical volume,第一个分区大小为20GB,Ending cylinder处输入51300,点击Create。

用上面方法,用剩余磁盘空间创建第二个分区,创建后磁盘分区见下图。



2.4  在物理分区上创建逻辑卷组

格式化之后,我们在openfiler的网页中就能看到这个磁盘信息,如果不格式化,或者格式化错误,是无法编辑的。

 

   

页面网下拉,我们能看到创建分区:

 

 

    

把所有空间全部创建成一个分区。 之后窗口会显示:

 

   


2.5  在物理分区上创建逻辑卷组

 选择volume Groups。

  

 

然后输入vg名称和对应的设备,确定即可。

 

  

至此,我们已经创建完成了一个叫san的卷组。 但是我们在环境中使用的是卷。 所以我们还需要在这个卷组里创建它的卷。

 


2.6  在卷组上创建逻辑卷

点击旁边的add volume选项:

 

   

在这个页面往下拉,我们可以看到创建卷的选项:

在Create a volume in "san"表中,Volume Name处输入卷名称,Required Space (MB)处输入卷大小,卷大小根据需要设置,本例中约为20GB,Filesystem / Volume type处选择iSCSI,点击Create按钮,创建该卷。

   

这里我把所有的空间都创建到一个逻辑卷里。

  

 


2.7  创建  iscsi target

逻辑卷创建完成以后,我们需要创建一个iscsi target, 然后把逻辑卷和这个target 映射起来,这样就可以通过这个target 与服务器进行连接。  点机iSCSI Target,创建Target IQN:

  

点击Target Configuration,点击Add按钮,添加一个新的iSCSI Target



添加以后,见下图:




选择LUN Mapping, 将ISCSI 和 逻辑卷对应起来

  



         配置能够访问逻辑卷的Network ACL 权限,这个ip 是在system 的选项里设置的。 这个之前已经配置过。 这里可以设置多个IP, 可以控制哪个IP 允许访问哪个逻辑卷。从而可以多个用户同时使用存储而互不影响。注意子网掩码,我设置过255.255.255.0,测试,但是从131或者132上尝试访问,都不可以。

 

  

 

至此, 存储的服务端已经配置完成。 在这一步,我们创建了一个逻辑卷然后与ISCSI target 进行了对应。 客户端的服务器就通过这个ISCSI target 进行连接。

Openfiler target的配置文件是: /etc/ietd.conf。

 

在openfiler这台机器上,查看此设置:

[root@store ~]# cat /etc/ietd.conf 
#####   WARNING!!! - This configuration file generated by Openfiler. DO NOT MANUALLY EDIT.  #####  
 
Target liutarget.2006-01.com
HeaderDigest None
DataDigest None
MaxConnections 1
InitialR2T Yes
ImmediateData No
MaxRecvDataSegmentLength 131072
MaxXmitDataSegmentLength 131072
MaxBurstLength 262144
FirstBurstLength 262144
DefaultTime2Wait 2
DefaultTime2Retain 20
MaxOutstandingR2T 8
DataPDUInOrder Yes
DataSequenceInOrder Yes
ErrorRecoveryLevel 0
Lun 0 Path=/dev/vg01/volume01,Type=blockio,ScsiSN=WjguST-l7Aj-ZYrI,ScsiId=WjguST-l7Aj-ZYrI,IOMode=wt

重启iscsi-target 服务:

#service iscsi-target restart




三.服务器端(initiator配置

           iSCSI 客户端可以是提供 iSCSI 支持(驱动程序)的任何系统(Linux、Unix、MS Windows、Apple Mac 等)。

 

 

3.1安装 iSCSI(启动器)服务

           这个安装包在系统的安装包里。 找到iscsi-initiator-utils-6.2.0.871-0.10.el5.x86_64.rpm包。 安装上。

 

[root@centos ~]# rpm -Uvh iscsi-initiator-utils-6.2.0.871-0.10.el5.x86_64.rpm

warning: iscsi-initiator-utils-6.2.0.871-0.10.el5.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID e8562897

Preparing...                ########################################### [100%]

   1:iscsi-initiator-utils  ########################################### [100%]

[root@centos ~]# rpm -qa | grep iscsi-initiator-utils

iscsi-initiator-utils-6.2.0.871-0.10.el5

 

 

3.2  配置 iSCSI(启动器)服务

       刚才已经安装了initiator 包。 现在我们来启动initiator 服务(iscsid),并使其在系统引导时自动启动。在配置 iscsi 服务自动启动,使其在系统启动时自动登录 iSCSI 目标。

 

[root@centos ~]# service iscsid start

[  OK  ]off network shutdown. Starting iSCSI daemon: [  OK  ]

[  OK  ]

[root@centos ~]# chkconfig iscsid on

[root@centos ~]# chkconfig iscsi on

 

 

iscsiadm命令检查网络存储服务器上的所有可用目标:

必须确保system—Network Access Configuration中添加了此服务器的ip;Volume——iSCSI Targets--network ACL中此服务器是允许访问的:


 

[root@rac2 ~]#  iscsiadm -m discovery -t sendtargets -p 192.168.15.138
192.168.15.138:3260,1 liutarget.2006-01.com


手动登录 iSCSI 目标
[root@rac2 ~]# iscsiadm -m node -T liutarget.2006-01.com -p 192.168.15.138 -l
Logging in to [iface: default, target: liutarget.2006-01.com, portal: 192.168.15.138,3260]
iscsiadm: Could not login to [iface: default, target: liutarget.2006-01.com, portal: 192.168.15.138,3260]: 
iscsiadm: initiator reported error (15 - already exists)

以上报错  initiator reported error (15 - already exists)  是说initiator已经建立了一个到target的连接,如果想再连接,你必须断开之前的那个连接,断开语法如下:

iscsiadm -m node -T [target-name] -p [ip-address] -u

[root@rac2 ~]# iscsiadm -m node -T liutarget.2006-01.com -p 192.168.15.138 -u

Logging out of session [sid: 1, target: liutarget.2006-01.com, portal: 192.168.15.138,3260]
Logout of [sid: 1, target: liutarget.2006-01.com, portal: 192.168.15.138,3260]: successful

再次尝试手动登陆:

[root@rac2 ~]# iscsiadm -m node -T liutarget.2006-01.com -p 192.168.15.138 -l
Logging in to [iface: default, target: liutarget.2006-01.com, portal: 192.168.15.138,3260]
Login to [iface: default, target: liutarget.2006-01.com, portal: 192.168.15.138,3260]: successful

配置自动登录

在计算机引导(或 iSCSI 启动器服务启动/重新启动)时,客户端将自动登录上面列出的每个目标。和上面描述的手动登录过程一样,不过在这里加了2个参数。

[root@centos ~]# iscsiadm -m node -Tliutarget.2006-01.com -p 192.168.15.138 --op update -n node.startup -v automatic


3.3 创建永久性本地 SCSI设备名称

 

查看/dev/disk/by-path文件,来确定文件被映射到了哪个文件上:

[root@rac2 ~]# ls /dev/disk/by-path/ -al
total 0
drwxr-xr-x 2 root root 340 Mar 13 10:18 .
drwxr-xr-x 6 root root 120 Mar 12 15:25 ..
lrwxrwxrwx 1 root root   9 Mar 13 10:18 ip-192.168.15.138:3260-iscsi-liutarget.2006-01.com-lun-0 -> ../../sdc
lrwxrwxrwx 1 root root   9 Mar 12 15:25 pci-0000:00:07.1-ide-0:0 -> ../../hdc
lrwxrwxrwx 1 root root   9 Mar 12 15:25 pci-0000:00:10.0-scsi-0:0:0:0 -> ../../sda
lrwxrwxrwx 1 root root  10 Mar 12 15:25 pci-0000:00:10.0-scsi-0:0:0:0-part1 -> ../../sda1
lrwxrwxrwx 1 root root  10 Mar 12 15:25 pci-0000:00:10.0-scsi-0:0:0:0-part2 -> ../../sda2
lrwxrwxrwx 1 root root  10 Mar 12 15:25 pci-0000:00:10.0-scsi-0:0:0:0-part3 -> ../../sda3
lrwxrwxrwx 1 root root   9 Mar 12 15:25 pci-0000:02:06.0-scsi-0:0:0:0 -> ../../sdb
lrwxrwxrwx 1 root root  10 Mar 12 15:25 pci-0000:02:06.0-scsi-0:0:0:0-part1 -> ../../sdb1
lrwxrwxrwx 1 root root  10 Mar 12 15:25 pci-0000:02:06.0-scsi-0:0:0:0-part2 -> ../../sdb2
lrwxrwxrwx 1 root root  10 Mar 12 15:25 pci-0000:02:06.0-scsi-0:0:0:0-part3 -> ../../sdb3
lrwxrwxrwx 1 root root  10 Mar 12 15:25 pci-0000:02:06.0-scsi-0:0:0:0-part4 -> ../../sdb4
lrwxrwxrwx 1 root root  10 Mar 12 15:25 pci-0000:02:06.0-scsi-0:0:0:0-part5 -> ../../sdb5
lrwxrwxrwx 1 root root  10 Mar 12 15:25 pci-0000:02:06.0-scsi-0:0:0:0-part6 -> ../../sdb6
lrwxrwxrwx 1 root root  10 Mar 12 15:25 pci-0000:02:06.0-scsi-0:0:0:0-part7 -> ../../sdb7
lrwxrwxrwx 1 root root  10 Mar 12 15:25 pci-0000:02:06.0-scsi-0:0:0:0-part8 -> ../../sdb8

         通过上面,我们可以看到这个文件被挂到了sdc下。 但是每次重新引导服务器时,该映射都可能有所不同。它是自动登录到以随机方式配置的每个目标,并将这些目标映射到下一个可用的本地 SCSI 设备名称。 所以对于有个多target的时候,target1现在是/dev/sdc,下一次可能就是/dev/sdd . 因此,如果无法预测重新引导后的 iSCSI 目标映射,依赖于使用本地 SCSI 设备名称是不现实的。

 

在这里,我们就需要使用udev的动态管理工具。udev 提供了一个动态设备目录,使用一组可配置的规则通过符号链接指向实际设备。当 udev 收到设备事件(例如,客户端登录到 iSCSI 目标)时,就会根据 sysfs 中提供的可用设备属性匹配其配置好的规则以便识别设备。匹配规则可以提供其他设备信息或指定设备节点名和多个符号链接名,并指示 udev 运行其他程序(例如,一个 SHELL 脚本)作为设备事件处理过程的一部分。

 

3.3.1. 创建新的规则文件

创建文件 /etc/udev/rules.d/55-openiscsi.rules,它只包含一行用于接收事件的名称-值对。还将定义一个调出 SHELL 脚本 (/etc/udev/scripts/iscsidev.sh),用于处理事件。

 

[root@centos ~]# more /etc/udev/rules.d/55-openiscsi.rules

# /etc/udev/rules.d/55-openiscsi.rules

KERNEL=="sd*", BUS=="scsi", PROGRAM="/etc/udev/scripts/iscsidev.sh %b",SYMLINK+="iscsi/%c"

 

3.3.2. 创建在接收该事件时将调用的 UNIX SHELL脚本

 

1)先在服务器上创建一个目录,用于存储 udev脚本:

[root@centos ~]# mkdir -p /etc/udev/scripts

 

2)在服务器上创建 UNIX shell脚本 /etc/udev/scripts/iscsidev.sh

[root@centos ~]# more /etc/udev/scripts/iscsidev.sh

#!/bin/sh

# FILE: /etc/udev/scripts/iscsidev.sh

BUS=${1}

HOST=${BUS%%:*}

[ -e /sys/class/iscsi_host ] || exit 1

file="/sys/class/iscsi_host/host${HOST}/device/session*/iscsi_session*/targetname"

target_name=$(cat ${file})

# This is not an open-scsi drive

if [ -z "${target_name}" ]; then

   exit 1

fi

echo "${target_name##*.}"

 

说明:我们先看一下这个脚本的作用:

[root@centos]# more /sys/class/iscsi_host/host${HOST}/device/session*/iscsi_session*/targetname   (伪代码)

iqn.2006-01.com.san

 

从这个命令,我们可以看出,这个脚本就是获取target 的名称的。 而规则将根据这个脚本返回的target 名称的最后一个字符串,来在相应的目录的下建立对应的文件。 简单点就是根据target来做一个映射。 因为target 名称是唯一的,所以这个映射名称也是唯一的。 这就避免了映射到不同的系统目录,而到时共享数据不可用。

 

 

3)将刚才创建的shell脚本修改为可执行文件:

# chmod 755 /etc/udev/scripts/iscsidev.sh

 

4)在服务器上重新启动 iSCSI服务:

[root@rac2 ~]# service iscsi stop
Logging out of session [sid: 2, target: liutarget.2006-01.com, portal: 192.168.15.138,3260]
Logout of [sid: 2, target: liutarget.2006-01.com, portal: 192.168.15.138,3260]: successful
Stopping iSCSI daemon: 


[root@rac2 ~]# service iscsi start
iscsid dead but pid file exists
Starting iSCSI daemon:                                     [  OK  ]
                                                           [  OK  ]
Setting up iSCSI targets: Logging in to [iface: default, target: liutarget.2006-01.com, portal: 192.168.15.138,3260]
Login to [iface: default, target: liutarget.2006-01.com, portal: 192.168.15.138,3260]: successful
                                                           [  OK  ]


 

5)验证

 [root@rac2 ~]#  ls -l /dev/iscsi/*
lrwxrwxrwx 1 root root 6 Mar 13 10:42 /dev/iscsi/com -> ../sdc

因为这里我们用udev 配置,它就保证了iscsi目标映射到唯一的设备。 我们在使用的时候使用这个唯一的映射/dev/iscsi/san 即可。

 

 

对客户端这个映射做一个解释。因为开始对这块也有点模糊。

存储的配置只干一件事,就是给我提供一个target。 这个target 是在存储上做的映射。 服务器通过initiator 去连存储。 然后把这个target 映射到自己的下一个可用设备上,如 /dev/sdc。 如果只有一个target. 那么没有任何问题。 每次initiator连上后都会把这个target 映射到/dev/sdc上。 但是如果有多个target, 那么这里就出了问题。 因为initiator的连接是随机的。 可能A先连接,那A就会映射到/dev/sdc上。 如果B先连接,B就会映射到/dev/sdc上。 这就是问题的所在。

 

Udev 的动态管理很好的解决了这个问题。 我们通过脚本加规则的设置,用脚本来获取每个target的名称,然后在规则里用每个target 最后一个字符串,在我们指定的目录创建一个设备。 这样,因为规则是唯一的。 所以每个设备都是唯一的。 我们就可以使用这个唯一的设备,而不会出现问题。 比如实验中的/dev/iscsi/san. 这个就是一个绝对位置。

相关文章
|
1月前
|
存储 运维 Linux
ISCSI详解(五)——ISCSI客户端配置实战
ISCSI详解(五)——ISCSI客户端配置实战
45 5
|
网络协议 数据安全/隐私保护
【OpenFiler】使用虚拟机安装openfiler
【OpenFiler】使用虚拟机安装openfiler
252 0
【OpenFiler】使用虚拟机安装openfiler
|
存储 Linux 数据安全/隐私保护
【Storage】Openfiler存储服务器搭建ISCSI配置及ESXI连接
云小宝木有给我发优惠券,俺买不起服务器做实验啦!!!
1515 0
【Storage】Openfiler存储服务器搭建ISCSI配置及ESXI连接
|
存储 网络协议 开发工具
|
数据安全/隐私保护
|
存储 网络协议 数据安全/隐私保护

热门文章

最新文章