(该日志,为以前“Database Logic”的网站在本地记录的副本,图片链接已经失效,但是并不妨碍对于本文想要描述的问题的理解。)

以下为iSCSI在RHEL 5.4上的配置过程。
需要说明的是我的iSCSI是通过Openfiler分发出来的:
如图:
iscsi1
它对我将要配置RAC的两个节点开放了访问权限:
iscsi2
以上,可以理解为iSCSI“服务器”端的配置了。
下面是“客户端”的配置:
(以其中一个节点的Linux上的配置为例)
首先,需要确定系统已经安装了软件包:iscsi-initiator-utils-6.2.0.871-0.10.el5。
如下:

[root@purplerain1 ~]# rpm -qa | grep iscsi –color
iscsi-initiator-utils-6.2.0.871-0.10.el5
[root@purplerain1 ~]#
如果没有安装,可以配置好YUM之后使用以下命令安装:

[root@purplerain1 ~]# yum install -y iscsi*
Loaded plugins: rhnplugin, security
This system is not registered with RHN.
RHN support will be disabled.
Setting up Install Process
Resolving Dependencies
–> Running transaction check
—> Package iscsi-initiator-utils.i386 0:6.2.0.871-0.10.el5 set to be updated
–> Finished Dependency Resolution

Dependencies Resolved

================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
iscsi-initiator-utils i386 6.2.0.871-0.10.el5 Server 773 k

Transaction Summary
================================================================================
Install 1 Package(s)
Update 0 Package(s)
Remove 0 Package(s)

Total download size: 773 k
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : iscsi-initiator-utils 1/1

Installed:
iscsi-initiator-utils.i386 0:6.2.0.871-0.10.el5

Complete!
[root@purplerain1 ~]#
下面就开始对客户端做出配置了。
首先需要启动两个系统服务:iscsi、iscsid。
如果没有启动这两个服务,在后面的iSCSI发现的时候将会遭遇错误:

[root@purplerain1 ~]# iscsiadm -m discovery -t sendtargets -p openfiler
iscsiadm: can not connect to iSCSI daemon (111)!
iscsiadm: can not connect to iSCSI daemon (111)!
iscsiadm: Cannot perform discovery. Initiatorname required.
iscsiadm: Discovery process to openfiler:3260 failed to create a discovery session.
[root@purplerain1 ~]#
Linux中服务启动的命令如下:

[root@purplerain1 ~]# service iscsi start
iscsid is stopped
Turning off network shutdown. Starting iSCSI daemon: [ OK ] [ OK ] Setting up iSCSI targets: iscsiadm: No records found!
[ OK ] [root@purplerain1 ~]# chkconfig iscsi on
[root@purplerain1 ~]#
[root@purplerain1 ~]# service iscsid start
Turning off network shutdown. Starting iSCSI daemon:
[ OK ] [root@purplerain1 ~]# chkconfig iscsid on
[root@purplerain1 ~]#
[root@purplerain1 ~]# chkconfig –list iscsi
iscsi 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@purplerain1 ~]# chkconfig –list iscsid
iscsid 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@purplerain1 ~]#
然后,再次尝试iSCSI发现:

[root@purplerain1 ~]# iscsiadm -m discovery -t sendtargets -p openfiler
192.168.81.128:3260,1 ora10g
[root@purplerain1 ~]#
这里的“ora10g”正是上面截图中,Openfiler端做出的设定。

再需要将iSCSI发现的设备注册到系统中,注册的命令为:“iscsiadm -m node -T iscsi_名称 -p IP地址 -l”。
操作前,查看下当前的磁盘分布状态:

[root@purplerain1 ~]# fdisk -l

Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 2610 20860402+ 8e Linux LVM
[root@purplerain1 ~]#
Action:

[root@purplerain1 ~]#
[root@purplerain1 ~]# iscsiadm -m node -T ora10g -p openfiler -l
iscsiadm: no records found!
[root@purplerain1 ~]# iscsiadm -m node -T ora10g -p 192.168.81.128 -l
Logging in to [iface: default, target: ora10g, portal: 192.168.81.128,3260] Login to [iface: default, target: ora10g, portal: 192.168.81.128,3260]: successful
[root@purplerain1 ~]#
操作完成后的磁盘分布状态:

