eclipse连接不到hbase解决

由于虚拟机运行比较卡顿,因此我觉定把其相关编程在主机的eclipse上运行,但在虚拟机上运行的好好程序到了本机上却不管用了,连接不到hbase,卡在一个地方不动

 映射什么的都没问题但就是连接不上

 看了https://www.cnblogs.com/huan-ch/p/11689016.html#4709881这篇贴子后终于解决

修改连接的代码就解决了

原本的连接方式

1
2
3
4
5
6
7
8
9
10
11
12
public static void getConnection() {
            configuration = HBaseConfiguration.create();
            configuration.set("hbase.rootdir", "hdfs://192.168.146.131:9000/text");
             
            try {
                connection = ConnectionFactory.createConnection(configuration);
                admin = connection.getAdmin();
            }catch (Exception e) {
                // TODO: handle exception
                e.printStackTrace();
            }
        }

  改为

1
2
3
4
5
6
7
8
9
10
11
12
public static void getConnection() {
            configuration = HBaseConfiguration.create();
            configuration.set("hbase.zookeeper.quorum", "192.168.146.131");
            configuration.set("hbase.zookeeper.pronperty.clientPort","2181");
            try {
                connection = ConnectionFactory.createConnection(configuration);
                admin = connection.getAdmin();
            }catch (Exception e) {
                // TODO: handle exception
                e.printStackTrace();
            }
        }

  成功解决

posted @   溜了溜  阅读(447)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示