java—在本地计算机中创建hadoop客户端时出现的问题

xwbd5t1u  于 2021-06-02  发布在  Hadoop
关注(0)|答案(2)|浏览(315)

我有一个namenode和数据节点在aws上运行。我配置了foxyproxy并检查了以下各项:

Ganglia Metrics Reports    master-public-dns/ganglia/
 Hadoop ResourceManager master-public-dns-name:9026
 Hadoop NameNode    master-public-dns-name:9101

我的java代码是:

import java.io.IOException;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.MasterNotRunningException;
import org.apache.hadoop.hbase.client.HBaseAdmin;
import com.google.protobuf.ServiceException;

public class HBaseConnection {

public static void main(String [] args){

    System.out.println("HBaseConnection");

}

public void getConnection() throws IOException, ServiceException{

    Configuration config = HBaseConfiguration.create();
    config.clear();
    config.set("hbase.zookeeper.quorum", "MASTER_NODE_DNS");
    config.set("hbase.zookeeper.property.clientPort","2181");
    System.out.println("Getting HBaseConnection..");

    try {
        HBaseAdmin.checkHBaseAvailable(config);
    } catch (MasterNotRunningException e) {
        p("HBase is not running.");
        p(e.toString());
        System.exit(1);
    }

    QueryHBase query = new QueryHBase();
    query.run(config);

}

private static void p(String msg) {
    System.out.println(msg);
}
}

我无法连接到主节点并收到以下错误:

14/10/23 07:17:35 WARN zookeeper.ClientCnxn: Session 0x0 for server null, unexpected error,         closing socket connection and attempting reconnect
java.net.ConnectException: Operation timed out
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:739)
at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:350)
at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1068)

我已启用主安全组配置中的所有端口。
这个问题一直困扰着我很久了。

oxf4rvwz

oxf4rvwz1#

当hbase是针对hadoop 1编译的,并且在其类路径上有hadoop 2 JAR时会导致。确保使用相同的hbase版本,并在正确的hadoop上编译

rjee0c15

rjee0c152#

确保连接到zookeeper集合,该集合可能不会与namenode或resourcemanager并置。你应该确定 zookeeper-host:2181 是可以到达的。

相关问题