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

Hadoop启动报错求助:Permission denied及NativeCodeLoader警告

Fixing "Permission denied (publickey,password,keyboard-interactive)" When Starting HDFS

Hey there, I’ve run into this exact issue multiple times when setting up Hadoop locally—reinstalling won’t fix it because the problem is almost always with SSH key authentication, which Hadoop relies on to communicate between nodes (even local ones). Let’s walk through the fixes step by step:

1. Verify and Generate SSH Key Pair

Hadoop needs passwordless SSH access to localhost to start daemons. First, check if you already have a key pair:

ls -la ~/.ssh

If you don’t see id_rsa (private key) and id_rsa.pub (public key), generate a new pair with no passphrase:

ssh-keygen -t rsa -P "" -f ~/.ssh/id_rsa

Just hit Enter through all prompts—we don’t want a passphrase here (it would break automated SSH logins for Hadoop).

2. Add Public Key to Authorized Keys

Next, add your public key to the list of authorized keys for local login:

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

SSH is strict about file permissions—set the correct permissions to avoid being locked out:

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

3. Test Passwordless SSH Login

Before touching Hadoop again, verify you can SSH to localhost without a password:

ssh localhost

If this prompts for a password, your SSH config might be blocking key auth. Fix that by editing the SSH daemon config:

sudo nano /etc/ssh/sshd_config

Make sure these lines are uncommented and set to yes:

PubkeyAuthentication yes
AuthorizedKeysFile      .ssh/authorized_keys .ssh/authorized_keys2

Save the file and restart the SSH service:

  • On Ubuntu/Debian: sudo systemctl restart sshd
  • On CentOS/RHEL: sudo service ssh restart
    Test ssh localhost again—it should log you in without asking for a password.

4. Fix Hadoop Directory Permissions

Sometimes Hadoop can’t start because its installation or data directories have incorrect ownership. Set them to your user account:

chown -R your_username:your_username $HADOOP_HOME

Replace your_username with your actual Linux username, and $HADOOP_HOME with the path to your Hadoop installation (e.g., /opt/hadoop).

Also, check the data directories you configured in hdfs-site.xml (like dfs.namenode.name.dir and dfs.datanode.data.dir)—make sure those directories exist and are owned by your user too.

5. Double-Check Hadoop SSH Config

If you still have issues, verify Hadoop’s SSH settings. Open $HADOOP_HOME/etc/hadoop/hadoop-env.sh and add this line to ensure Hadoop uses your key:

export HADOOP_SSH_OPTS="-i ~/.ssh/id_rsa"

Quick Note on the NativeCodeLoader Warning

As you found in forums, that WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform message is totally harmless. It just means Hadoop can’t load some optimized native libraries for your OS, but all core HDFS/YARN functionality will work perfectly fine—no need to fix that right now.

Once you’ve gone through these steps, run ./start-dfs.sh again—it should start the NameNode, DataNode, and SecondaryNameNode without permission errors. If you still hit issues, check the logs in $HADOOP_HOME/logs (look for namenode-*.log or datanode-*.log)—they’ll have more specific details about what’s failing.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.19 10:04:52