LoginSignup
27
0

More than 1 year has passed since last update.

概要

Amazon FSx for NetApp ONTAP では、ファイルストレージ(NFS)だけじゃなく、ブロックストレージとして iSCSI が利用できます。

今回は、Amazon FSx for NetApp ONTAP の iSCSI LUN を Linux で認識させるところまで実践してみたいと思います。

基本的な手順は、AWS公式 を参照しています。

やること / やらないこと

やること

今回取り上げるのは、ざっくり以下の内容です。

  • NetApp側

    • iSCSIターゲット設定
  • Linux側

    • iSCSIイニシエーター設定
    • DM-Multipath設定

やらないこと

以下については、Linuxの一般的な操作なので今回はやりません。

  • パーティション作成
  • ファイルシステム作成
  • マウント

事前準備

安心安全のクラスメソッドさんの記事などを参考に、事前にSVMとボリュームを作成しておきます。

ONTAPに接続後、以下コマンドでも確認可能です。

  • SVM
::> vserver show
                               Admin      Operational Root
Vserver     Type    Subtype    State      State       Volume     Aggregate
----------- ------- ---------- ---------- ----------- ---------- ----------
fsx         data    default    running    running     fsx_root   aggr1
  • ボリューム
::> volume show
Vserver   Volume       Aggregate    State      Type       Size  Available Used%
--------- ------------ ------------ ---------- ---- ---------- ---------- -----
fsx       fsx_root     aggr1        online     RW          1GB    972.1MB    0%
fsx       vol1         aggr1        online     RW          1TB    860.3GB    0%
2 entries were displayed.

LUNの作成

ONTAPの管理エンドポイントにSSH接続します。

$ ssh fsxadmin@management.fs-00db1764f1699fd52.fsx.ap-northeast-1.amazonaws.com
Password:

Last login time: 6/22/2023 19:51:03

事前にLUNが一つも作成されていないことを確認します。

::> lun show
This table is currently empty.

lun create コマンドで LUNを作成します。

::> lun create -vserver fsx -volume vol1 -lun lun01 -size 10240 -ostype linux -space-allocation enabled

Created a LUN of size 10k (10240)

LUNが作成されたことを確認します。

::> lun show
Vserver   Path                            State   Mapped   Type        Size
--------- ------------------------------- ------- -------- -------- --------
fsx       /vol/vol1/lun01                 online  unmapped linux        10KB

Linux OSのiSCSI設定

必要なパッケージ(iscsi-initiator-utilsdevice-mapper-multipath)をインストールします。

$ sudo yum install device-mapper-multipath iscsi-initiator-utils -y
読み込んだプラグイン:extras_suggestions, langpacks, priorities, update-motd
amzn2-core                                                                                                                                                                                                                                                                                                                                           | 3.7 kB  00:00:00
amzn2extra-docker                                                                                                                                                                                                                                                                                                                                    | 3.0 kB  00:00:00
amzn2extra-kernel-5.10                                                                                                                                                                                                                                                                                                                               | 3.0 kB  00:00:00
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> パッケージ device-mapper-multipath.x86_64 0:0.4.9-136.amzn2 を インストール
--> 依存性の処理をしています: device-mapper-multipath-libs = 0.4.9-136.amzn2 のパッケージ: device-mapper-multipath-0.4.9-136.amzn2.x86_64
--> 依存性の処理をしています: libmultipath.so.0()(64bit) のパッケージ: device-mapper-multipath-0.4.9-136.amzn2.x86_64
--> 依存性の処理をしています: libmpathpersist.so.0()(64bit) のパッケージ: device-mapper-multipath-0.4.9-136.amzn2.x86_64
--> 依存性の処理をしています: libmpathcmd.so.0()(64bit) のパッケージ: device-mapper-multipath-0.4.9-136.amzn2.x86_64
---> パッケージ iscsi-initiator-utils.x86_64 0:6.2.0.874-7.amzn2 を インストール
--> 依存性の処理をしています: iscsi-initiator-utils-iscsiuio >= 6.2.0.874-7.amzn2 のパッケージ: iscsi-initiator-utils-6.2.0.874-7.amzn2.x86_64
--> トランザクションの確認を実行しています。
---> パッケージ device-mapper-multipath-libs.x86_64 0:0.4.9-136.amzn2 を インストール
---> パッケージ iscsi-initiator-utils-iscsiuio.x86_64 0:6.2.0.874-7.amzn2 を インストール
--> 依存性解決を終了しました。

