我的bash脚本中有以下几行内容,以便修复HDFS中的复制文件
su hdfs -c "hdfs fsck / | grep 'Under replicated' | awk -F':' '{print \$1}' > /tmp/under_replicated_files"
su hdfs -c "for hdfsfile in `cat /tmp/under_replicated_files`; do echo "Fixing $hdfsfile :" ; hadoop fs -setrep 3 $hdfsfile; done"
脚本运行失败
: ; hadoop fs -setrep 3 ; done: -c: line 1: syntax error near unexpected token `/user/ambari-qa/.staging/job_1571913174208_0001/job.split'
: ; hadoop fs -setrep 3 ; done: -c: line 1: `/user/ambari-qa/.staging/job_1571913174208_0001/job.split'
文件/tmp/under_replicated_files
包含:
/user/ambari-qa/.staging/job_1571913174208_0001/job.jar
/user/ambari-qa/.staging/job_1571913174208_0001/job.split
/user/ambari-qa/.staging/job_1571913174208_0003/job.jar
我在以下行中错了吗?
su hdfs -c "for hdfsfile in `cat /tmp/under_replicated_files`; do echo "Fixing $hdfsfile :" ; hadoop fs -setrep 3 $hdfsfile; done"
注意:
当我执行用户-hdfs
的相同步骤的步骤时,我们没有任何问题
示例:
su hdfs
$ hdfs fsck / | grep 'Under replicated' | awk -F':' '{print $1}' > /tmp/under_replicated_files
$ for hdfsfile in `cat /tmp/under_replicated_files`; do echo "Fixing $hdfsfile :" ; hadoop fs -setrep 3 $hdfsfile; done
我们也尝试过
su hdfs -c "for hdfsfile in `cat /tmp/under_replicated_files`; do echo \"Fixing $hdfsfile :\" ; hadoop fs -setrep 3 $hdfsfile; done"
但我们得到:
bash: -c: line 1: syntax error near unexpected token `/user/ambari-qa/.staging/job_1571913174208_0001/job.split'
bash: -c: line 1: `/user/ambari-qa/.staging/job_1571913174208_0001/job.split'