Hadoop-cos-DistCheckerは、移行したディレクトリの整合性を検証するためのツールです。ユーザーがhadoop distcp
コマンドを使用してHDFSからCOSにデータを移行した後、MapReduceの並列機能に基づいて、Hadoop-cos-DistCheckerツールはソースディレクトリとターゲットディレクトリ間の検証比較をすばやく実行することができます。
注意:
- 自分でHadoopクラスターをビルドする場合、CRC64チェックデジットの取得をサポートするため、Hadoop-cos依存関係を最新バージョン(GitHub releaseバージョンは5.8.2以降)にする必要があります。
- Tencent Cloud EMRスイートを使用している場合、2020年5月8日以降に作成されたクラスターには、このHadoop-cosバージョンのみが含まれます。それ以前に作成されたクラスターについては、チケットを提出してお問い合わせください。
Hadoop-cos-distcheckerは、Hadoop-cos(CosNファイルシステム)内のファイルのCRC64チェックサムを取得する必要があるため、ツールを実行する前に、設定項目fs.cosn.crc64.checksum.enabled をtrueに設定して、Hadoop-cosファイルのCRC64チェックサムの取得をサポートする必要があります。ツールの実行が完了したら、このオプションをfalseに戻し、CRC64チェックサムの取得を無効にします。
注意:Hadoop-COSでサポートされているCRC64チェックサムはHDFSファイルシステムのCRC32Cチェックサムと互換性がないため、このツールを使用した後は、必ず上記の設定項目を無効状態に戻してください。戻さない場合、Hadoop-cosがファイルシステムのgetFileChecksumインターフェースが呼び出されるシナリオによっては、実行が失敗する恐れがあります。
ソースファイルリスト:ソースファイルパスリストとは、ユーザーが以下のコマンドを実行してエクスポートしたチェック対象のサブディレクトリとファイルのリストです。
hadoop fs -ls -R hdfs://host:port/{source_dir} | awk '{print $8}' > check_list.txt
形式の例は次のとおりです。
/benchmarks/TestDFSIO
/benchmarks/TestDFSIO/io_control
/benchmarks/TestDFSIO/io_control/in_file_test_io_0
/benchmarks/TestDFSIO/io_control/in_file_test_io_1
/benchmarks/TestDFSIO/io_data
/benchmarks/TestDFSIO/io_data/test_io_0
/benchmarks/TestDFSIO/io_data/test_io_1
/benchmarks/TestDFSIO/io_write
/benchmarks/TestDFSIO/io_write/_SUCCESS
/benchmarks/TestDFSIO/io_write/part-00000
ソースディレクトリ:ソースファイルのリストがあるディレクトリを指します。このディレクトリは通常、データを移行する際のdistcp
コマンドのソースパスにもなります。次に示すように、hdfs://host:port/source_dir
はソースディレクトリです。
hadoop distcp hdfs://host:port/source_dir cosn://examplebucket-appid/dest_dir
さらに、このパスはソースファイルパスリストの共通の親ディレクトリでもあります。例えば、上記のソースファイルリスト共通の親ディレクトリは、/benchmarks
です。
ターゲットディレクトリ:比較するターゲットディレクトリです。
Hadoop-cos-DistCheckerは、MapReduceジョブプログラムです。MapReduceジョブの送信プロセスに従えばOKです。
hadoop jar hadoop-cos-distchecker-2.8.5-1.0-SNAPSHOT.jar com.qcloud.cos.hadoop.distchecker.App <ソースファイルリストの絶対パス> <ソースディレクトリの絶対パス表現> <ターゲットディレクトリの絶対パス表現> [optional parameters]
説明:Optional parametersは、Hadoopのオプションパラメータを示します。
以下では、ツールの使用手順を紹介する例として、 hdfs://10.0.0.3:9000/benchmarks
とcosn://hdfs-test-1250000000/benchmarks
のチェックを例として取り上げます。
まず、次のコマンドを実行します。
hadoop fs -ls -R hdfs://10.0.0.3:9000/benchmarks | awk '{print $8}' > check_list.txt
次のように、チェックするソースパスをcheck_list.txtファイルにエクスポートします。このファイルには、ソースファイルのパスリストが格納されています。
次に、check_list.txtをHDFSに入れて、次のように実行します。
hadoop fs -put check_list.txt hdfs://10.0.0.3:9000/
最後に、Hadoop-cos-DistCheckerを実行し、hdfs://10.0.0.3:9000/benchmarks
とcosn://hdfs-test-1250000000/benchmarks
を比較して、出力結果をcosn://hdfs-test-1250000000/check_result
のパスに保存します。コマンド形式は次のとおりです。
hadoop jar hadoop-cos-distchecker-2.8.5-1.0-SNAPSHOT.jar com.qcloud.cos.hadoop.distchecker.App hdfs://10.0.0.3:9000/check_list.txt hdfs://10.0.0.3:9000/benchmarks cosn://hdfs-test-1250000000/benchmarks cosn://hdfs-test-1250000000/check_result
Hadoop-cos-DistCheckerは、ソースファイルリストとソースディレクトリを読み込み、MapReduceジョブを実行して分散チェックを行い、最終的なチェックレポートをcosn://examplebucket-appid/check_result
パスに出力します。
チェックレポートは次のとおりです。
hdfs://10.0.0.3:9000/benchmarks/TestDFSIO hdfs://10.0.0.3:9000/benchmarks/TestDFSIO,cosn://hdfs-test-1250000000/benchmarks/TestDFSIO,None,None,None,SUCCESS,'The source file and the target file are the same.'
hdfs://10.0.0.3:9000/benchmarks/TestDFSIO/io_control hdfs://10.0.0.3:9000/benchmarks/TestDFSIO/io_control,cosn://hdfs-test-1250000000/benchmarks/TestDFSIO/io_control,None,None,None,SUCCESS,'The source file and the target file are the same.'
hdfs://10.0.0.3:9000/benchmarks/TestDFSIO/io_control/in_file_test_io_0 hdfs://10.0.0.3:9000/benchmarks/TestDFSIO/io_control/in_file_test_io_0,cosn://hdfs-test-1250000000/benchmarks/TestDFSIO/io_control/in_file_test_io_0,CRC64,1566310986176587838,1566310986176587838,SUCCESS,'The source file and the target file are the same.'
hdfs://10.0.0.3:9000/benchmarks/TestDFSIO/io_control/in_file_test_io_1 hdfs://10.0.0.3:9000/benchmarks/TestDFSIO/io_control/in_file_test_io_1,cosn://hdfs-test-1250000000/benchmarks/TestDFSIO/io_control/in_file_test_io_1,CRC64,-6584441696534676125,-6584441696534676125,SUCCESS,'The source file and the target file are the same.'
hdfs://10.0.0.3:9000/benchmarks/TestDFSIO/io_data hdfs://10.0.0.3:9000/benchmarks/TestDFSIO/io_data,cosn://hdfs-test-1250000000/benchmarks/TestDFSIO/io_data,None,None,None,SUCCESS,'The source file and the target file are the same.'
hdfs://10.0.0.3:9000/benchmarks/TestDFSIO/io_data/test_io_0 hdfs://10.0.0.3:9000/benchmarks/TestDFSIO/io_data/test_io_0,cosn://hdfs-test-1250000000/benchmarks/TestDFSIO/io_data/test_io_0,CRC64,3534425600523290380,3534425600523290380,SUCCESS,'The source file and the target file are the same.'
hdfs://10.0.0.3:9000/benchmarks/TestDFSIO/io_data/test_io_1 hdfs://10.0.0.3:9000/benchmarks/TestDFSIO/io_data/test_io_1,cosn://hdfs-test-1250000000/benchmarks/TestDFSIO/io_data/test_io_1,CRC64,3534425600523290380,3534425600523290380,SUCCESS,'The source file and the target file are the same.'
hdfs://10.0.0.3:9000/benchmarks/TestDFSIO/io_write hdfs://10.0.0.3:9000/benchmarks/TestDFSIO/io_write,cosn://hdfs-test-1250000000/benchmarks/TestDFSIO/io_write,None,None,None,SUCCESS,'The source file and the target file are the same.'
hdfs://10.0.0.3:9000/benchmarks/TestDFSIO/io_write/_SUCCESS hdfs://10.0.0.3:9000/benchmarks/TestDFSIO/io_write/_SUCCESS,cosn://hdfs-test-1250000000/benchmarks/TestDFSIO/io_write/_SUCCESS,CRC64,0,0,SUCCESS,'The source file and the target file are the same.'
hdfs://10.0.0.3:9000/benchmarks/TestDFSIO/io_write/part-00000 hdfs://10.0.0.3:9000/benchmarks/TestDFSIO/io_write/part-00000,cosn://hdfs-test-1250000000/benchmarks/TestDFSIO/io_write/part-00000,CRC64,-4804567387993776854,-4804567387993776854,SUCCESS,'The source file and the target file are the same.'
チェックレポートは、次のような形式で表示されます。
check_list.txtのソースファイルパス、ソースファイルの絶対パス、ターゲットファイルの絶対パス、Checksumアルゴリズム、ソースファイルのchecksum値、ターゲットファイルのchecksum値、チェック結果、チェック結果の説明
これらのチェック結果は、以下7つのカテゴリーに分類されます。
CRC64の値が20ビットの値である可能性があり、Java long型の表現できる範囲を超えていますが、基になるバイトは同じであるため、long型をダンプすると負の数が表示されます。
この記事はお役に立ちましたか?