hadoop 3.1.2 ./start-all.sh错误,意外令牌'<'附近的语法错误

时间:2019-05-14 12:35:44

标签: hadoop namenode

我在Mac上运行hadoop 3.1.2,执行./start-all.sh时,出现错误提示

Starting namenodes on [localhost]
/usr/local/Cellar/hadoop/3.1.2/libexec/bin/../libexec/hadoop-functions.sh: line 398: syntax error near unexpected token `<'
/usr/local/Cellar/hadoop/3.1.2/libexec/bin/../libexec/hadoop-functions.sh: line 398: `  done < <(for text in "${input[@]}"; do'
/usr/local/Cellar/hadoop/3.1.2/libexec/bin/../libexec/hadoop-config.sh: line 70: hadoop_deprecate_envvar: command not found
/usr/local/Cellar/hadoop/3.1.2/libexec/bin/../libexec/hadoop-config.sh: line 87: hadoop_bootstrap: command not found
/usr/local/Cellar/hadoop/3.1.2/libexec/bin/../libexec/hadoop-config.sh: line 104: hadoop_parse_args: command not found
/usr/local/Cellar/hadoop/3.1.2/libexec/bin/../libexec/hadoop-config.sh: line 105: shift: : numeric argument required
/usr/local/Cellar/hadoop/3.1.2/libexec/bin/../libexec/hadoop-config.sh: line 244: hadoop_need_reexec: command not found
/usr/local/Cellar/hadoop/3.1.2/libexec/bin/../libexec/hadoop-config.sh: line 252: hadoop_verify_user_perm: command not found

我打开hadoop-functions.sh并在第398行中找到以下信息:

done < <(for text in "${input[@]}"; do
    echo "${text}"
  done | sort)

有什么解决办法吗?

1 个答案:

答案 0 :(得分:1)

您发现了一个错误,尽管该错误不太可能很快得到解决。 MacOS运行bash 3.x,但是此语法在运行bash版本4.x的大多数现代Linux上都适用。

根据Bash Manual:Process Substitution <(cmd(s)被视为文件,因此您可以将其解释为:

for text in "${input[@]}"; do
  echo "${text}"
done | sort > /tmp/results

while read -r line; do
  tmpa[${counter}]=${line}
  ((counter=counter+1))
  IFS='@' read -ra brup <<< "${line}"
  option="${brup[0]}"
  if [[ ${#option} -gt ${maxoptsize} ]]; then
    maxoptsize=${#option}
  fi
done < /tmp/results

您的选择是:

  • 安装更高版本的bash
  • 在hadoop-functions.sh中重写< <(的2个实例,这是您遇到此构造的唯一实例。

参考文献