【问题标题】:hadoop 3.1.2 ./start-all.sh error, syntax error near unexpected token `<'hadoop 3.1.2 ./start-all.sh 错误,意外标记 `<' 附近的语法错误
【发布时间】:2019-05-14 12:35:43
【问题描述】:

我在 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)

知道如何解决这个问题吗?

【问题讨论】:

  • 这看起来像一个错误。您是如何安装 Hadoop 的?
  • brew install hadoop @tk421
  • 我认为是bug,我可以分别启动name node和data node,但是不能使用start-all.sh或者start yarn @tk421
  • 是的,我深入研究了代码库,并且已经存在了一段时间。这是 bash 的不兼容,MacOS 的 bash 版本是 3.x,而大多数 Linux 运行的是 bash 4.x。
  • 看来古版 bash 是由于apple.stackexchange.com/questions/193411/….

标签: hadoop namenode


【解决方案1】:

您发现了一个错误,尽管它不太可能很快得到解决。 MacOS 运行 bash 3.x,但这种语法适用于大多数现代 Linux,它们运行 bash 4.x 版本。

根据Bash Manual:Process Substitution &lt;(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 中重写 &lt; &lt;( 的 2 个实例,这是您遇到此构造的唯一实例。

参考文献

【讨论】:

    猜你喜欢
    • 2019-12-16
    • 2012-08-31
    • 2012-10-20
    • 2012-09-29
    • 2013-12-11
    • 1970-01-01
    • 1970-01-01
    • 2014-08-30
    相关资源
    最近更新 更多