2016年11月11日金曜日

LIO Cluster [LIO, DRBD, Pacemaker による冗長化 iSCSI Target] (その8)LIO


LIO の設定を行います。

Active 機と Stand-by 機で targetcli コマンドの設定を確認します。


sudo targetcli get global
Warning: Could not load preferences file /root/.targetcli/prefs.bin.
GLOBAL CONFIG GROUP
===================
auto_add_default_portal=true
----------------------------
If true, adds a portal listening on all IPs to new targets.

auto_add_mapped_luns=true
-------------------------
If true, automatically create node ACLs mapped LUNs after creating a new target LUN or a new node ACL

auto_cd_after_create=false
--------------------------
If true, changes current path to newly created objects.

auto_enable_tpgt=true
---------------------
If true, automatically enables TPGTs upon creation.

auto_save_on_exit=true
----------------------
If true, saves configuration on exit.

color_command=cyan
------------------
Color to use for command completions.

color_default=none
------------------
Default text display color.

color_keyword=cyan
------------------
Color to use for keyword completions.

color_mode=true
---------------
Console color display mode.

color_parameter=magenta
-----------------------
Color to use for parameter completions.

color_path=magenta
------------------
Color to use for path completions

export_backstore_name_as_model=true
-----------------------------------
If true, the backstore name is used for the scsi inquiry model name.

logfile=/root/.targetcli/log.txt
--------------------------------
Logfile to use.

loglevel_console=info
---------------------
Log level for messages going to the console.

loglevel_file=debug
-------------------
Log level for messages going to the log file.

prompt_length=30
----------------
Max length of the shell prompt path, 0 for infinite.

tree_max_depth=0
----------------
Maximum depth of displayed node tree.

tree_round_nodes=true
---------------------
Tree node display style.

tree_show_root=true
-------------------
Whether or not to display tree root.

tree_status_mode=true
---------------------
Whether or not to display status in tree.


Active 機と Stand-by 機で、targetcli から exit する際に自動的に設定を save する挙動を無効化します。


sudo targetcli set global auto_save_on_exit=false
Parameter auto_save_on_exit is now 'false'.


Active 機と Stand-by 機で、targetcli から target を追加する際に自動的に portal がデフォルト値で作成される挙動を無効化します。


sudo targetcli set global auto_add_default_portal=false
Parameter auto_add_default_portal is now 'false'.


Active 機で、targetcli から 状態を確認します。


sudo targetcli ls /
o- / ..................................................................... [...]
  o- backstores .......................................................... [...]
  | o- block .............................................. [Storage Objects: 0]
  | o- fileio ............................................. [Storage Objects: 0]
  | o- pscsi .............................................. [Storage Objects: 0]
  | o- ramdisk ............................................ [Storage Objects: 0]
  o- iscsi ........................................................ [Targets: 0]
  o- loopback ..................................................... [Targets: 0]


Active 機で、IQN を定義します。


sudo targetcli /iscsi create iqn.2016-09.com.example:iscsitgt01
Created target iqn.2016-09.com.example:iscsitgt01.
Created TPG 1.

sudo targetcli ls /
o- / ..................................................................... [...]
  o- backstores .......................................................... [...]
  | o- block .............................................. [Storage Objects: 0]
  | o- fileio ............................................. [Storage Objects: 0]
  | o- pscsi .............................................. [Storage Objects: 0]
  | o- ramdisk ............................................ [Storage Objects: 0]
  o- iscsi ........................................................ [Targets: 1]
  | o- iqn.2016-09.com.example:iscsitgt01 ............................ [TPGs: 1]
  |   o- tpg1 ........................................... [no-gen-acls, no-auth]
  |     o- acls ...................................................... [ACLs: 0]
  |     o- luns ...................................................... [LUNs: 0]
  |     o- portals ................................................ [Portals: 0]
  o- loopback ..................................................... [Targets: 0]