依存性を解決しました

============================================================================================================================================================================================================================================================================================================================================================================
 Package                                                                                                アーキテクチャー                                                               バージョン                                                                                  リポジトリー                                                                        容量
============================================================================================================================================================================================================================================================================================================================================================================
インストール中:
 device-mapper-multipath                                                                                x86_64                                                                         0.4.9-136.amzn2                                                                             amzn2-core                                                                         147 k
 iscsi-initiator-utils                                                                                  x86_64                                                                         6.2.0.874-7.amzn2                                                                           amzn2-core                                                                         420 k
依存性関連でのインストールをします:
 device-mapper-multipath-libs                                                                           x86_64                                                                         0.4.9-136.amzn2                                                                             amzn2-core                                                                         266 k
 iscsi-initiator-utils-iscsiuio                                                                         x86_64                                                                         6.2.0.874-7.amzn2                                                                           amzn2-core                                                                          90 k

トランザクションの要約
============================================================================================================================================================================================================================================================================================================================================================================
インストール  2 パッケージ (+2 個の依存関係のパッケージ)

総ダウンロード容量: 924 k
インストール容量: 3.3 M
Downloading packages:
(1/4): device-mapper-multipath-0.4.9-136.amzn2.x86_64.rpm                                                                                                                                                                                                                                                                                            | 147 kB  00:00:00
(2/4): device-mapper-multipath-libs-0.4.9-136.amzn2.x86_64.rpm                                                                                                                                                                                                                                                                                       | 266 kB  00:00:00
(3/4): iscsi-initiator-utils-6.2.0.874-7.amzn2.x86_64.rpm                                                                                                                                                                                                                                                                                            | 420 kB  00:00:00
(4/4): iscsi-initiator-utils-iscsiuio-6.2.0.874-7.amzn2.x86_64.rpm                                                                                                                                                                                                                                                                                   |  90 kB  00:00:00
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
合計                                                                                                                                                                                                                                                                                                                                        2.7 MB/s | 924 kB  00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  インストール中          : iscsi-initiator-utils-6.2.0.874-7.amzn2.x86_64                                                                                                                                                                                                                                                                                              1/4
  インストール中          : iscsi-initiator-utils-iscsiuio-6.2.0.874-7.amzn2.x86_64                                                                                                                                                                                                                                                                                     2/4
  インストール中          : device-mapper-multipath-libs-0.4.9-136.amzn2.x86_64                                                                                                                                                                                                                                                                                         3/4
  インストール中          : device-mapper-multipath-0.4.9-136.amzn2.x86_64                                                                                                                                                                                                                                                                                              4/4
  検証中                  : device-mapper-multipath-0.4.9-136.amzn2.x86_64                                                                                                                                                                                                                                                                                              1/4
  検証中                  : iscsi-initiator-utils-iscsiuio-6.2.0.874-7.amzn2.x86_64                                                                                                                                                                                                                                                                                     2/4
  検証中                  : device-mapper-multipath-libs-0.4.9-136.amzn2.x86_64                                                                                                                                                                                                                                                                                         3/4
  検証中                  : iscsi-initiator-utils-6.2.0.874-7.amzn2.x86_64                                                                                                                                                                                                                                                                                              4/4

インストール:
  device-mapper-multipath.x86_64 0:0.4.9-136.amzn2                                                                                                                                     iscsi-initiator-utils.x86_64 0:6.2.0.874-7.amzn2

