hbase 基于Hdfs 文件系统 hbase 支持随机高速访问
hbase 没有事务特性 hbase不能处理联合关系处理 比如mysql 里面的join
hbase优点在于存放非常大的表 百万行 百万列 支持随机高速访问
Hbase 表结构
表名->行键->列族(column family)->列名(qualifier)->版本号
具体请查看:https://www.cnblogs.com/steven-note/p/7209398.html
hbase 创建 增加数据代码展示
public class HbaseTest {
public static void main(String[] args) {
Configuration configuration = HBaseConfiguration.create();
configuration.set("hbase.zookeeper.quorum","192.168.36.139:2181,192.168.36.139:2182,192.168.36.139:2183");
//createTable(configuration);
InsertTest(configuration);
}
public static void InsertTest(Configuration configuration) {
HTable hTable = null;
try {
hTable = new HTable(configuration, "dj");
} catch (IOException e) {
e.printStackTrace();
}
Put row1 = new Put(Bytes.toBytes("row1"));
row1.add(Bytes.toBytes("f1"), Bytes.toBytes("tuya"), Bytes.toBytes("zhuangbi"));
Put row2 = new Put(Bytes.toBytes("row2"));
row2.add(Bytes.toBytes("f1"), Bytes.toBytes("xiaopeng"), Bytes.toBytes("wanyingde"));
ArrayList<Put> puts = new ArrayList<>();
puts.add(row1);
puts.add(row2);
try {
hTable.put(puts);
} catch (IOException e) {
e.printStackTrace();
}
}
public static void createTable(Configuration configuration) {
HBaseAdmin hBaseAdmin=null;
try {
hBaseAdmin= new HBaseAdmin(configuration);
} catch (IOException e) {
e.printStackTrace();
}
TableName table = TableName.valueOf("dj");
HTableDescriptor hTableDescriptor = new HTableDescriptor(table);
HColumnDescriptor f1 = new HColumnDescriptor("f1");
hTableDescriptor.addFamily(f1);
try {
hBaseAdmin.createTable(hTableDescriptor);
} catch (IOException e) {
e.printStackTrace();
}
}
}