Active 機で、ACL(アクセス許可リスト)にイニシエータ名を登録します。必要に応じて CHAP 認証情報も紐付けします。認証なしとしたい場合には、この作業をスキップします。


sudo targetcli /iscsi/iqn.2016-09.com.example:iscsitgt01/tpg1/acls create iqn.2016-09.com.example:initiator01
Created Node ACL for iqn.2016-09.com.example:initiator01

  sudo targetcli /iscsi/iqn.2016-09.com.example:iscsitgt01/tpg1/acls/iqn.2016-09.com.example:initiator01 set auth userid=iscsiuser01
Parameter userid is now 'iscsiuser01'.

  sudo targetcli /iscsi/iqn.2016-09.com.example:iscsitgt01/tpg1/acls/iqn.2016-09.com.example:initiator01 set auth password=password-user01
Parameter password is now 'password-user01'.


sudo targetcli /iscsi/iqn.2016-09.com.example:iscsitgt01/tpg1/acls create iqn.2016-09.com.example:initiator02
Created Node ACL for iqn.2016-09.com.example:initiator02

  sudo targetcli /iscsi/iqn.2016-09.com.example:iscsitgt01/tpg1/acls/iqn.2016-09.com.example:initiator02 set auth userid=iscsiuser02
Parameter userid is now 'iscsiuser02'.

  sudo targetcli /iscsi/iqn.2016-09.com.example:iscsitgt01/tpg1/acls/iqn.2016-09.com.example:initiator02 set auth password=password-user02
Parameter password is now 'password-user02'.


sudo targetcli /iscsi/iqn.2016-09.com.example:iscsitgt01/tpg1/acls create iqn.2016-09.com.example:initiator03
Created Node ACL for iqn.2016-09.com.example:initiator03

  sudo targetcli /iscsi/iqn.2016-09.com.example:iscsitgt01/tpg1/acls/iqn.2016-09.com.example:initiator03 set auth userid=iscsiuser03
Parameter userid is now 'iscsiuser03'.

  sudo targetcli /iscsi/iqn.2016-09.com.example:iscsitgt01/tpg1/acls/iqn.2016-09.com.example:initiator03 set auth password=password-user03
Parameter password is now 'password-user03'.


sudo targetcli /iscsi/iqn.2016-09.com.example:iscsitgt01/tpg1/acls create iqn.2016-09.com.example:initiator04
Created Node ACL for iqn.2016-09.com.example:initiator04

  sudo targetcli /iscsi/iqn.2016-09.com.example:iscsitgt01/tpg1/acls/iqn.2016-09.com.example:initiator04 set auth userid=iscsiuser04
Parameter userid is now 'iscsiuser04'.

  sudo targetcli /iscsi/iqn.2016-09.com.example:iscsitgt01/tpg1/acls/iqn.2016-09.com.example:initiator04 set auth password=password-user04
Parameter password is now 'password-user04'.

sudo targetcli ls /
o- / ..................................................................... [...]
  o- backstores .......................................................... [...]
  | o- block .............................................. [Storage Objects: 0]
  | o- fileio ............................................. [Storage Objects: 0]
  | o- pscsi .............................................. [Storage Objects: 0]
  | o- ramdisk ............................................ [Storage Objects: 0]
  o- iscsi ........................................................ [Targets: 1]
  | o- iqn.2016-09.com.example:iscsitgt01 ............................ [TPGs: 1]
  |   o- tpg1 ........................................... [no-gen-acls, no-auth]
  |     o- acls ...................................................... [ACLs: 4]
  |     | o- iqn.2016-09.com.example:initiator01 .............. [Mapped LUNs: 0]
  |     | o- iqn.2016-09.com.example:initiator02 .............. [Mapped LUNs: 0]
  |     | o- iqn.2016-09.com.example:initiator03 .............. [Mapped LUNs: 0]
  |     | o- iqn.2016-09.com.example:initiator04 .............. [Mapped LUNs: 0]
  |     o- luns ...................................................... [LUNs: 0]
  |     o- portals ................................................ [Portals: 0]
  o- loopback ..................................................... [Targets: 0]


