這可能已在某處解決,但我還沒有找到它。用於將文件移入hadoop羣集的shell腳本
我有一個簡單的shell腳本,我想用它將日誌文件移動到我的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文件命令手動將文件移動到正確的目錄中。我能以這種方式將文件移入羣集嗎?有沒有更好的辦法?
歡迎任何想法和意見。 謝謝
#change登錄目錄 CD /無功/日誌 qradar.log駐留在/ var /日誌 –