欢迎访问皮皮网官网
皮皮网

【果粉之家源码】【openwrt源码更新记录】【获取网站tdk源码】eclipse hbase 源码

时间:2024-11-20 12:44:09 分类:百科 来源:获取账号盒子源码

1.eclipse中Java程序实现对HBase操作报错:java.io.IOException: Attempt to start meta tracker failed.

eclipse hbase 源码

eclipse中Java程序实现对HBase操作报错:java.io.IOException: Attempt to start meta tracker failed.

       我hadoop和Hbase都是源码采用伪分布式的

       代码如下:

       public class HbaseTest {

       private static Configuration conf;

       static{

       conf = HBaseConfiguration.create();

       conf.set("hbase.rootdir", "hdfs://...2:/hbase");

       //使用eclipse时必须添加这个,否则无法定位

       conf.set("hbase.zookeeper.quorum",源码果粉之家源码 "...2");

       conf.set("hbase.zookeeper.property.clientPort", "");

       }

       public static void createTable(String tableName){

       System.out.println("start create table ......");

       try {

       HBaseAdmin hbAdmin = new HBaseAdmin(conf);

       if(hbAdmin.tableExists(tableName)){

       hbAdmin.disableTable(tableName);

       hbAdmin.deleteTable(tableName);

       System.out.println(tableName + " is exist,detele ....");

       }

       // HTableDescriptor htd = new HTableDescriptor(tableName);

       HTableDescriptor htd = new HTableDescriptor(tableName);

       htd.addFamily(new HColumnDescriptor("cf1"));

       htd.addFamily(new HColumnDescriptor("cf2"));

       htd.addFamily(new HColumnDescriptor("cf3"));

       htd.addFamily(new HColumnDescriptor("cf4"));

       hbAdmin.createTable(htd);

       } catch (MasterNotRunningException e) {

       // TODO Auto-generated catch block

       e.printStackTrace();

       } catch (ZooKeeperConnectionException e) {

       // TODO Auto-generated catch block

       e.printStackTrace();

       } catch (IOException e) {

       // TODO Auto-generated catch block

       e.printStackTrace();

       }

       System.out.println("end create table ......");

       }

       public static void main(String[] args) {

       createTable("testTable");

       }

       更多0

copyright © 2016 powered by 皮皮网   sitemap