dimanche 10 mai 2015

Unable to create Hbase table from windows eclipse

I am trying to create Hbase table from eclipse installed in windows. I have cloudera vm running .I have out the ip "192.168.1.5" in windows host file and vm host files. Please suggest.

I have included all the hbase jar files. Can you please guide me how to connect eclipse to cloudera vm. The job is not throwing any error, but running for long time.

              ///code start///////////



 package hbase;
    import java.io.IOException;
    import org.apache.hadoop.conf.Configuration;
    import org.apache.hadoop.hbase.HBaseConfiguration;
    import org.apache.hadoop.hbase.client.Get;
    import org.apache.hadoop.hbase.client.HTable;
    import org.apache.hadoop.hbase.client.Put;
    import org.apache.hadoop.hbase.client.Result;
    import org.apache.hadoop.hbase.HBaseConfiguration;
    import org.apache.hadoop.hbase.HColumnDescriptor;
    import org.apache.hadoop.hbase.HTableDescriptor;
    import org.apache.hadoop.hbase.client.HBaseAdmin;
    import org.apache.hadoop.hbase.TableName;
    import org.apache.hadoop.conf.Configuration;
    import org.apache.hadoop.hbase.client.ResultScanner;

    import org.apache.hadoop.hbase.client.Scan;

    import org.apache.hadoop.hbase.util.Bytes;
    public class HbaseTable {
        public static void main(String[] args) throws Exception {
        Configuration conf = HBaseConfiguration.create();
        conf.set("hbase.zookeeper.quorum", "192.168.1.5");
        conf.set("hbase.zookeeper.property.clientPort","2181");
        conf.set("zookeeper.znode.parent", "/hbase-unsecure");
        //HTable usersTable = new HTable(conf, "users");
        //HBaseAdmin hbase = new HBaseAdmin(conf);
         HBaseAdmin admin = new HBaseAdmin(conf);
         // Instantiating table descriptor class
        HTableDescriptor tableDescriptor = new HTableDescriptor(TableName.valueOf("emp"));

        // Adding column families to table descriptor
        tableDescriptor.addFamily(new HColumnDescriptor("personal"));
        tableDescriptor.addFamily(new HColumnDescriptor("professional"));
        **System.out.println(" Table created started ");**
        // Execute the table through admin
        admin.createTable(tableDescriptor);
        System.out.println(" Table created ");

    }
    }
          ////code End///////////

The output after execution: log4j:WARN No appenders could be found for logger (org.apache.hadoop.metrics2.lib.MutableMetricsFactory). log4j:WARN Please initialize the log4j system properly. log4j:WARN See http://ift.tt/1foX5be for more info. Table created started

Aucun commentaire:

Enregistrer un commentaire