public void create() throws IOException{ Admin admin = conn.getAdmin(); if(admin.tableExists(tName)){ admin.disableTable(tName); ( ) ; } HTableDescriptor ht = new HTableDescriptor(tName); HColumnDescriptor hc = new HColumnDescriptor("cf1".getBytes()); hc.setMaxVersions(5); hc.setBlockCacheEnabled(true); hc.setBlocksize(180000); ht.addFamily(hc); admin.( ) (ht); System.out.println("表创建完成"); }
查看答案
public void insert() throws IOException{ Table table = conn.getTable(tName); ListputList = new ArrayList(); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); for(int i=1;i<20;i++){ String id=format.format(new Date()); id=id.replace("-", "").replace(" ", "").replace(":", ""); id = "student"+getRowKey(id); Put put = new Put(id.getBytes()); String name="Tom"+i; put.( ) ("cf1".getBytes(), "name".getBytes(), name.getBytes()); putList.( ) ; } table.put(putList); System.out.println("数据插入完成"); }
hbase.rootdir这个目录是 RegionServer 的共享目录,用来( ) 。特别注意的是 hbase.rootdir 里面的 HDFS 地址是要跟 Hadoop 的( )里面的 fs.defaultFS 的 HDFS 的 IP 地址或者域名、端口必须一致。
在windows系统下,需要配置hosts文件,试举例配置信息。