安装
https://github.com/harisekhon/dockerfiles 中包含N多Hadoop的docker项目,用于体验Hadoop是挺好的选择, 以下是怎么在Docker下体验Hbase项目
下载 Dockerfiles
git clone git@github.com:HariSekhon/Dockerfiles.git
mv Dockerfiles hadoop-docker
cd hadoop-docker
运行Hbase
cd hbase-dev
docker-compose up -d
在浏览器打开
– http://localhost:16010/
如果看到下图, 表名安装成功.
体验
- 进入hbase容器
cd hbase-dev
docker-compose exec hbase-dev bash
hbase shell
- list 列出当前tables
hbase(main):001:0> list
TABLE
0 row(s) in 0.3360 seconds
=> []
- 创建emp表
hbase(main):001:0> create 'emp', 'personal data', 'professional data'
0 row(s) in 1.6220 seconds
=> Hbase::Table - emp
- 插入数据
hbase(main):003:0> put 'emp','1','personal data:name','raju'
0 row(s) in 0.1370 seconds
hbase(main):005:0> scan 'emp'
ROW COLUMN+CELL
1 column=personal data:name, timestamp=1529399837299, value=raju
1 row(s) in 0.0410 seconds
- 更新数据
hbase(main):012:0> put 'emp','1','personal data:name','raju-1'
0 row(s) in 0.0100 seconds
hbase(main):013:0> scan 'emp'
ROW COLUMN+CELL
1 column=personal data:name, timestamp=1529400258739, value=raju-1
1 row(s) in 0.0390 seconds
- 读取数据
hbase(main):014:0> get 'emp', '1'
COLUMN CELL
personal data:name timestamp=1529400258739, value=raju-1
1 row(s) in 0.0440 seconds
- 删除单元格
delete 'emp', '1', 'personal data:name'
- 删除表的所有单元格
deleteall 'emp','1'
- 计数
hbase(main):022:0> count 'emp'
0 row(s) in 0.0460 seconds
=> 0
参考
- https://www.yiibai.com/hbase/hbase_shell.html