无法从windows eclipse

时间:2015-05-10 16:04:07

标签: eclipse hadoop hive hbase cloudera

我正在尝试从windows中安装的eclipse创建Hbase表。我有运行cloudera vm。我在Windows主机文件和vm主机文件中输出了ip“192.168.1.5”。请建议。

我已经包含了所有的hbase jar文件。你能指导我如何将eclipse连接到cloudera vm。这项工作并没有引发任何错误,而是长时间运行。

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 ");        
    }
}

执行后的输出:

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 

1 个答案:

答案 0 :(得分:1)

将你的cloudera vm 192.168.1.5的IP地址添加到你的窗口的/etc/hosts

C:\WINDOWS\system32\drivers\etc\hosts

并将此属性添加到配置中:

conf.set("hbase.master", "192.168.1.5:60000");