Hadoop:start-dfs.sh抛出语法错误

Hadoop:start-dfs.sh抛出语法错误,hadoop,Hadoop,我试图通过运行./start-dfs.sh来启动hadoop,但是我遇到了一些语法错误。有人能帮忙吗 Gurupads-MacBook-Air:sbin guru$ sudo ./start-dfs.sh Starting namenodes on [localhost] /Users/guru/homebrew/Cellar/hadoop/3.1.1/libexec/bin/../libexec/hadoop-functions.sh: line 398: syntax

我试图通过运行./start-dfs.sh来启动hadoop,但是我遇到了一些语法错误。有人能帮忙吗

    Gurupads-MacBook-Air:sbin guru$ sudo ./start-dfs.sh
    Starting namenodes on [localhost]
    /Users/guru/homebrew/Cellar/hadoop/3.1.1/libexec/bin/../libexec/hadoop-functions.sh: line 398: syntax error near unexpected token `<'
    /Users/guru/homebrew/Cellar/hadoop/3.1.1/libexec/bin/../libexec/hadoop-functions.sh: line 398: `  done < <(for text in "${input[@]}"; do'
    /Users/guru/homebrew/Cellar/hadoop/3.1.1/libexec/bin/../libexec/hadoop-config.sh: line 70: hadoop_deprecate_envvar: command not found
    /Users/guru/homebrew/Cellar/hadoop/3.1.1/libexec/bin/../libexec/hadoop-config.sh: line 87: hadoop_bootstrap: command not found
    /Users/guru/homebrew/Cellar/hadoop/3.1.1/libexec/bin/../libexec/hadoop-config.sh: line 104: hadoop_parse_args: command not found
    /Users/guru/homebrew/Cellar/hadoop/3.1.1/libexec/bin/../libexec/hadoop-config.sh: line 105: shift: : numeric argument required
    /Users/guru/homebrew/Cellar/hadoop/3.1.1/libexec/bin/../libexec/hadoop-config.sh: line 244: hadoop_need_reexec: command not found
    /Users/guru/homebrew/Cellar/hadoop/3.1.1/libexec/bin/../libexec/hadoop-config.sh: line 252: hadoop_verify_user_perm: command not found
    /Users/guru/homebrew/Cellar/hadoop/3.1.1/libexec/bin/hdfs: line 213: hadoop_validate_classname: command not found
    /Users/guru/homebrew/Cellar/hadoop/3.1.1/libexec/bin/hdfs: line 214: hadoop_exit_with_usage: command not found
    /Users/guru/homebrew/Cellar/hadoop/3.1.1/libexec/bin/../libexec/hadoop-config.sh: line 263: hadoop_add_client_opts: command not found
    /Users/guru/homebrew/Cellar/hadoop/3.1.1/libexec/bin/../libexec/hadoop-config.sh: line 270: hadoop_subcommand_opts: command not found
    /Users/guru/homebrew/Cellar/hadoop/3.1.1/libexec/bin/../libexec/hadoop-config.sh: line 273: hadoop_generic_java_subcmd_handler: command not found
    Starting datanodes
    ERROR: Attempting to operate on hdfs datanode as root
    ERROR: but there is no HDFS_DATANODE_USER defined. Aborting operation.
    Starting secondary namenodes [Gurupads-MacBook-Air.local]
    ERROR: Attempting to operate on hdfs secondarynamenode as root
    ERROR: but there is no HDFS_SECONDARYNAMENODE_USER defined. Aborting operation.
    2018-09-18 21:51:24,380 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Gurupads MacBook Air:sbin guru$sudo./start-dfs.sh
正在[localhost]上启动namenodes

/Users/guru/homebrew/ceral/hadoop/3.1.1/libexec/bin/./libexec/hadoop-functions.sh:第398行:意外标记附近的语法错误`错误表示,您正在以根用户身份运行
hdfs datanode
,并且没有定义
hdfs\u datanode\u user

解决方案:

通过在文件末尾添加以下行编辑
/Users/guru/homebrew/ceral/hadoop/3.1.1/etc/hadoop/hadoop env.sh
文件:

export HDFS_NAMENODE_USER=root
export HDFS_DATANODE_USER=root
export HDFS_SECONDARYNAMENODE_USER=root
如果您使用的是
纱线
,则可以在同一文件中添加以下行:

export YARN_RESOURCEMANAGER_USER=root
export YARN_NODEMANAGER_USER=root

使用
start dfs.sh
脚本重新启动hadoop。

请格式化您的答案,然后发布。