hadoop 2.6.1 出现ssh无法解析主机名等错误提示的解决办法

lin@LL162:~/Hadoop/hadoop-2.6.1$ sbin/start-all.sh 
This script is Deprecated. Instead use start-dfs.sh and start-yarn.sh
15/10/21 09:31:22 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Starting namenodes on [Java HotSpot(TM) Client VM warning: You have loaded library /home/lin/Hadoop/hadoop-2.6.1/lib/native/libhadoop.so.1.0.0 which might have disabled stack guard. The VM will try to fix the stack guard now.
It's highly recommended that you fix the library with 'execstack -c <libfile>', or link it with '-z noexecstack'.
LL163]
sed: -e expression #1, char 6: unknown option to `s'
HotSpot(TM): ssh: Could not resolve hostname HotSpot(TM): Name or service not known
warning:: ssh: Could not resolve hostname warning:: Name or service not known
guard.: ssh_exchange_identification: Connection closed by remote host
guard: ssh_exchange_identification: Connection closed by remote host
Client: ssh_exchange_identification: Connection closed by remote host
VM: ssh_exchange_identification: Connection closed by remote host
which: ssh_exchange_identification: Connection closed by remote host
The authenticity of host 'loaded (202.106.199.34)' can't be established.
RSA key fingerprint is f0:53:b3:43:1f:dc:1f:8c:08:03:a4:40:ed:da:d0:34.
Are you sure you want to continue connecting (yes/no)? The authenticity of host 'might (202.106.199.34)' can't be established.
RSA key fingerprint is f0:53:b3:43:1f:dc:1f:8c:08:03:a4:40:ed:da:d0:34.
Are you sure you want to continue connecting (yes/no)? -c: Unknown cipher type 'cd'
'execstack: ssh: Could not resolve hostname 'execstack: Name or service not known
It's: ssh: Could not resolve hostname It's: Name or service not known
<libfile>',: ssh: Could not resolve hostname <libfile>',: Name or service not known
The authenticity of host 'disabled (202.106.199.34)' can't be established.
RSA key fingerprint is f0:53:b3:43:1f:dc:1f:8c:08:03:a4:40:ed:da:d0:34.
Are you sure you want to continue connecting (yes/no)? will: ssh_exchange_identification: Connection closed by remote host
The authenticity of host 'stack (202.106.199.37)' can't be established.
RSA key fingerprint is a6:1d:25:ab:6c:5b:ae:12:b9:ff:8c:d4:81:42:05:49.
Are you sure you want to continue connecting (yes/no)? The authenticity of host 'have (202.106.199.34)' can't be established.
RSA key fingerprint is f0:53:b3:43:1f:dc:1f:8c:08:03:a4:40:ed:da:d0:34.
Are you sure you want to continue connecting (yes/no)? The authenticity of host 'try (202.106.199.37)' can't be established.
RSA key fingerprint is a6:1d:25:ab:6c:5b:ae:12:b9:ff:8c:d4:81:42:05:49.
Are you sure you want to continue connecting (yes/no)? The authenticity of host 'the (202.106.199.37)' can't be established.
RSA key fingerprint is a6:1d:25:ab:6c:5b:ae:12:b9:ff:8c:d4:81:42:05:49.
Are you sure you want to continue connecting (yes/no)? The authenticity of host 'that (202.106.199.37)' can't be established.
RSA key fingerprint is a6:1d:25:ab:6c:5b:ae:12:b9:ff:8c:d4:81:42:05:49.
Are you sure you want to continue connecting (yes/no)? The authenticity of host 'the (202.106.199.37)' can't be established.
RSA key fingerprint is a6:1d:25:ab:6c:5b:ae:12:b9:ff:8c:d4:81:42:05:49.
Are you sure you want to continue connecting (yes/no)? The authenticity of host 'you (202.106.199.34)' can't be established.
RSA key fingerprint is f0:53:b3:43:1f:dc:1f:8c:08:03:a4:40:ed:da:d0:34.
Are you sure you want to continue connecting (yes/no)? The authenticity of host 'fix (202.106.199.37)' can't be established.
RSA key fingerprint is a6:1d:25:ab:6c:5b:ae:12:b9:ff:8c:d4:81:42:05:49.
Are you sure you want to continue connecting (yes/no)? The authenticity of host 'you (202.106.199.37)' can't be established.
RSA key fingerprint is a6:1d:25:ab:6c:5b:ae:12:b9:ff:8c:d4:81:42:05:49.
Are you sure you want to continue connecting (yes/no)? The authenticity of host 'have (202.106.199.34)' can't be established.
RSA key fingerprint is f0:53:b3:43:1f:dc:1f:8c:08:03:a4:40:ed:da:d0:34.
Are you sure you want to continue connecting (yes/no)? The authenticity of host 'stack (202.106.199.37)' can't be established.
RSA key fingerprint is a6:1d:25:ab:6c:5b:ae:12:b9:ff:8c:d4:81:42:05:49.
Are you sure you want to continue connecting (yes/no)? The authenticity of host 'fix (202.106.199.37)' can't be established.
RSA key fingerprint is a6:1d:25:ab:6c:5b:ae:12:b9:ff:8c:d4:81:42:05:49.
Are you sure you want to continue connecting (yes/no)? The authenticity of host 'now. (202.106.199.37)' can't be established.
RSA key fingerprint is a6:1d:25:ab:6c:5b:ae:12:b9:ff:8c:d4:81:42:05:49.
Are you sure you want to continue connecting (yes/no)? The authenticity of host 'll163 (192.168.0.163)' can't be established.
ECDSA key fingerprint is 7d:17:c1:12:a0:1b:cd:30:58:8c:ce:69:e1:57:f0:c1.
Are you sure you want to continue connecting (yes/no)? The authenticity of host 'vm (202.106.199.34)' can't be established.
RSA key fingerprint is f0:53:b3:43:1f:dc:1f:8c:08:03:a4:40:ed:da:d0:34.
Are you sure you want to continue connecting (yes/no)? it: ssh: Could not resolve hostname it: Name or service not known
The authenticity of host 'highly (202.106.199.37)' can't be established.
RSA key fingerprint is a6:1d:25:ab:6c:5b:ae:12:b9:ff:8c:d4:81:42:05:49.
Are you sure you want to continue connecting (yes/no)? The authenticity of host 'library (202.106.199.34)' can't be established.
RSA key fingerprint is f0:53:b3:43:1f:dc:1f:8c:08:03:a4:40:ed:da:d0:34.
Are you sure you want to continue connecting (yes/no)? The authenticity of host 'or (202.106.199.37)' can't be established.
RSA key fingerprint is a6:1d:25:ab:6c:5b:ae:12:b9:ff:8c:d4:81:42:05:49.
Are you sure you want to continue connecting (yes/no)? Java: ssh: Could not resolve hostname Java: Name or service not known
'-z: ssh: Could not resolve hostname '-z: Name or service not known
noexecstack'.: ssh: Could not resolve hostname noexecstack'.: Name or service not known
The authenticity of host 'library (202.106.199.37)' can't be established.
RSA key fingerprint is a6:1d:25:ab:6c:5b:ae:12:b9:ff:8c:d4:81:42:05:49.
Are you sure you want to continue connecting (yes/no)? The authenticity of host 'the (202.106.199.37)' can't be established.
RSA key fingerprint is a6:1d:25:ab:6c:5b:ae:12:b9:ff:8c:d4:81:42:05:49.
Are you sure you want to continue connecting (yes/no)? The authenticity of host 'with (202.106.199.37)' can't be established.
RSA key fingerprint is a6:1d:25:ab:6c:5b:ae:12:b9:ff:8c:d4:81:42:05:49.
Are you sure you want to continue connecting (yes/no)? The authenticity of host 'recommended (202.106.199.37)' can't be established.
RSA key fingerprint is a6:1d:25:ab:6c:5b:ae:12:b9:ff:8c:d4:81:42:05:49.
Are you sure you want to continue connecting (yes/no)? The authenticity of host 'with (202.106.199.37)' can't be established.
RSA key fingerprint is a6:1d:25:ab:6c:5b:ae:12:b9:ff:8c:d4:81:42:05:49.
Are you sure you want to continue connecting (yes/no)? link: ssh: Could not resolve hostname link: Name or service not known
to: ssh: connect to host to port 22: Connection refused


