1

我正在构建一个由 2 个节点组成的小型 Hadoop 集群:1 个主节点 + 1 个工作节点。我正在使用最新版本的 Hadoop (3.2),一切都由root用户执行。在安装过程中,我已经能够hdfs namenode -format. 下一步是使用start-dfs.sh.

$ start-dfs.sh                  
Starting namenodes on [master]
bash v3.2+ is required. Sorry.
Starting datanodes
bash v3.2+ is required. Sorry.
Starting secondary namenodes [master]
bash v3.2+ is required. Sorry.

这是日志中生成的日志:

$ journalctl --since "1 min ago"
-- Logs begin at Thu 2019-08-29 11:12:27 CEST, end at Thu 2019-08-29 11:46:40 CEST. --
Aug 29 11:46:40 master su[3329]: (to root) root on pts/0
Aug 29 11:46:40 master su[3329]: pam_unix(su-l:session): session opened for user root by root(uid=0)
Aug 29 11:46:40 master su[3329]: pam_unix(su-l:session): session closed for user root
Aug 29 11:46:40 master su[3334]: (to root) root on pts/0
Aug 29 11:46:40 master su[3334]: pam_unix(su-l:session): session opened for user root by root(uid=0)
Aug 29 11:46:40 master su[3334]: pam_unix(su-l:session): session closed for user root
Aug 29 11:46:40 master su[3389]: (to root) root on pts/0
Aug 29 11:46:40 master su[3389]: pam_unix(su-l:session): session opened for user root by root(uid=0)
Aug 29 11:46:40 master su[3389]: pam_unix(su-l:session): session closed for user root

当我使用Zsh(使用Oh-my-Zsh)时,我登录到 bash 控制台试一试。可悲的是,我得到了同样的结果。实际上,所有sbin/start-*.sh脚本都会发生此错误。然而,hadoopandyarn命令就像一个魅力。

由于我在互联网上没有找到有关此错误的太多信息,所以我在这里。很高兴有任何建议!


其他技术细节

操作系统信息:

$ lsb_release -d
Description:    Debian GNU/Linux 10 (buster)

$ uname -srm       
Linux 4.19.0-5-amd64 x86_64

可用的 Java 版本(两者都试过):

$ update-alternatives --config java
There are 2 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                                Priority   Status
------------------------------------------------------------
  0            /usr/lib/jvm/java-11-openjdk-amd64/bin/java          1111      auto mode
* 1            /usr/lib/jvm/adoptopenjdk-8-hotspot-amd64/bin/java   1081      manual mode
  2            /usr/lib/jvm/java-11-openjdk-amd64/bin/java          1111      manual mode

您可能感兴趣的一些 ENV 变量:

$ env
USER=root
LOGNAME=root
HOME=/root
PATH=/root/bin:/usr/local/bin:/usr/local/hadoop/bin:/usr/local/hadoop/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
SHELL=/usr/bin/zsh
TERM=rxvt-unicode
JAVA_HOME=/usr/lib/jvm/adoptopenjdk-8-hotspot-amd64
HADOOP_HOME=/usr/local/hadoop
HADOOP_CONF_DIR=/usr/local/hadoop/etc/hadoop
ZSH=/root/.oh-my-zsh

Hadoop 可执行文件的输出:

$ hadoop version
Hadoop 3.2.0
Source code repository https://github.com/apache/hadoop.git -r e97acb3bd8f3befd27418996fa5d4b50bf2e17bf
Compiled by sunilg on 2019-01-08T06:08Z
Compiled with protoc 2.5.0
From source with checksum d3f0795ed0d9dc378e2c785d3668f39
This command was run using /usr/local/hadoop/share/hadoop/common/hadoop-common-3.2.0.jar

我的 Zsh 和 Bash 安装:

$ zsh --version
zsh 5.7.1 (x86_64-debian-linux-gnu)

$ bash --version
GNU bash, version 5.0.3(1)-release (x86_64-pc-linux-gnu)

# only available in a console using *bash*
$ echo ${BASH_VERSINFO[@]}
5 0 3 1 release x86_64-pc-linux-gnu
4

2 回答 2

1

TL;DR:使用不同的用户(例如hadoop)而不是root


我找到了解决方案,但对正在发生的事情没有深入的了解。尽管我有多难过,但这是我找到的解决方案:

root用户运行:

$ start-dfs.sh 
Starting namenodes on [master]
bash v3.2+ is required. Sorry.
Starting datanodes
bash v3.2+ is required. Sorry.
Starting secondary namenodes [master_bis]
bash v3.2+ is required. Sorry

然后我创建了一个hadoop用户并赋予该用户安装 Hadoop 的权限(R/W 访问)。使用这个新用户登录后,我有以下导致我遇到麻烦的命令的输出:

$ start-dfs.sh 
Starting namenodes on [master]
Starting datanodes
Starting secondary namenodes [master_bis]

此外,我注意到使用 Java 11 时创建的进程start-yarn.sh未列在输出中jps。切换到 Java 8 解决了我的问题(不要忘记更新所有$JAVA_HOME变量,包括/etc/environmenthadoop-env.sh)。

成功\o/。但是,我很高兴理解为什么root用户不能这样做。我知道使用root是一个坏习惯,但在实验环境中,拥有一个干净的“接近”生产环境并不符合我们的利益。任何有关此的信息将不胜感激:)。

于 2019-08-29T14:23:30.957 回答
0

尝试

chsh -s /bin/bash

将默认 shell 改回 bash

于 2021-05-22T09:00:31.327 回答