由于虚拟机运行比较卡顿,因此我觉定把其相关编程在主机的eclipse上运行,但在虚拟机上运行的好好程序到了本机上却不管用了,连接不到hbase,卡在一个地方不动
映射什么的都没问题但就是连接不上
看了https://www.cnblogs.com/huan-ch/p/11689016.html#4709881这篇贴子后终于解决
修改连接的代码就解决了
原本的连接方式
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(); } }
改为
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(); } }
成功解决