Windows下访问VM中HBase
资源所限,只能先在本机上模拟hadoop集群。(见文章:http://blackwing.iteye.com/admin/blogs/1502476)
开动之前,需要启动hadoop,并且创建好一个hbase目录:
hadoop fs -mkdir hbase
hadoop fs -ls /
<configuration> <property> <name>hbase.rootdir</name> <value>hdfs://namenode.blackwing.com:8020/hbase/</value> </property> <property> <name>hbase.cluster.distributed</name> <value>true</value> </property> <property> <name>hbase.zookeeper.property.clientPort</name> <value>2181</value> </property> <property> <name>hbase.zookeeper.quorum</name> <value>namenode.blackwing.com</value> </property></configuration>
hdfs://namenode.blackwing.com:8020/
public InsertData(String tableName){rowList = new ArrayList<Row>();this.conf = HBaseConfiguration.create();this.conf.set("hbase.zookeeper.quorum","192.168.128.140");System.out.println("hbase.master = "+conf.get("hbase.master"));System.out.println("hbase.zookeeper.quorum = "+conf.get("hbase.zookeeper.quorum"));try {this.table=new HTable(this.conf,tableName.getBytes());} catch (IOException e) {e.printStackTrace();logger.info("errors occur while creating table : "+tableName);}}
hdfs://namenode.blackwing.com:8020/hbase/
hdfs://namenode.blackwing.com:8020/
C:\WINDOWS\system32\drivers\etc\hosts
192.168.128.140 namenode.blackwing.com192.168.128.136 jobtracker.blackwing.com192.168.128.141 datanode.blackwing.com
hadoop fs -ls /hbase