GNU/Linux >> Linux の 問題 >  >> Cent OS

Linux SCSI 予約について

SCSI 予約とは

SCSI 予約は、SCSI イニシエーターが排他的アクセスのために LUN を予約できるようにし、他のイニシエーターが変更を加えないようにするメカニズムです。この機能は通常、クラスターで使用されます。この投稿では、CentOS/RHEL システムでの SCSI 予約の基本的な使用法について詳しく説明します。

SCSI 予約には 2 つの段階があります。最初に、イニシエーターは予約キーを登録する必要があります。次に、ホストが排他的アクセスを必要とするときに、同じ予約キーを使用してデバイスを予約し続けます。 SCSI 予約と SCSI 予約に必要な機能を使用する方法を見てみましょう。

必要なユーティリティをインストールします

sg_persist コマンドは、SCSI 予約に必要なすべての機能を提供します。パッケージ sg3_utils に含まれています。 .

# yum install sg3_utils

登録を表示

以下の例では、まだ予約キーが登録されていません。

# sg_persist /dev/sdc
>> No service action given; assume Persistent Reserve In command
>> with Read Keys service action
IET VIRTUAL-DISK 0001
Peripheral device type: disk
PR generation=0x4, there are NO registered reservation keys

予約キーを登録

予約キーは、最大 8 バイトの長さの 16 進文字列である必要があります。ここでは、たとえば abc123 を使用します。

# sg_persist --out --register --param-sark=abc123 /dev/sdc

以下の出力は、2 つの予約キー (または 2 つのホスト) が登録されている SCSI LUN を示しています。

# sg_persist /dev/sdc
>> No service action given; assume Persistent Reserve In command
>> with Read Keys service action
IET VIRTUAL-DISK 0001
Peripheral device type: disk
PR generation=0x6, 2 registered reservation keys follow:
0xabc123
0x123abc

特定のキーに代わって登録済み LUN を予約

# sg_persist --out --reserve --param-rk=abc123 --prout-type=3 /dev/sdc
IET VIRTUAL-DISK 0001
Peripheral device type: disk

–プラウト型 パラメータは、マンページからの予約タイプを指定し、以下を含む有効なタイプ:

  • 1 :専用書き込み
  • 3 :排他的アクセス
  • 5 :専用書き込み – 登録者のみ
  • 6 :排他的アクセス - 登録者のみ
  • 7 :排他的書き込み – すべての登録者
  • 8 :排他的アクセス – すべての登録者

予約を見る

出力は、サーバーがキー abc123 によってタイプ 3 (排他的アクセス) で予約されていることを示しています:

# sg_persist -r /dev/sdc
IET VIRTUAL-DISK 0001
Peripheral device type: disk
PR generation=0x6, Reservation follows:
Key=0xabc123
scope: LU_SCOPE, type: Exclusive Access

予約を確認

/dev/sdc1 が予約されている node1 では、ディスクをマウントできました。

# mount /dev/sdc1 /mnt
# mount | grep mnt
/dev/sdc1 on /mnt type ext3 (rw,relatime,errors=continue,user_xattr,acl,barrier=1,data=ordered)
# umount /mnt

その間、node2 の同じディスクにアクセスできませんでした

# mount /dev/sdc1 /mnt
mount: mount /dev/sdc1 on /mnt failed: Invalid exchange

dmesg 表示予約の競合

# dmesg | tail
[6902380.608058] sd 11:0:0:1: [sdc] tag#16 FAILED Result: hostbyte=DID_OK driverbyte=DRIVER_OK
[6902380.608060] sd 11:0:0:1: [sdc] tag#16 CDB: Read(10) 28 00 00 1f ff 80 00 00 08 00
[6902380.608061] blk_update_request: critical nexus error, dev sdc, sector 2097024
[6902380.608064] Buffer I/O error on dev sdc1, logical block 261872, async page read
[6902380.609007] sd 11:0:0:1: reservation conflict
[6902380.609011] sd 11:0:0:1: [sdc] tag#14 FAILED Result: hostbyte=DID_OK driverbyte=DRIVER_OK
[6902380.609013] sd 11:0:0:1: [sdc] tag#14 CDB: Read(10) 28 00 00 00 08 00 00 00 01 00
[6902380.609015] blk_update_request: critical nexus error, dev sdc, sector 2048
[6902380.609523] sd 11:0:0:1: reservation conflict
[6902380.609526] blk_update_request: critical nexus error, dev sdc, sector 0

予約を解除

# sg_persist --out --release --param-rk=abc123 --prout-type=3 /dev/sdc

予約キーの登録を解除

# sg_persist --out --register --param-rk=abc123 /dev/sdc
Linux OS サービス「scsi_reserve」


Cent OS
  1. CでのLinuxソフトウェアライブラリを理解するためのガイド

  2. Linuxでの起動時にsystemdを理解する

  3. Linux – Linuxでの同期コマンド操作を理解していますか?

  1. 基本的な Linux コマンドを理解する

  2. Linux での dm-Multipath 識別子について

  3. Linux での SELinux ポリシーについて

  1. straceを使用したLinuxでのシステムコールの理解

  2. Linuxデスクトップを理解していますか?

  3. Linux の /etc/xinetd.conf ファイルについて