Active 機で、バックエンド・デバイスを指定し、IQN に紐付けます。


sudo targetcli /backstores/block create name=lun0 dev=/dev/vg1/lv-lun0
Created block storage object lun0 using /dev/vg1/lv-lun0.

sudo targetcli /iscsi/iqn.2016-09.com.example:iscsitgt01/tpg1/luns create /backstores/block/lun0
Created LUN 0.
Created LUN 0->0 mapping in node ACL iqn.2016-09.com.example:initiator04
Created LUN 0->0 mapping in node ACL iqn.2016-09.com.example:initiator03
Created LUN 0->0 mapping in node ACL iqn.2016-09.com.example:initiator02
Created LUN 0->0 mapping in node ACL iqn.2016-09.com.example:initiator01


sudo targetcli /backstores/block create name=lun1 dev=/dev/vg1/lv-lun1
Created block storage object lun1 using /dev/vg1/lv-lun1.

sudo targetcli /iscsi/iqn.2016-09.com.example:iscsitgt01/tpg1/luns create /backstores/block/lun1
Created LUN 1.
Created LUN 1->1 mapping in node ACL iqn.2016-09.com.example:initiator04
Created LUN 1->1 mapping in node ACL iqn.2016-09.com.example:initiator03
Created LUN 1->1 mapping in node ACL iqn.2016-09.com.example:initiator02
Created LUN 1->1 mapping in node ACL iqn.2016-09.com.example:initiator01


sudo targetcli /backstores/block create name=lun2 dev=/dev/vg1/lv-lun2
Created block storage object lun2 using /dev/vg1/lv-lun2.

sudo targetcli /iscsi/iqn.2016-09.com.example:iscsitgt01/tpg1/luns create /backstores/block/lun2
Created LUN 2.
Created LUN 2->2 mapping in node ACL iqn.2016-09.com.example:initiator04
Created LUN 2->2 mapping in node ACL iqn.2016-09.com.example:initiator03
Created LUN 2->2 mapping in node ACL iqn.2016-09.com.example:initiator02
Created LUN 2->2 mapping in node ACL iqn.2016-09.com.example:initiator01


sudo targetcli /backstores/block create name=lun3 dev=/dev/vg1/lv-lun3
Created block storage object lun3 using /dev/vg1/lv-lun3.

sudo targetcli /iscsi/iqn.2016-09.com.example:iscsitgt01/tpg1/luns create /backstores/block/lun3
Created LUN 3.
Created LUN 3->3 mapping in node ACL iqn.2016-09.com.example:initiator04
Created LUN 3->3 mapping in node ACL iqn.2016-09.com.example:initiator03
Created LUN 3->3 mapping in node ACL iqn.2016-09.com.example:initiator02
Created LUN 3->3 mapping in node ACL iqn.2016-09.com.example:initiator01