依存性関連をインストールしました:
  device-mapper-multipath-libs.x86_64 0:0.4.9-136.amzn2                                                                                                                              iscsi-initiator-utils-iscsiuio.x86_64 0:6.2.0.874-7.amzn2

完了しました!
$

iSCSIサービスを起動します。

$ sudo systemctl status iscsid.service
● iscsid.service - Open-iSCSI
   Loaded: loaded (/usr/lib/systemd/system/iscsid.service; disabled; vendor preset: disabled)
   Active: inactive (dead)
     Docs: man:iscsid(8)
           man:iscsiadm(8)

$ sudo systemctl start iscsid

$ sudo systemctl status iscsid.service
● iscsid.service - Open-iSCSI
   Loaded: loaded (/usr/lib/systemd/system/iscsid.service; disabled; vendor preset: disabled)
   Active: active (running) since 木 2023-06-22 20:29:35 UTC; 2s ago
     Docs: man:iscsid(8)
           man:iscsiadm(8)
  Process: 17175 ExecStart=/usr/sbin/iscsid (code=exited, status=0/SUCCESS)
 Main PID: 17177 (iscsid)
   CGroup: /system.slice/iscsid.service
           ├─17176 /usr/sbin/iscsid
           └─17177 /usr/sbin/iscsid

 6月 22 20:29:35 ip-10-0-0-142.ap-northeast-1.compute.internal systemd[1]: Starting Open-iSCSI...
 6月 22 20:29:35 ip-10-0-0-142.ap-northeast-1.compute.internal iscsid[17175]: iSCSI logger with pid=17176 started!
 6月 22 20:29:35 ip-10-0-0-142.ap-northeast-1.compute.internal systemd[1]: Failed to parse PID from file /var/run/iscsid.pid: Invalid argument
 6月 22 20:29:35 ip-10-0-0-142.ap-northeast-1.compute.internal iscsid[17176]: iSCSI daemon with pid=17177 started!
 6月 22 20:29:35 ip-10-0-0-142.ap-northeast-1.compute.internal systemd[1]: Started Open-iSCSI.

以下のコマンドでフェイルオーバー設定用の DM-Multipath をセットアップします。
このコマンドでマルチパス設定が有効になり、multipathd デーモンが起動されます。

$ sudo mpathconf --enable --with_multipathd y

EC2インスタンスのイニシエーター名を確認します。

$ sudo cat /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.1994-05.com.redhat:0f38a7bcd63

iSCSIターゲットの設定

ONTAP CLI からiSCSIターゲットの設定をします。

事前にigroupが1つも作成されていないことを確認します。

::> lun igroup show
This table is currently empty.

igroup(イニシエーターグループ)を作成します。
-initiator には、先ほど確認したEC2インスタンスのイニシエータ名を記載します。

::> lun igroup create -vserver fsx -igroup igroup_01 -initiator iqn.1994-05.com.redhat:0f38a7bcd63 -protocol iscsi -ostype linux

igroupが作成されたことを確認します。

::> lun igroup show
Vserver   Igroup       Protocol OS Type  Initiators
--------- ------------ -------- -------- ------------------------------------
fsx       igroup_01    iscsi    linux    iqn.1994-05.com.redhat:0f38a7bcd63

LUNとイニシエーターグループのマッピングを作成します。
事前にマッピング状態を確認します。
この時点では、unmapped になっています。

::> lun show -path /vol/vol1/lun01 -fields state,mapped,serial-hex
vserver path            serial-hex               state  mapped
------- --------------- ------------------------ ------ --------
fsx     /vol/vol1/lun01 6c574230673f55744a346669 online unmapped

マッピングを作成します。

::> lun mapping create -vserver fsx -path /vol/vol1/lun01 -igroup igroup_01 -lun-id 01

再度コマンドを実行し、mapped となっていることを確認します。

::> lun show -path /vol/vol1/lun01 -fields state,mapped,serial-hex
vserver path            serial-hex               state  mapped
------- --------------- ------------------------ ------ ------
fsx     /vol/vol1/lun01 6c574230673f55744a346669 online mapped

