LoginSignup
2
3

More than 5 years have passed since last update.

Azure FilesをLinuxからマウントできないときのセルフトラブルシューティングツール(和訳)

Posted at

色々な理由でAzure FilesをLinuxにマウントできないとき、まずは以下のサイトを見て簡単にトラブルシューティングをすると思う。

Linux での Azure Files に関する問題のトラブルシューティング
Linux で Azure Files を使用する

一方で、TechNetにこんなツールがあるのだが全部英語なので、せっかくなので和訳紹介する。
Troubleshooting tool for Azure Files mounting errors on Linux

■環境
Red Hat Enterprise Linux Server release 7.3 (Maipo)

まずはダウンロードしてみる

# wget https://gallery.technet.microsoft.com/Troubleshooting-tool-for-02184089/file/179416/2/AzureFileDiagnostics.sh

ダウンロードしたシェルを実行してみる

# bash ./AzureFileDiagnostics.sh

2018-06-20T08:40:56.643Z Checking: Create a folder MSFileMountDiagLog to save the script output

2018-06-20T08:40:56.661Z Checking: Client running with "Red Hat Enterprise Linux Server" version 7.3, kernel version is 3.10.0-514.28.1.el7.x86_64

2018-06-20T08:40:56.663Z Checking: Check if cifs-utils is installed
2018-06-20T08:40:56.665Z Error: Cifs-utils module is not installed on this client, please refer to https://docs.microsoft.com/en-us/azure/storage/files/storage-how-to-use-files-linux#prerequisities-for-mounting-an-azure-file-share-with-linux-and-the-cifs-utils-package for more information

早速怒られた。
このように、スクリプトを実行することで何故Azure Filesをマウントできないか教えてくれる。

もう少し使ってみよう。まずは、正常にマウントできるシナリオでちゃんとマウントしてくれるか。
今度は、以下のコマンドで必要パッケージはインストールしてある。

# sudo yum install samba-client samba-common cifs-utils

いざ。適宜和訳する。

# bash ./AzureFileDiagnostics.sh

# MSFileMountDiagLogという名前のフォルダにログが出力されている
2018-06-20T08:43:24.661Z Checking: Create a folder MSFileMountDiagLog to save the script output

# 環境情報の確認
2018-06-20T08:43:24.673Z Checking: Client running with "Red Hat Enterprise Linux Server" version 7.3, kernel version is 3.10.0-514.28.1.el7.x86_64

# 先ほど怒られた、必要パッケージの導入を確認している
2018-06-20T08:43:24.675Z Checking: Check if cifs-utils is installed
2018-06-20T08:43:24.677Z Cifs-utils is already installed on this client

# 仮想マシンがSMB2.1をサポートしているかを確認している
2018-06-20T08:43:24.679Z Checking: Check if client has at least SMB2.1 support
2018-06-20T08:43:24.683Z System supports SMB2.1

# 仮想マシンがSMB 3の暗号化をサポートしているか確認している。
# [安全な転送が必須]がストレージ アカウントで有効になっている場合、Azure Files は暗号化付き SMB 3.0 を使った接続のみを許可するので注意。
2018-06-20T08:43:24.685Z Checking: Check if client has SMB 3 Encryption support
# この仮想マシンはSMB 3の暗号化をサポートしていないようだ
2018-06-20T08:43:24.691Z Warning: System DOES NOT support SMB 3 Encryption

# 既知のタイムアウトバグを引くカーネルバージョンかどうかを確認している。
2018-06-20T08:43:24.693Z Checking: Check if client has been patched with the recommended kernel update for idle timeout issue
# 今回は合致してしまっている模様。
2018-06-20T08:43:24.700Z Warning: Kernel has not been patched with the fixes that prevent idle timeout issues, more information, please refer to https://docs.microsoft.com/en-us/azure/storage/storage-troubleshoot-linux-file-connection-problems#mount-error112-host-is-down-because-of-a-reconnection-time-out

# ストレージアカウントとの接続に問題ないかを調べてくれるとのこと。
2018-06-20T08:43:24.701Z Checking: Check if client has any connectivity issue with storage account
# ストレージアカウント名の入力を求められている
2018-06-20T08:43:24.703Z Type the storage account name, followed by [ENTER]:
[ストレージアカウント名]
# 共有名の入力を求められている
2018-06-20T08:43:53.266Z Type the share name, followed by [ENTER]:
[共有名]
# どの環境のAzureかを聞かれている。基本的には"1"でOK。
2018-06-20T08:43:56.729Z Choose the Azure Environment:
1) azurecloud         3) azuregermancloud
2) azurechinacloud    4) azureusgovernment
Please enter your choice: 1
2018-06-20T08:43:59.410Z Storage account FQDN is [ストレージアカウント名].file.core.windows.net
# IPtablesで防がれないか確認
2018-06-20T08:43:59.412Z Getting the Iptables policies
# アウトバウンドの445番ポートは開いているようだ
2018-06-20T08:43:59.429Z Test the storage account IP connectivity over TCP port 445
2018-06-20T08:43:59.453Z Port 445 is reachable from this client.

