RAC on Oracle VM - iSCSIイニシエータを設定する - すこっと・たいがー!
udevの設定
udevを使用してiSCSIとして利用するデバイスを命名し固定化を行います。イニシエータがiSCSIターゲットにログインすると自動的にudevdデーモンが/dev/sdbのようにデバイスファイルを作成しますが、毎回同じデバイスファイル名を使用するとは限りません。また、/dev/sdbといったデバイスファイル名だとRAWデバイスとして使用する際に何の領域として利用しているのかわかりません。そこで、デバイスファイルの命名規則を作成すると同時に毎回同じファイル名が設定されるようにデバイスファイルの設定ルールを作成します。
まず、現状マッピングされているデバイスファイルの一覧は以下のコマンドで確認することができます。
[root@vmrac1 ~]# (cd /dev/disk/by-path; ls -l *openfiler* | awk '{FS=" "; print $9 " " $10 " " $11}') ip-172.16.1.13:3260-iscsi-iqn.2006-01.com.openfiler:vg01.dg01 -> ../../sdb ip-172.16.1.13:3260-iscsi-iqn.2006-01.com.openfiler:vg01.dg02 -> ../../sde ip-172.16.1.13:3260-iscsi-iqn.2006-01.com.openfiler:vg01.ocr01 -> ../../sdc ip-172.16.1.13:3260-iscsi-iqn.2006-01.com.openfiler:vg01.ocr02 -> ../../sdf ip-172.16.1.13:3260-iscsi-iqn.2006-01.com.openfiler:vg01.voting01 -> ../../sdg ip-172.16.1.13:3260-iscsi-iqn.2006-01.com.openfiler:vg01.voting02 -> ../../sda ip-172.16.1.13:3260-iscsi-iqn.2006-01.com.openfiler:vg01.voting03 -> ../../sddiSCSIターゲットのIQNでは「vg01.voting01」の文字列から何の領域かが判断つきますが、「/dev/sdg」といったデバイスファイル名だと何の領域なんだか判断がつきません。そこで、udevルールファイル「/etc/udev/rules.d/55-openiscsi.rules」を作成します。
[root@vmrac1 ~]# vi /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/part%n", OWNER="oracle", MODE="0640", GROUP="oinstall"上記の設定は、カーネルデバイス名が「sd*」でデバイスのバスの種類が「scsi」の場合、外部プログラム「/etc/udev/scripts/iscsidev.sh」を実行する。という意味で、さらにSYMLINKでデバイスファイル名の命名を行い、そのファイルの権限をOWNER、MODE、GROUPで設定しています。ちなみに、カーネルデバイス名(KERNEL)とデバイスバスのタイプ(BUS)はudevinfoコマンドを使用することで確認できます。たとえば、「/dev/sdb」で認識されているカーネルデバイス名とバスのタイプは以下のコマンドで調査します。
[root@vmrac1 ~]# udevinfo -a -p $(udevinfo -q path -n /dev/sdb) Udevinfo starts with the device specified by the devpath and then walks up the chain of parent devices. It prints for every device found, all possible attributes in the udev rules key format. A rule to match, can be composed by the attributes of the device and the attributes from one single parent device. looking at device '/block/sdb': KERNEL=="sdb" SUBSYSTEM=="block" : :次に、ルールで設定した外部プログラム「/etc/udev/scripts/iscsidev.sh」を作成します。これは、IQNの最後の文字列(たとえば、dg01やocr01など)を取得するシェルスクリプトです。
[root@vmrac1 ~]# cat /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##*.}"OS再起動
今までの設定を確認するためにOS再起動をしてみます。そして、デバイスファイルを確認してみると次のようにわかりやすい名前でデバイスが作成されていることがわかります。
[root@vmrac1 ~]# ls -l /dev/iscsi/*/* lrwxrwxrwx 1 root root 9 2月 1 21:18 /dev/iscsi/dg01/part -> ../../sdb lrwxrwxrwx 1 root root 9 2月 1 21:18 /dev/iscsi/dg02/part -> ../../sde lrwxrwxrwx 1 root root 9 2月 1 21:18 /dev/iscsi/ocr01/part -> ../../sdc lrwxrwxrwx 1 root root 9 2月 1 21:18 /dev/iscsi/ocr02/part -> ../../sdf lrwxrwxrwx 1 root root 9 2月 1 21:18 /dev/iscsi/voting01/part -> ../../sdg lrwxrwxrwx 1 root root 9 2月 1 21:18 /dev/iscsi/voting02/part -> ../../sda lrwxrwxrwx 1 root root 9 2月 1 21:18 /dev/iscsi/voting03/part -> ../../sddちょっと難しかったので、ここまでとして次回はOCRと投票ディスク領域に、Oracle Cluster File System 2 を利用するための設定を行います。
Posted via web from アマノユウのポケットメモ | Comment »














