Reputation: 19
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.
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 ");
}
}
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://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Table created started
Upvotes: 0
Views: 401
Reputation: 799
add the ip address of your cloudera vm 192.168.1.5
to /etc/hosts
of your windows under
C:\WINDOWS\system32\drivers\etc\hosts
and add this property to the configuration:
conf.set("hbase.master", "192.168.1.5:60000");
Upvotes: 1