sudo targetcli ls /
o- / ..................................................................... [...]
  o- backstores .......................................................... [...]
  | o- block .............................................. [Storage Objects: 4]
  | | o- lun0 ............... [/dev/vg1/lv-lun0 (360.0GiB) write-thru activated]
  | | o- lun1 ............... [/dev/vg1/lv-lun1 (360.0GiB) write-thru activated]
  | | o- lun2 ............... [/dev/vg1/lv-lun2 (360.0GiB) write-thru activated]
  | | o- lun3 ............... [/dev/vg1/lv-lun3 (360.0GiB) write-thru activated]
  | o- fileio ............................................. [Storage Objects: 0]
  | o- pscsi .............................................. [Storage Objects: 0]
  | o- ramdisk ............................................ [Storage Objects: 0]
  o- iscsi ........................................................ [Targets: 1]
  | o- iqn.2016-09.com.example:iscsitgt01 ............................ [TPGs: 1]
  |   o- tpg1 ........................................... [no-gen-acls, no-auth]
  |     o- acls ...................................................... [ACLs: 4]
  |     | o- iqn.2016-09.com.example:initiator01 .............. [Mapped LUNs: 4]
  |     | | o- mapped_lun0 .............................. [lun0 block/lun0 (rw)]
  |     | | o- mapped_lun1 .............................. [lun1 block/lun1 (rw)]
  |     | | o- mapped_lun2 .............................. [lun2 block/lun2 (rw)]
  |     | | o- mapped_lun3 .............................. [lun3 block/lun3 (rw)]
  |     | o- iqn.2016-09.com.example:initiator02 .............. [Mapped LUNs: 4]
  |     | | o- mapped_lun0 .............................. [lun0 block/lun0 (rw)]
  |     | | o- mapped_lun1 .............................. [lun1 block/lun1 (rw)]
  |     | | o- mapped_lun2 .............................. [lun2 block/lun2 (rw)]
  |     | | o- mapped_lun3 .............................. [lun3 block/lun3 (rw)]
  |     | o- iqn.2016-09.com.example:initiator03 .............. [Mapped LUNs: 4]
  |     | | o- mapped_lun0 .............................. [lun0 block/lun0 (rw)]
  |     | | o- mapped_lun1 .............................. [lun1 block/lun1 (rw)]
  |     | | o- mapped_lun2 .............................. [lun2 block/lun2 (rw)]
  |     | | o- mapped_lun3 .............................. [lun3 block/lun3 (rw)]
  |     | o- iqn.2016-09.com.example:initiator04 .............. [Mapped LUNs: 4]
  |     |   o- mapped_lun0 .............................. [lun0 block/lun0 (rw)]
  |     |   o- mapped_lun1 .............................. [lun1 block/lun1 (rw)]
  |     |   o- mapped_lun2 .............................. [lun2 block/lun2 (rw)]
  |     |   o- mapped_lun3 .............................. [lun3 block/lun3 (rw)]
  |     o- luns ...................................................... [LUNs: 4]
  |     | o- lun0 .............................. [block/lun0 (/dev/vg1/lv-lun0)]
  |     | o- lun1 .............................. [block/lun1 (/dev/vg1/lv-lun1)]
  |     | o- lun2 .............................. [block/lun2 (/dev/vg1/lv-lun2)]
  |     | o- lun3 .............................. [block/lun3 (/dev/vg1/lv-lun3)]
  |     o- portals ................................................ [Portals: 0]
  o- loopback ..................................................... [Targets: 0]


※ 今回試してみた範囲では、ここで「block」ではなく「fileio」を選ぶと、デバイス名が「/dev/dm-1」等という名前で保存されてしまい、再起動後やフェイルオーバー先で同じデバイス名となることが保証されないため、udev の設定変更も加える等の処置が追加で必要となるはずです。LVM 論理ボリュームを指定する場合は「block」を利用することをお奨めします。

※ ここでは、1つの Target IQN に複数の LUN を紐付けました。複数の IQN を用意し、1 IQN に 1 LUN という方が、きめ細かく設定できます。

2016/11/20追記
※ 1つの Target IQN に tpg が1つ紐付くわけですが、この1つの tpg が CPU の 1Core しか活用してくれないので、マルチコア、マルチプロセッサ環境で複数の LUN をエクスポートしたい場合には、1 IQN に 1 LUN という設定が推奨となります。10Gbit Ethernet 環境では、1 IQN には、多くても 4 LUN までにとどめておくべきです。

Active 機で、IQN に portal を作成します。


sudo targetcli /iscsi/iqn.2016-09.com.example:iscsitgt01/tpg1/portals create 10.110.88.58 3260
Using default IP port 3260
Created network portal 10.110.88.59:3260.

