这个问题可能已经在某个地方得到了回答,但我还没有找到它。
我有一个简单的shell脚本,我想使用它将日志文件移动到我的Hadoop集群中。该脚本将由Logrotate每天调用。
失败,错误如下:"/user/qradar:无法打开`/user/ the‘(没有这样的文件或目录)“。
#!/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/ can确实存在,可以使用Hadoop文件命令列出该目录。我还可以使用Hadoop文件命令手动将文件移动到正确的目录中。我可以通过这种方式将文件移动到集群中吗?有没有更好的方法?
欢迎任何想法和评论。谢谢
发布于 2012-10-09 07:11:27
hadoop dfs -put行中的&file是不是打错了?
如果不是,那么这可能是您的问题,您正在后台运行命令hadoop dfs -put /var/log/qradar/ (与号在后台运行命令),然后运行命令file /user/qradar,shell正在本地路径上查找该命令。
我猜你指的是以下内容(美元而不是和符号):
hadoop dfs -put /var/log/qradar/$file /user/qradarhttps://stackoverflow.com/questions/12790166
复制相似问题