You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Hadoop3.0.0伪分布式启动报错求助:localhost权限拒绝及配置异常

Hey Tim, let's work through these two issues step by step to get your Hadoop pseudo-distributed cluster up and running smoothly.


1. Fix the #: command not found error in hadoop-env.sh

This error pops up because your hadoop-env.sh script's first line is being interpreted as a command instead of a comment. The most common causes are:

  • You used a full-width Chinese # instead of the standard half-width English # for comments
  • The script lacks a proper shebang (the line that tells the system which shell to use) at the top

Resolution steps:

  1. Open the file for editing:
    sudo nano /usr/local/hadoop/etc/hadoop/hadoop-env.sh
    
  2. Check the first line:
    • If it's a comment, make sure it starts with a half-width # (e.g., # Hadoop Environment Configuration)
    • If it's a shebang line, set it to #!/bin/bash (the standard for bash scripts)
  3. Save and exit: Press Ctrl+O, hit Enter, then Ctrl+X

2. Resolve localhost: Permission denied (publickey,password)

Hadoop's pseudo-distributed mode requires password-less SSH access to localhost for node communication. This error means your user tc doesn't have the right SSH permissions set up.

Resolution steps:

Step 1: Generate an SSH key pair (if you haven't already)

Run this command and press Enter through all prompts to accept defaults:

ssh-keygen -t rsa -P ""

This creates two files in ~/.ssh/: id_rsa (private key) and id_rsa.pub (public key).

Step 2: Add your public key to authorized keys

Append your public key to the list of trusted keys:

cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys

SSH enforces strict permissions for these files, so set the correct access rights:

chmod 600 ~/.ssh/authorized_keys
chmod 700 ~/.ssh

Step 3: Test password-less login

Verify the setup works by logging into localhost without a password:

ssh localhost

If you get a shell prompt without entering a password, it's working. Type exit to return to your original session.


Final Verification

Once both fixes are done, re-run the start command:

sudo /usr/local/hadoop/sbin/start-dfs.sh

Use the jps command to check running processes—you should see NameNode, DataNode, and SecondaryNameNode listed if everything started correctly.

内容的提问来源于stack exchange,提问作者Tim

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.26 10:59:03