[root@purplerain1 ~]# fdisk -l

Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 2610 20860402+ 8e Linux LVM

Disk /dev/sdb: 30.7 GB, 30702305280 bytes
64 heads, 32 sectors/track, 29280 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes

Disk /dev/sdb doesn’t contain a valid partition table
[root@purplerain1 ~]#
这样iSCSI设备就添加完成了。
如果想要开机(系统启动)的时候自动注册,需要执行命令:“iscsiadm -m node -T iscsi_名称 -p IP地址 –op update -n node.startup -v automatic”

关于iSCSI的Name:ora10g,如何被映射成了/dev/sdb:

[root@purplerain1 ~]# cd /dev/disk/by-path
[root@purplerain1 by-path]# ls -l | grep –color ora10g
lrwxrwxrwx 1 root root 9 Apr 15 10:30 ip-192.168.81.128:3260-iscsi-ora10g-lun-0 -> ../../sdb
[root@purplerain1 by-path]#
当本地挂在了多个iSCSI之后,/dev/disk/by-path中的映射关系可能会动态的改变,而有时候需要将它们固定下来,可以使用/dev/udev来实现。
UDEV的配置文件一般位于/dev/udev/rules.d/中。

[root@purplerain1 by-path]# ls /etc/udev/rules.d/
05-udev-early.rules 60-wacom.rules 90-ib.rules
40-multipath.rules 61-uinput-stddev.rules 95-pam-console.rules
50-udev.rules 61-uinput-wacom.rules 98-kexec.rules
51-hotplug.rules 85-pcscd_ccid.rules 99-vmware-scsi-udev.rules
60-net.rules 90-alsa.rules bluetooth.rules
60-pcmcia.rules 90-dm.rules
60-raw.rules 90-hal.rules
[root@purplerain1 by-path]#
配置如下:

[root@purplerain1 by-path]# vim /etc/udev/rules.d/55-iscsi.rules
[root@purplerain1 by-path]# cat /etc/udev/rules.d/55-iscsi.rules
KERNEL==”sd*”,BUS==”scsi”,PROGRAM=”/script/iscsi.sh %b”,SYMLINK+=”iscsi/%c/part%n”
[root@purplerain1 by-path]#
就像配置中所写的那样,还需要创建脚本文件“/script/iscsi.sh”。
如下:

[root@purplerain1 by-path]# mkdir /script
[root@purplerain1 by-path]# vim /script/iscsi.sh
[root@purplerain1 by-path]# cat /script/iscsi.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

# Check if QNAP drive
check_qnap_target_name=${target_name%%:*}
if [ $check_qnap_target_name = “iqn.2004-04.com.qnap” ]; then
target_name=echo "${target_name%.*}"
fi

echo “${target_name##*.}”
[root@purplerain1 by-path]#
验证:

[root@purplerain1 by-path]# ls /dev | grep iscsi
[root@purplerain1 by-path]#
[root@purplerain1 by-path]# service iscsi restart
Logging out of session [sid: 1, target: ora10g, portal: 192.168.81.128,3260] Logout of [sid: 1, target: ora10g, portal: 192.168.81.128,3260]: successful
Stopping iSCSI daemon:
iscsid dead but pid file exists [ OK ] Turning off network shutdown. Starting iSCSI daemon: [ OK ] [ OK ] Setting up iSCSI targets: Logging in to [iface: default, target: ora10g, portal: 192.168.81.128,3260] Login to [iface: default, target: ora10g, portal: 192.168.81.128,3260]: successful
[ OK ] [root@purplerain1 by-path]# ls /dev | grep iscsi
iscsi
[root@purplerain1 by-path]#
[root@purplerain1 by-path]# ls -l /dev/iscsi/
total 0
drwxr-xr-x 2 root root 60 Apr 15 10:59 ora10g
[root@purplerain1 by-path]# ls -l /dev/iscsi/ora10g/
total 0
lrwxrwxrwx 1 root root 9 Apr 15 10:59 part -> ../../sdb
[root@purplerain1 by-path]#
——
To be continue。

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

隐藏
变装