看尚硅谷视频,在windows上运行集群上的hbase时
package org.example;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.client.HBaseAdmin;
import java.io.IOException;
public class TestHBaseApi {
private static HBaseConfiguration conf;
private static HBaseAdmin admin;
public static void conncet2HBase() throws IOException {
conf=new HBaseConfiguration();
conf.set("hbase.zookeeper.quorum","node1,node2,node3");
admin=new HBaseAdmin(conf);
}
public static boolean isTableExist(String tableName) throws IOException {
boolean is;
is=admin.tableExists(tableName);
admin.close();
return is;
}
public static void main(String[] args) throws IOException {
conncet2HBase();
String tableName="ORDER_INFO";
System.out.println(isTableExist(tableName));
}
}
出现了以下的错误,说找不到位置:
Exception in thread "main" org.apache.hadoop.hbase.client.RetriesExhaustedException: Can't get the locations
其实是windows不认识node1,node2,node3是什么意思,去windows的hosts文件夹下把 node1的ip 和node1做一个映射,跟linux上的hosts一样
C:\Windows\System32\drivers\etc\hosts,会出现不能编辑的问题,更改一下文件的权限就好了