我有一个名称节点和在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)
我已经启用了主安全组配置中的所有端口。
这个问题从很久以前就一直困扰着我。
确保连接到Zookeeper集成,该集成可能不会与NameNode或ResourceManager共存。您应该确保zookeeper-host:2181
是可访问的。
当HBase是针对Hadoop 1编译的,并且其类路径上有Hadoop 2 jar时引起的。确保您使用相同的hbase版本,并在正确的hadoop 上编译