sudo targetcli ls /
o- / ..................................................................... [...]
  o- backstores .......................................................... [...]
  | o- block .............................................. [Storage Objects: 4]
  | | o- lun0 ............... [/dev/vg1/lv-lun0 (360.0GiB) write-thru activated]
  | | o- lun1 ............... [/dev/vg1/lv-lun1 (360.0GiB) write-thru activated]
  | | o- lun2 ............... [/dev/vg1/lv-lun2 (360.0GiB) write-thru activated]
  | | o- lun3 ............... [/dev/vg1/lv-lun3 (360.0GiB) write-thru activated]
  | o- fileio ............................................. [Storage Objects: 0]
  | o- pscsi .............................................. [Storage Objects: 0]
  | o- ramdisk ............................................ [Storage Objects: 0]
  o- iscsi ........................................................ [Targets: 1]
  | o- iqn.2016-09.com.example:iscsitgt01 ............................ [TPGs: 1]
  |   o- tpg1 ........................................... [no-gen-acls, no-auth]
  |     o- acls ...................................................... [ACLs: 4]
  |     | o- iqn.2016-09.com.example:initiator01 .............. [Mapped LUNs: 4]
  |     | | o- mapped_lun0 .............................. [lun0 block/lun0 (rw)]
  |     | | o- mapped_lun1 .............................. [lun1 block/lun1 (rw)]
  |     | | o- mapped_lun2 .............................. [lun2 block/lun2 (rw)]
  |     | | o- mapped_lun3 .............................. [lun3 block/lun3 (rw)]
  |     | o- iqn.2016-09.com.example:initiator02 .............. [Mapped LUNs: 4]
  |     | | o- mapped_lun0 .............................. [lun0 block/lun0 (rw)]
  |     | | o- mapped_lun1 .............................. [lun1 block/lun1 (rw)]
  |     | | o- mapped_lun2 .............................. [lun2 block/lun2 (rw)]
  |     | | o- mapped_lun3 .............................. [lun3 block/lun3 (rw)]
  |     | o- iqn.2016-09.com.example:initiator03 .............. [Mapped LUNs: 4]
  |     | | o- mapped_lun0 .............................. [lun0 block/lun0 (rw)]
  |     | | o- mapped_lun1 .............................. [lun1 block/lun1 (rw)]
  |     | | o- mapped_lun2 .............................. [lun2 block/lun2 (rw)]
  |     | | o- mapped_lun3 .............................. [lun3 block/lun3 (rw)]
  |     | o- iqn.2016-09.com.example:initiator04 .............. [Mapped LUNs: 4]
  |     |   o- mapped_lun0 .............................. [lun0 block/lun0 (rw)]
  |     |   o- mapped_lun1 .............................. [lun1 block/lun1 (rw)]
  |     |   o- mapped_lun2 .............................. [lun2 block/lun2 (rw)]
  |     |   o- mapped_lun3 .............................. [lun3 block/lun3 (rw)]
  |     o- luns ...................................................... [LUNs: 4]
  |     | o- lun0 .............................. [block/lun0 (/dev/vg1/lv-lun0)]
  |     | o- lun1 .............................. [block/lun1 (/dev/vg1/lv-lun1)]
  |     | o- lun2 .............................. [block/lun2 (/dev/vg1/lv-lun2)]
  |     | o- lun3 .............................. [block/lun3 (/dev/vg1/lv-lun3)]
  |     o- portals ................................................ [Portals: 1]
  |       o- 10.110.88.59:3260 ............................................ [OK]
  o- loopback ..................................................... [Targets: 0]

sudo ss -ant | grep LISTEN.\*:3260
LISTEN     0      256    10.110.88.59:3260                     *:*


Active 機で、設定ファイルに設定を保存し、Stand-by 機にコピーします。


sudo targetcli saveconfig
Last 10 configs saved in /etc/target/backup.
Configuration saved to /etc/target/saveconfig.json

