これはどこかで答えられているかもしれませんが、私はまだ見つけていません。
ログ ファイルを Hadoop クラスタに移動するために使用したい単純なシェル スクリプトがあります。このスクリプトは、Logrotate によって毎日呼び出されます。
次のエラーで失敗します: "/user/qradar: `/user/qradar' を開けません (そのようなファイルまたはディレクトリはありません)"。
#!/bin/bash
#use today's date and time
day=$(date +%Y-%m-%d)
#change to log directory
cd /var/log/qradar
#move and add time date to file name
mv qradar.log qradar$day.log
#load file into variable
#copy file from local to hdfs cluster
if [ -f qradar$day.log ]
then
file=qradar$day.log
hadoop dfs -put /var/log/qradar/&file /user/qradar
else
echo "failed to rename and move the file into the cluster" >> /var/log/messages
fi
ディレクトリ /user/qradar は存在し、Hadoop ファイル コマンドで一覧表示できます。Hadoop ファイル コマンドを使用して、ファイルを正しいディレクトリに手動で移動することもできます。この方法でファイルをクラスターに移動できますか? より良い方法はありますか?
どんな考えやコメントも大歓迎です。ありがとう