# SMB3は使えないので、スクリプトを実行する仮想マシンがストレージアカウントと同一リージョンのAzure VMかを確認している
2018-06-20T08:43:59.456Z Checking: Client does not support SMB Encyrption, verify if client is in the same region as Stoage Account
# ストレージアカウントと同一リージョンのAzure VMだ。
2018-06-20T08:44:00.347Z Client is Azure VM and running in region ukwest
2018-06-20T08:44:00.377Z Storage account region is ukwest

# 当スクリプトがファイル共有をマウントしても良いかを聞かれる。問題ないので1を選択。
2018-06-20T08:44:00.380Z Checking: Script has validated the client settings and do you want to map drive by script?
1) yes
2) no
Please enter your choice: 1

# 診断ログを取っても良いかを聞かれる。問題ないので1を選択。
2018-06-20T08:44:03.202Z Checking: Do you want to tun on diagnostics logs
1) yes
2) no
Please enter your choice: 1

# どのローカルマウントポイントにマウントするか聞かれる。作ってなかったが、とりあえず入力。
2018-06-20T08:44:07.370Z Checking: type the local mount point, followed by [ENTER]:
/share
# なんと、勝手に作ってくれる。
2018-06-20T08:44:15.955Z mount point /share does not exist, create it now

# ストレージアカウントのアクセスキーの入力を求められる。
2018-06-20T08:44:15.958Z Checking: Type the storage account access key, followed by [ENTER]:
[ストレージアカウントキー]

# マウントできるかのテストが始まる。
2018-06-20T08:44:28.982Z Checking: Try with mounting share using SMB3.0
2018-06-20T08:44:28.985Z mount -t cifs //[ストレージアカウント名].file.core.windows.net/[共有名]  /share -o vers=3.0,username=[ストレージアカウント名],password='[ストレージアカウントキー]',dir_mode=0777,file_mode=0777,sec=ntlmssp
# 成功したようだ
2018-06-20T08:44:29.154Z Mounting share succeeds
2018-06-20T08:44:30.240Z Packet trace/CIFS debugging logs can be found in MSFileMountDiagLog folder

このように、かなり丁寧にデバッグしてくれる。ちゃんとログも出ている。

# ls ./MSFileMountDiagLog/
azurepubliciprange.xml  cifs.txt  download.html  firewall-before.txt  output.txt  packet.cap

パケットキャプチャまで取られているので、失敗したときは原因をしっかり見てくれそうだ。

失敗例として、[安全な転送が必須]を有効にしてみる。SMB 3の暗号化が有効ではないから失敗するはず。
image.png

いざ。

# bash ./AzureFileDiagnostics.sh

#中略

# マウントできるかのテストが始まる。
2018-06-20T09:05:50.623Z Checking: Try with mounting share using SMB3.0
2018-06-20T09:05:50.625Z mount -t cifs //[ストレージアカウント名].file.core.windows.net/[共有名]  /share -o vers=3.0,username=[ストレージアカウント名],password='[ストレージアカウントキー]',dir_mode=0777,file_mode=0777,sec=ntlmssp
# 仮想マシンが暗号化されたSMB3が有効でないため、失敗する
mount error(13): Permission denied
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)

# 今度はSMB2.1でマウントできるかテストされる。
2018-06-20T09:05:50.721Z Checking: Try with mounting share using SMB2.1
2018-06-20T09:05:50.724Z mount -t cifs //[ストレージアカウント名].file.core.windows.net/[共有名]  /share -o vers=2.1,username=[ストレージアカウント名],password='[ストレージアカウントキー]',dir_mode=0777,file_mode=0777,sec=ntlmssp
# [安全な転送が必須]が有効なため、SMB2.1ではマウントできず失敗となる
mount error(13): Permission denied
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
2018-06-20T09:05:50.807Z Error: Mounting share fails
2018-06-20T09:05:51.858Z Packet trace/CIFS debugging logs can be found in MSFileMountDiagLog folder

このように、ツールを使えば自分でもデバッグができるので便利。
下記のように対話式で入力するのを軽減するオプションもあるよう。

オプション 意味
-u Azure File共有のパス(例: storageaccount.file.core.windows.net\sharename )
-a ストレージアカウント名
-s 共有名
-e Azure環境。通常はAzureCloudでOK。

また、スクリプトのドキュメントには確認される事項として以下が挙げられている。

• 仮想マシンのディストリビューション。なお、推奨は以下の模様。
Ubuntu Server 14.04+ | RHEL 7+ | CentOS 7+ | Debian 8 | openSUSE 13.2+ | SUSE Linux Enterprise Server 12

•CIFSパッケージが導入されているか

•SMB/CIFS2.1が仮想マシンでサポートされているか

•SMB3の暗号化がサポートされているか。Ubuntu16.4+およびSUSE 12.3+では既に組み込まれていて、その他のディストリビューションではkernel 4.11以上であることが必要。

•既知のタイムアウトバグを引くカーネルバージョンか

•ストレージアカウントへTCP 445番で接続できるか。もしfirewall ruleで拒否された場合はIPtablesのダンプが取得される。

•SMB3は使えないので、スクリプトを実行する仮想マシンがストレージアカウントと同一リージョンのAzure VMか

•上記すべての確認で問題ない場合、ユーザの代わりにマウントを行う。ユーザが設定すれば、CIFSトレースやパケットキャプチャを取得する。

2
3
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
2
3