対象SVMのiSCSI IPアドレスを確認します。

::> network interface show -vserver fsx
            Logical    Status     Network            Current       Current Is
Vserver     Interface  Admin/Oper Address/Mask       Node          Port    Home
----------- ---------- ---------- ------------------ ------------- ------- ----
fsx
            iscsi_1      up/up    10.0.0.41/24       FsxId00db1764f1699fd52-01 e0e true
            iscsi_2      up/up    10.0.0.121/24      FsxId00db1764f1699fd52-02 e0e true
            nfs_smb_management_1 up/up 10.0.0.217/24 FsxId00db1764f1699fd52-01 e0e true
3 entries were displayed.

Amazon Linux 2 で認識させる

事前に確認したiscsi_1のIPアドレスを --portal に指定して、ターゲットのiSCSIノードを検出します。

$ sudo iscsiadm --mode discovery --op update --type sendtargets --portal 10.0.0.41
10.0.0.41:3260,1028 iqn.1992-08.com.netapp:sn.c8bdab770d1a11eeaea9bb21f0b8b056:vs.3
10.0.0.121:3260,1030 iqn.1992-08.com.netapp:sn.c8bdab770d1a11eeaea9bb21f0b8b056:vs.3

各アベイラビリティーゾーンの ONTAP ノードごとにイニシエーターごとに 4 つのセッションを確立し、クライアントが最大 20 Gb/秒 (2,500 MB / 秒) の集約スループットを iSCSI LUN に駆動できるようにします。

$ sudo iscsiadm --mode node -T iqn.1992-08.com.netapp:sn.c8bdab770d1a11eeaea9bb21f0b8b056:vs.3 --op update -n node.session.nr_sessions -v 4

ターゲットイニシエーターにログインします。
iSCSI LUN が、使用可能なディスクとして表示されます。

$ sudo iscsiadm --mode node -T iqn.1992-08.com.netapp:sn.c8bdab770d1a11eeaea9bb21f0b8b056:vs.3 --login
Logging in to [iface: default, target: iqn.1992-08.com.netapp:sn.c8bdab770d1a11eeaea9bb21f0b8b056:vs.3, portal: 10.0.0.41,3260] (multiple)
Logging in to [iface: default, target: iqn.1992-08.com.netapp:sn.c8bdab770d1a11eeaea9bb21f0b8b056:vs.3, portal: 10.0.0.41,3260] (multiple)
Logging in to [iface: default, target: iqn.1992-08.com.netapp:sn.c8bdab770d1a11eeaea9bb21f0b8b056:vs.3, portal: 10.0.0.41,3260] (multiple)
Logging in to [iface: default, target: iqn.1992-08.com.netapp:sn.c8bdab770d1a11eeaea9bb21f0b8b056:vs.3, portal: 10.0.0.41,3260] (multiple)
Logging in to [iface: default, target: iqn.1992-08.com.netapp:sn.c8bdab770d1a11eeaea9bb21f0b8b056:vs.3, portal: 10.0.0.121,3260] (multiple)
Logging in to [iface: default, target: iqn.1992-08.com.netapp:sn.c8bdab770d1a11eeaea9bb21f0b8b056:vs.3, portal: 10.0.0.121,3260] (multiple)
Logging in to [iface: default, target: iqn.1992-08.com.netapp:sn.c8bdab770d1a11eeaea9bb21f0b8b056:vs.3, portal: 10.0.0.121,3260] (multiple)
Logging in to [iface: default, target: iqn.1992-08.com.netapp:sn.c8bdab770d1a11eeaea9bb21f0b8b056:vs.3, portal: 10.0.0.121,3260] (multiple)
Login to [iface: default, target: iqn.1992-08.com.netapp:sn.c8bdab770d1a11eeaea9bb21f0b8b056:vs.3, portal: 10.0.0.41,3260] successful.
Login to [iface: default, target: iqn.1992-08.com.netapp:sn.c8bdab770d1a11eeaea9bb21f0b8b056:vs.3, portal: 10.0.0.41,3260] successful.
Login to [iface: default, target: iqn.1992-08.com.netapp:sn.c8bdab770d1a11eeaea9bb21f0b8b056:vs.3, portal: 10.0.0.41,3260] successful.
Login to [iface: default, target: iqn.1992-08.com.netapp:sn.c8bdab770d1a11eeaea9bb21f0b8b056:vs.3, portal: 10.0.0.41,3260] successful.
Login to [iface: default, target: iqn.1992-08.com.netapp:sn.c8bdab770d1a11eeaea9bb21f0b8b056:vs.3, portal: 10.0.0.121,3260] successful.
Login to [iface: default, target: iqn.1992-08.com.netapp:sn.c8bdab770d1a11eeaea9bb21f0b8b056:vs.3, portal: 10.0.0.121,3260] successful.
Login to [iface: default, target: iqn.1992-08.com.netapp:sn.c8bdab770d1a11eeaea9bb21f0b8b056:vs.3, portal: 10.0.0.121,3260] successful.
Login to [iface: default, target: iqn.1992-08.com.netapp:sn.c8bdab770d1a11eeaea9bb21f0b8b056:vs.3, portal: 10.0.0.121,3260] successful.