sudo scp -p /etc/target/saveconfig.json iscsitgt01s:/etc/target/saveconfig.json
saveconfig.json                               100% 8709     8.5KB/s   00:00


Active 機と Stand-by 機で、LIO のリソース・エージェントを作成します。


cat << 'EOF_LIO' | sudo tee /usr/lib/ocf/resource.d/heartbeat/LIO
#!/bin/bash
#
#     LIO OCF RA. manages iSCSI target LIO.
#
#   (c) 2009-2010 Florian Haas, Dejan Muhamedagic,
#                 and Linux-HA contributors
#
#      modified by Katsuaki Hamada (hamada@pc-office.net), 10 Dec 2016
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of version 2 of the GNU General Public License as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it would be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# Further, this software is distributed without any warranty that it is
# free of the rightful claim of any third person regarding infringement
# or the like.  Any license provided herein, whether implied or
# otherwise, applies only to this software file.  Patent licenses, if
# any, provided herein do not apply to combinations of this program with
# other software, or any other product whatsoever.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write the Free Software Foundation,
# Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
#

#######################################################################
# Initialization:
: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs

# Lockfile, used for selecting a target ID
LOCKFILE=${HA_RSCTMP}/target.lock
#######################################################################

meta_data() {
        cat <<END
<?xml version="1.0"?>
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
<resource-agent name="LIO" version="1.0">
<version>0.9</version>

<longdesc lang="en">
Manages iSCSI target LIO. An iSCSI target is a collection of SCSI Logical
Units (LUs) exported via a daemon that speaks the iSCSI protocol.
</longdesc>
<shortdesc lang="en">iSCSI target export agent</shortdesc>

<parameters>
<parameter name="iqn" required="0" unique="1">
<longdesc lang="en">
The target iSCSI Qualified Name (IQN). Should follow the conventional
iqn.yyyy-mm.&lt;reversed domain name&gt;[:identifier] syntax.
</longdesc>
<shortdesc lang="en">iSCSI target IQN</shortdesc>
<content type="string" />
</parameter>
</parameters>

<actions>
<action name="start" timeout="10" />
<action name="stop" timeout="10" />
<action name="status" timeout="10" interval="10" depth="0" />
<action name="monitor" timeout="10" interval="10" depth="0" />
<action name="meta-data" timeout="5" />
<action name="validate-all" timeout="10" />
</actions>
</resource-agent>
END
}

#######################################################################

LIO_usage() {
  cat <<END
usage: $0 {start|stop|status|monitor|validate-all|meta-data}

Expects to have a fully populated OCF RA-compliant environment set.
END
}

LIO_start() {
  LIO_monitor
  [ $? = $OCF_SUCCESS ] && return $OCF_SUCCESS
  /usr/bin/timeout 3 /usr/bin/targetctl restore
  LIO_monitor
}

LIO_stop() {
  LIO_monitor
  [ $? -eq $OCF_NOT_RUNNING ] && return $OCF_SUCCESS
  /usr/bin/timeout 3 /usr/bin/targetctl clear
  rc=$?
  [ $rc -eq 0 ] && return $OCF_SUCCESS
  [ -e /etc/ha.d/noreboot ] && return $rc
  echo 1 > /proc/sys/kernel/sysrq
  echo s > /proc/sysrq-trigger
  echo u > /proc/sysrq-trigger
  echo c > /proc/sysrq-trigger
  /sbin/reboot -f
  return $rc
}

LIO_monitor() {
  for i in /sys/kernel/config/target/iscsi/iqn.*
  do
    [ -d $i ] && [ $(cat $i/tpgt_1/enable) -eq 1 ] && return $OCF_SUCCESS
  done
  return $OCF_NOT_RUNNING
}

LIO_validate() {
  if ! ocf_is_probe; then
    # Do we have all required binaries?
    check_binary targetctl
  fi
  return $OCF_SUCCESS
}

