废话不多说,上代码
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.ServerName; import org.apache.hadoop.hbase.client.Admin; import org.apache.hadoop.hbase.client.Connection; import org.apache.hadoop.hbase.client.ConnectionFactory; import java.io.IOException; public class TableAmdinTest { public static void main(String[] args) throws IOException { Configuration conf=new Configuration(); //输入自己配置的hbase连接 conf.set("hbase.zookeeper.quorum","node-1,nde-2,node-3"); Connection connection=ConnectionFactory.createConnection(conf); Admin admin=connection.getAdmin(); ServerName master=admin.getMaster(); System.out.println(master); //关闭连接 admin.close(); connection.close(); } }
依赖导入
org.apache.hbase hbase-client2.2.4 commons-io commons-io2.6 junit junit4.12 compile
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)