マルチパスの状態を見ると、iSCSI セッションを識別してマージしたことが確認できます。

$ sudo multipath -ll
3600a09806c574230673f55744a346669 dm-0 NETAPP  ,LUN C-Mode
size=10K features='4 queue_if_no_path pg_init_retries 50 retain_attached_hw_handle' hwhandler='0' wp=rw
|-+- policy='service-time 0' prio=50 status=active
| |- 4:0:0:1 sdd  8:48  active ready running
| |- 2:0:0:1 sdb  8:16  active ready running
| `- 5:0:0:1 sdc  8:32  active ready running
`-+- policy='service-time 0' prio=10 status=enabled
  |- 6:0:0:1 sdf  8:80  active ready running
  |- 7:0:0:1 sde  8:64  active ready running
  |- 8:0:0:1 sdg  8:96  active ready running
  `- 9:0:0:1 sdh  8:112 active ready running

ブロックデバイスとしても認識されています。

$ lsblk
NAME                                MAJ:MIN RM SIZE RO TYPE  MOUNTPOINT
sda                                   8:0    0  10K  0 disk
sdb                                   8:16   0  10K  0 disk
└─3600a09806c574230673f55744a346669 253:0    0  10K  0 mpath
sdc                                   8:32   0  10K  0 disk
└─3600a09806c574230673f55744a346669 253:0    0  10K  0 mpath
sdd                                   8:48   0  10K  0 disk
└─3600a09806c574230673f55744a346669 253:0    0  10K  0 mpath
sde                                   8:64   0  10K  0 disk
└─3600a09806c574230673f55744a346669 253:0    0  10K  0 mpath
sdf                                   8:80   0  10K  0 disk
└─3600a09806c574230673f55744a346669 253:0    0  10K  0 mpath
sdg                                   8:96   0  10K  0 disk
└─3600a09806c574230673f55744a346669 253:0    0  10K  0 mpath
sdh                                   8:112  0  10K  0 disk
└─3600a09806c574230673f55744a346669 253:0    0  10K  0 mpath
xvda                                202:0    0   8G  0 disk
└─xvda1                             202:1    0   8G  0 part  /

以上が iSCSI LUN を Linux で認識させるまでの作業になります。

まとめ

NetAppは昔よく触っていたのですが、AWSで使えるようになったのでリハビリがてら触ってみました。

仕事で使う機会があまりなさそうですが、ONTAPのコマンドとかは結構面白いので、ボリューム拡張したり、スナップショット取ったり、いろんなものを破壊したり、今後も色々試してみようと思います。

今回はここまで! ありがとうございました!!!

参考文献

27
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
27
0