この記事では、Azure HPC Cache で使用するために BLOB ストレージ コンテナーにデータを手動でコピーする方法について詳しく説明します。 マルチスレッドの並列操作を使用して、コピー速度を最適化します。
Azure HPC Cache の Blob Storage へのデータの移動の詳細については、「Azure Blob Storage へのデータの移動」を参照してください。
単純なコピーの例
定義済みのファイルまたはパスのセットに対して複数のコピー コマンドをバックグラウンドで一度に実行することで、クライアントでマルチスレッド コピーを手動で作成できます。
Linux/UNIX cp コマンドには、所有権と mtime メタデータを保持するための引数 -p が含まれています。 次のコマンドにこの引数を追加することは省略可能です。 (引数を追加すると、メタデータを変更するためにクライアントから宛先ファイル システムに送信されるファイル システム呼び出しの数が増えます)。
この簡単な例では、2 つのファイルを並列コピーします。
cp /mnt/source/file1 /mnt/destination1/ & cp /mnt/source/file2 /mnt/destination1/ &
このコマンドを発行すると、 jobs コマンドは 2 つのスレッドが実行されていることを示します。
予測可能なファイル名を使用してデータをコピーする
ファイル名が予測可能な場合は、式を使用して並列コピー スレッドを作成できます。
たとえば、ディレクトリに、 0001 から 1000に順番に番号が付けられている 1000 個のファイルが含まれている場合は、次の式を使用して、各 100 ファイルをコピーする 10 個の並列スレッドを作成できます。
cp /mnt/source/file0* /mnt/destination1/ & \
cp /mnt/source/file1* /mnt/destination1/ & \
cp /mnt/source/file2* /mnt/destination1/ & \
cp /mnt/source/file3* /mnt/destination1/ & \
cp /mnt/source/file4* /mnt/destination1/ & \
cp /mnt/source/file5* /mnt/destination1/ & \
cp /mnt/source/file6* /mnt/destination1/ & \
cp /mnt/source/file7* /mnt/destination1/ & \
cp /mnt/source/file8* /mnt/destination1/ & \
cp /mnt/source/file9* /mnt/destination1/
非構造化ファイル名を使用してデータをコピーする
ファイルの名前付け構造が予測できない場合は、ディレクトリ名でファイルをグループ化できます。
この例では、バックグラウンド タスクとして実行 cp コマンドに送信するディレクトリ全体を収集します。
/root
|-/dir1
| |-/dir1a
| |-/dir1b
| |-/dir1c
|-/dir1c1
|-/dir1d
ファイルが収集されたら、並列コピー コマンドを実行して、サブディレクトリとそのすべての内容を再帰的にコピーできます。
cp /mnt/source/* /mnt/destination/
mkdir -p /mnt/destination/dir1 && cp /mnt/source/dir1/* mnt/destination/dir1/ &
cp -R /mnt/source/dir1/dir1a /mnt/destination/dir1/ &
cp -R /mnt/source/dir1/dir1b /mnt/destination/dir1/ &
cp -R /mnt/source/dir1/dir1c /mnt/destination/dir1/ & # this command copies dir1c1 via recursion
cp -R /mnt/source/dir1/dir1d /mnt/destination/dir1/ &
マウント ポイントを追加するタイミング
1 つの宛先ファイル システムマウント ポイントに対して十分な並列スレッドが発生すると、スレッドを追加してもスループットが向上しない点があります。 (スループットは、データの種類に応じて、ファイル/秒またはバイト/秒で測定されます)。さらに悪いことに、過剰なスレッド処理がスループットの低下を引き起こす可能性があります。
この場合、同じリモート ファイル システム マウント パスを使用して、クライアント側マウント ポイントを他の Azure HPC Cache マウント アドレスに追加できます。
10.1.0.100:/nfs on /mnt/sourcetype nfs (rw,vers=3,proto=tcp,addr=10.1.0.100)
10.1.1.101:/nfs on /mnt/destination1type nfs (rw,vers=3,proto=tcp,addr=10.1.1.101)
10.1.1.102:/nfs on /mnt/destination2type nfs (rw,vers=3,proto=tcp,addr=10.1.1.102)
10.1.1.103:/nfs on /mnt/destination3type nfs (rw,vers=3,proto=tcp,addr=10.1.1.103)
クライアント側のマウント ポイントを追加すると、追加のコピー コマンドを追加の /mnt/destination[1-3] マウント ポイントにフォークして、さらに並列処理を実現できます。
たとえば、ファイルが非常に大きい場合は、個別の宛先パスを使用するようにコピー コマンドを定義し、コピーを実行するクライアントから複数のコマンドを並列で送信できます。
cp /mnt/source/file0* /mnt/destination1/ & \
cp /mnt/source/file1* /mnt/destination2/ & \
cp /mnt/source/file2* /mnt/destination3/ & \
cp /mnt/source/file3* /mnt/destination1/ & \
cp /mnt/source/file4* /mnt/destination2/ & \
cp /mnt/source/file5* /mnt/destination3/ & \
cp /mnt/source/file6* /mnt/destination1/ & \
cp /mnt/source/file7* /mnt/destination2/ & \
cp /mnt/source/file8* /mnt/destination3/ & \
上記の例では、3 つの宛先マウント ポイントすべてがクライアント ファイルコピープロセスの対象になっています。
クライアントを追加するタイミング
最後に、クライアントの能力に達すると、コピー スレッドやマウント ポイントを追加しても、ファイル/秒またはバイト/秒の増加は得られません。 このような状況では、独自のファイル コピー プロセスのセットを実行するマウント ポイントの同じセットを持つ別のクライアントを展開できます。
Example:
Client1: cp -R /mnt/source/dir1/dir1a /mnt/destination/dir1/ &
Client1: cp -R /mnt/source/dir2/dir2a /mnt/destination/dir2/ &
Client1: cp -R /mnt/source/dir3/dir3a /mnt/destination/dir3/ &
Client2: cp -R /mnt/source/dir1/dir1b /mnt/destination/dir1/ &
Client2: cp -R /mnt/source/dir2/dir2b /mnt/destination/dir2/ &
Client2: cp -R /mnt/source/dir3/dir3b /mnt/destination/dir3/ &
Client3: cp -R /mnt/source/dir1/dir1c /mnt/destination/dir1/ &
Client3: cp -R /mnt/source/dir2/dir2c /mnt/destination/dir2/ &
Client3: cp -R /mnt/source/dir3/dir3c /mnt/destination/dir3/ &
Client4: cp -R /mnt/source/dir1/dir1d /mnt/destination/dir1/ &
Client4: cp -R /mnt/source/dir2/dir2d /mnt/destination/dir2/ &
Client4: cp -R /mnt/source/dir3/dir3d /mnt/destination/dir3/ &
ファイル マニフェストを作成する
上記の方法 (宛先ごとに複数のコピー スレッド、クライアントごとに複数のコピー先、ネットワークアクセス可能なソース ファイル システムごとに複数のクライアント) を理解した後、次の推奨事項を検討してください。ファイル マニフェストをビルドしてから、複数のクライアント間でコピー コマンドで使用します。
このシナリオでは、UNIX find コマンドを使用して、ファイルまたはディレクトリのマニフェストを作成します。
user@build:/mnt/source > find . -mindepth 4 -maxdepth 4 -type d
./atj5b55c53be6-01/support/gsi/2018-07-22T21:12:06EDT
./atj5b55c53be6-01/support/pcap/2018-07-23T01:34:57UTC
./atj5b55c53be6-01/support/trace/rolling
./atj5b55c53be6-03/support/gsi/2018-07-22T21:12:06EDT
./atj5b55c53be6-03/support/pcap/2018-07-23T01:34:57UTC
./atj5b55c53be6-03/support/trace/rolling
./atj5b55c53be6-02/support/gsi/2018-07-22T21:12:06EDT
./atj5b55c53be6-02/support/pcap/2018-07-23T01:34:57UTC
./atj5b55c53be6-02/support/trace/rolling
この結果をファイルにリダイレクトします。 find . -mindepth 4 -maxdepth 4 -type d > /tmp/foo
その後、BASH コマンドを使用してファイルをカウントし、サブディレクトリのサイズを決定して、マニフェストを反復処理できます。
ben@xlcycl1:/sps/internal/atj5b5ab44b7f > for i in $(cat /tmp/foo); do echo " `find ${i} |wc -l` `du -sh ${i}`"; done
244 3.5M ./atj5b5ab44b7f-02/support/gsi/2018-07-18T00:07:03EDT
9 172K ./atj5b5ab44b7f-02/support/gsi/stats_2018-07-18T05:01:00UTC
124 5.8M ./atj5b5ab44b7f-02/support/gsi/stats_2018-07-19T01:01:01UTC
152 15M ./atj5b5ab44b7f-02/support/gsi/stats_2018-07-20T01:01:00UTC
131 13M ./atj5b5ab44b7f-02/support/gsi/stats_2018-07-20T21:59:41UTC_partial
789 6.2M ./atj5b5ab44b7f-02/support/gsi/2018-07-20T21:59:41UTC
134 12M ./atj5b5ab44b7f-02/support/gsi/stats_2018-07-20T22:22:55UTC_hpccache_catchup
7 16K ./atj5b5ab44b7f-02/support/pcap/2018-07-18T17:12:19UTC
8 83K ./atj5b5ab44b7f-02/support/pcap/2018-07-18T17:17:17UTC
575 7.7M ./atj5b5ab44b7f-02/support/cores/armada_main.2000.1531980253.gsi
33 4.4G ./atj5b5ab44b7f-02/support/trace/rolling
281 6.6M ./atj5b5ab44b7f-01/support/gsi/2018-07-18T00:07:03EDT
15 182K ./atj5b5ab44b7f-01/support/gsi/stats_2018-07-18T05:01:00UTC
244 17M ./atj5b5ab44b7f-01/support/gsi/stats_2018-07-19T01:01:01UTC
299 31M ./atj5b5ab44b7f-01/support/gsi/stats_2018-07-20T01:01:00UTC
256 29M ./atj5b5ab44b7f-01/support/gsi/stats_2018-07-20T21:59:41UTC_partial
889 7.7M ./atj5b5ab44b7f-01/support/gsi/2018-07-20T21:59:41UTC
262 29M ./atj5b5ab44b7f-01/support/gsi/stats_2018-07-20T22:22:55UTC_hpccache_catchup
11 248K ./atj5b5ab44b7f-01/support/pcap/2018-07-18T17:12:19UTC
11 88K ./atj5b5ab44b7f-01/support/pcap/2018-07-18T17:17:17UTC
645 11M ./atj5b5ab44b7f-01/support/cores/armada_main.2019.1531980253.gsi
33 4.0G ./atj5b5ab44b7f-01/support/trace/rolling
244 2.1M ./atj5b5ab44b7f-03/support/gsi/2018-07-18T00:07:03EDT
9 158K ./atj5b5ab44b7f-03/support/gsi/stats_2018-07-18T05:01:00UTC
124 5.3M ./atj5b5ab44b7f-03/support/gsi/stats_2018-07-19T01:01:01UTC
152 15M ./atj5b5ab44b7f-03/support/gsi/stats_2018-07-20T01:01:00UTC
131 12M ./atj5b5ab44b7f-03/support/gsi/stats_2018-07-20T21:59:41UTC_partial
789 8.4M ./atj5b5ab44b7f-03/support/gsi/2018-07-20T21:59:41UTC
134 14M ./atj5b5ab44b7f-03/support/gsi/stats_2018-07-20T22:25:58UTC_hpccache_catchup
7 159K ./atj5b5ab44b7f-03/support/pcap/2018-07-18T17:12:19UTC
7 157K ./atj5b5ab44b7f-03/support/pcap/2018-07-18T17:17:17UTC
576 12M ./atj5b5ab44b7f-03/support/cores/armada_main.2013.1531980253.gsi
33 2.8G ./atj5b5ab44b7f-03/support/trace/rolling
最後に、実際のファイル コピー コマンドをクライアントに作成する必要があります。
4 つのクライアントがある場合は、次のコマンドを使用します。
for i in 1 2 3 4 ; do sed -n ${i}~4p /tmp/foo > /tmp/client${i}; done
5 つのクライアントがある場合は、次のように使用します。
for i in 1 2 3 4 5; do sed -n ${i}~5p /tmp/foo > /tmp/client${i}; done
6 人の場合....必要に応じて推定します。
for i in 1 2 3 4 5 6; do sed -n ${i}~6p /tmp/foo > /tmp/client${i}; done
結果として得られる N 個のファイルは、 コマンドからの出力の一部として取得されたレベル 4 のディレクトリへのパス名を持つ find クライアントごとに 1 つずつ取得されます。
各ファイルを使用してコピー コマンドをビルドします。
for i in 1 2 3 4 5 6; do for j in $(cat /tmp/client${i}); do echo "cp -p -R /mnt/source/${j} /mnt/destination/${j}" >> /tmp/client${i}_copy_commands ; done; done
上記では、クライアントで BASH スクリプトとして実行できる N 個の ファイルが、それぞれ 1 行にコピー コマンドを含みます。
目標は、これらのスクリプトの複数のスレッドを複数のクライアントで並列にクライアントごとに同時に実行することです。