•start-hbase.sh
•hbaseshell
•create'tab1','col'
•list 显示表
•put'tab1','row1', 'col:name', 'XiaoMing'
•put'tab1', 'row1', 'col:age','10'
•put'tab2', 'row2', 'col:name', 'DaMing'
•删除表
–disable'tab1'
–drop'tab1'
•@Test
• public void testGet() throws IOException {
• Configuration conf = HBaseConfiguration.create();
•// conf.set("hbase.master.port","localhost:PORT");
•// conf.set("hbase.zookeeper.quorum","IP");
• HTable table = new HTable(conf,"tab1");
• Get get = new Get(Bytes.toBytes("r1"));
• get.addColumn(Bytes.toBytes("col"),Bytes.toBytes("name"));
• Result result = table.get(get);
• byte[] value = result.value();
• System.out.println("v:"+ Bytes.toString(value));
• byte[] val = result.getValue(Bytes.toBytes("col"),Bytes.toBytes("name"));
• System.out.println("Value:" + Bytes.toString(val));
•}
HTable table = new HTable(conf, "tab1");
long t1 = System.currentTimeMillis();
for(int i=5; i<100000; i++){
Put put = new Put(Bytes.toBytes("r"+i));
put.add(Bytes.toBytes("col"), Bytes.toBytes("name"+i), Bytes.toBytes("MyName"+i));
table.put(put);
//Thread.sleep(10000);
}
System.out.println(System.currentTimeMillis() - t1);