case $1 in
  meta-data)  meta_data; exit $OCF_SUCCESS;;
  usage|help) LIO_usage; exit $OCF_SUCCESS;;
esac

# Everything except usage and meta-data must pass the validate test
LIO_validate

case $__OCF_ACTION in
  start)          LIO_start;;
  stop)           LIO_stop;;
  monitor|status) LIO_monitor;;
  reload)         ocf_log err "Reloading..."; LIO_start;;
  validate-all)   ;;
  *)              LIO_usage; exit $OCF_ERR_UNIMPLEMENTED;;
esac
rc=$?
ocf_log debug "${OCF_RESOURCE_INSTANCE} $__OCF_ACTION : $rc"
exit $rc
EOF_LIO
sudo chmod 755 /usr/lib/ocf/resource.d/heartbeat/LIO


※ 2016/12/10
targetctl, targetcli コマンドが応答不能になるケース(LIO のバグ)が見つかったので、stop に関して、3秒以内に応答がない場合は強制的に OS を再起動するように変更しました。
但し、/etc/ha.d/noreboot というファイルが存在する場合は、単にエラーを返します。
start に関しては、3秒でタイムアウトするように変更しました。


※ 当初は、systemd の target.service をリソース・エージェントとして利用しようと考えていました。スイッチオーバはうまく動くのですが、クラスタを停止しようとした場合にエラーが発生します。oneshot タイプだとうまくいかないのかと考え、sleep するだけのデーモンプロセスを作ってみました。どうも Pacemaker のプロセス処理で、リソース・エージェントの子プロセスに対する処理はしていない(考慮事項が足りない)ようで、かつ、終了時には stop メソッドも呼び出さないらしく、エラーを解消することができませんでした。以下のようなロジックで TERM シグナルを送ってくれればいいと思うのですが、そうではないようで、残念です。

killpstree(){
  kill -STOP $1
  for i in $(ps -o pid --no-heading --ppid $1)
  do
    killpstree $i
  done
  kill $2 $1
  kill -CONT $1
}
killpstree $(cat /run/target.pid) -TERM

※ このリソース・エージェントは、標準のリソース・エージェントとは設計思想が異なります。標準のリソース・エージェントは、サービスの内部のリソースまで管理し、種々の iSCSI Target で同じようによう扱えるように標準化しようという目標の元、処理が複雑化しています。私が作ったリソース・エージェントは、単純に、target.service の置き換えとなるようにしました。
単純なおかげで、iSCSITarget リソース・エージェントからの改造にかかった時間も1時間ほどですみました。他の iSCSI Target のことは考えなくてよいので、LIO の全ての機能を利用可能です。改造元のリソース・エージェントは、LIO の CHAP 認証機能を扱う機構が組み込まれていませんでした。

Active 機と Stand-by 機で、VIP 用のリソースエージェントを作ります。作るというよりも、IPaddr2  リソースエージェントの名前を VIP にリネームします。


sed -e 's/IPaddr2/VIP/g' /usr/lib/ocf/resource.d/heartbeat/IPaddr2 | sudo tee /usr/lib/ocf/resource.d/heartbeat/VIP > /dev/null
sudo chmod 755 /usr/lib/ocf/resource.d/heartbeat/VIP


Active 機で、VIP を追加します。


sudo ip addr add 10.110.88.59/26 dev bond0

ip addr show bond0
6: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 9000 qdisc noqueue state UNKNOWN
    link/ether 00:0c:29:0b:ab:b0 brd ff:ff:ff:ff:ff:ff
    inet 10.110.88.57/26 brd 10.110.88.63 scope global bond0
       valid_lft forever preferred_lft forever
    inet 10.110.88.59/26 brd 10.110.88.63 scope global secondary bond0
       valid_lft forever preferred_lft forever


ここまでの操作で、イニシエータから接続が可能な状態になっています。

0 件のコメント:

コメントを投稿