phoenix jdbc不起作用,没有异常并且卡住了 [英] phoenix jdbc doesn't work, no exceptions and stuck

查看:432
本文介绍了phoenix jdbc不起作用,没有异常并且卡住了的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是phoenix和hbase的新手.hbase表和phoenix视图运行良好,我可以通过phoenix获取数据.当我将jdbc访问到phoenix时,它卡住了.

I'm new to phoenix and hbase.hbase table and phoenix view works well and i can fetch data through phoenix. when I access jdbc to phoenix,it stucks.

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class Phoenix {
    private static String driver = "org.apache.phoenix.jdbc.PhoenixDriver";
    public static void main(String[] args) throws SQLException {
        try {
            Class.forName(driver);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        Statement stmt = null;
        ResultSet rs = null;
        System.out.println("start...");
        Connection con = DriverManager.getConnection("jdbc:phoenix:[my_cloud_server_ip]:2181");
        System.out.println(con);
        con.close();
    }
}

(只有一个Zookeeper服务器具有公共互联网ip,所以我在那儿写这个ip,重要吗?)

(only one zookeeper server has public internet ip,so i write this ip there,does it matters?)

它显示开始...",并且不再响应

it prints "start..." and no response any more

但当网址为"jdbc:phoenix:ip:2181"或"jdbc:phoenix:ip:2181/hbase"时

BUT when when the url is "jdbc:phoenix:ip:2181" or "jdbc:phoenix:ip:2181/hbase"

我没有回应

当我添加其他单词时,例如"jdbc:phoenix:ip:2181/balabala"

when i add some other words ,for example "jdbc:phoenix:ip:2181/balabala"

我得到了NULL POINTER EXCEPTION

i got NULL POINTER EXCEPTION

为什么?

我希望你能理解我说的话:)

I hope u can understand what i say:)

推荐答案

重现您的示例,由于java.net.UnknownHostException: unknown host: <hostname_of_my_zk_server>,我在60秒后得到了java.net.SocketTimeoutException.但是,如果您很着急(或者如果您的自定义hbase-site.xml客户端超时较大),那也许就是您所说的无响应".

Reproducing your example, I am getting a java.net.SocketTimeoutException after 60 seconds, caused by java.net.UnknownHostException: unknown host: <hostname_of_my_zk_server>. But maybe that's what you called "no response" if you were in a hurry (or if you have a custom hbase-site.xml with a larger timeout client-side).

此错误似乎是

This error seems like the one explained in this article (section Zookeeper at the end) :

在CDH在测试VM中运行的情况下,我们遇到了以下问题:通过将localhost.localdomain添加到cluster1的现有/etc/hosts条目中已解决,该条目已经指向正确的IP地址.

That was worked around by adding localhost.localdomain to the existing /etc/hosts entry for cluster1, which was already pointing to the right IP address.

关于SO的答案总结了解决方案.

基本上,您需要向/etc/hosts客户端添加条目:

Basically, you need to add an entry to your /etc/hosts client-side :

<my_cloud_server_ip> <hostname_of_my_cloud_server_ip>

此外,您需要具有hbase-site.xml客户端(可以在服务器上使用该客户端).

Moreover, you need to have an hbase-site.xml client-side (you can use the one on your server as a basis).

这篇关于phoenix jdbc不起作用,没有异常并且卡住了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