hadoop 2.61. 需要在环境变量里面添加 

export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_HOME/lib/native
export HADOOP_OPTS="-Djava.library.path=$HADOOP_HOME/lib"

这两句话,只有hadoop_home 是不行的;

后来发现是版本不兼容的问题。我的虚拟机是32位的,hadoop是64位的。吧虚拟机改为64位的 没有此问题;

### 解决Hadoop集群中SSH主机名解析失败的问题 #### 修改主机名配置 在Hadoop集群环境中,如果遇到SSH无法解析主机名的问题,通常需要检查和调整主机名配置。以下是具体的解决方法: 1. **编辑 `/etc/hosts` 文件** 在每台机器上打开并编辑 `/etc/hosts` 文件,确保所有节点的 IP 地址与其对应的主机名正确关联。例如: ```plaintext 192.168.226.128 vm2 192.168.226.129 vm3 192.168.226.130 vm4 ``` 这一步非常重要,因为如果没有正确的映射关系,SSH 和其他网络服务都无法识别主机名[^4]。 2. **更新主机名** 确保每台机器的实际主机名与 `/etc/hosts` 中定义的一致。可以通过以下命令设置主机名: ```bash sudo hostnamectl set-hostname vm2 ``` 替换 `vm2` 为实际的主机名,并在所有节点上重复此操作。 3. **重启网络服务** 更新完 `/etc/hosts` 和主机名后,需重启网络服务以使更改生效: ```bash sudo systemctl restart networking ``` --- #### 配置 DNS 设置(可选) 如果希望通过 DNS 来解析主机名而非依赖于 `/etc/hosts` 文件,可以考虑安装和配置本地 DNS 服务器(如 Bind 或 Dnsmasq)。以下是简单的方法之一——使用 Dnsmasq: 1. 安装 Dnsmasq: ```bash sudo apt-get install dnsmasq ``` 2. 编辑配置文件 `/etc/dnsmasq.conf` 并添加以下内容: ```plaintext address=/vm2/192.168.226.128 address=/vm3/192.168.226.129 address=/vm4/192.168.226.130 ``` 3. 启动 Dnsmasq 服务: ```bash sudo systemctl start dnsmasq ``` 4. 测试 DNS 解析功能: ```bash nslookup vm2 nslookup vm3 nslookup vm4 ``` --- #### 验证主机名解析 无论采用哪种方式(`/etc/hosts` 或 DNS),都需要验证主机名是否能被正确解析。可以在任意一台机器上运行以下命令: ```bash ping vm2 ping vm3 ping vm4 ``` 如果返回正常的 ICMP 回显响应,则说明主机名解析成功。 --- #### 配置 SSH 免密登录 即使解决了主机名解析问题,还需要确保 SSH 的免密登录功能正常工作。具体步骤如下: 1. **生成 RSA 密钥对** 在每台机器上执行以下命令生成密钥对: ```bash ssh-keygen -t rsa ``` 2. **分发公钥到其他节点** 将当前节点的公钥拷贝到其他节点的 `~/.ssh/authorized_keys` 文件中: ```bash ssh-copy-id hadoop@vm2 ssh-copy-id hadoop@vm3 ssh-copy-id hadoop@vm4 ``` 3. **测试免密登录** 尝试从某台机器连接到另一台机器而不输入密码: ```bash ssh vm2 ssh vm3 ssh vm4 ``` --- ### 总结 通过以上步骤,可以有效解决 Hadoop 集群中因主机名解析失败而导致的 SSH 连接问题。核心在于确保 `/etc/hosts` 文件或 DNS 配置正确无误,并完成 SSH 免密登录的设置[^1][^2][^3][^4]。 ```bash # 示例脚本:批量发送命令至多个会话 for host in vm2 vm3 vm4; do echo ==================== $host ==================== ssh $host 'hostname && uptime' done ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值