问题导读
1.如何查看HBase的安装等信息?
2.如何查看ROOT-表?
3.如何查看.META.表?
1 探究Zookeeper
安装过HBase的开发者一定知道,HBase本身就嵌入了Zookeeper,你可以选择安装嵌入的Zookeeper,也可以安装一个分布式的Zookeeper集群。具体的安装步骤,可以到我的博客里查找。
我们可以手工与Zookeeper交互的方式就是使用HBaseshell命令。使用zk_dump来查看HBase的安装等信息。
hbase(main):002:0>zk_dump
HBaseis rooted at /hbase
Active master address:hadoop-master,60000,1390921674646
Backup master addresses:
Region server holding ROOT:machine-0,60020,1390921686697
Region servers:
machine-1,60020,1390921690387
machine-2,60020,1390921767658
machine-0,60020,1390921686697
Quorum Server Statistics:
machine-1:2222
Zookeeper version: 3.4.5-1392090, built on 09/30/2012 17:52 GMT
Clients:
/192.168.177.158:55294[1](queued=0,recved=121,sent=135)
/192.168.177.172:54763[0](queued=0,recved=1,sent=0)
/192.168.177.168:59896[1](queued=0,recved=48,sent=48)
/192.168.177.158:55299[1](queued=0,recved=47,sent=47)
Latency min/avg/max: 0/2/42
Received: 217
Sent: 230
Connections: 4
Outstanding:0
Zxid: 0x3300000047
Mode: follower
Node count: 29
machine-0:2222
Zookeeper version: 3.4.5-1392090, built on 09/30/2012 17:52 GMT
Clients:
/192.168.177.172:38860[1](queued=0,recved=75,sent=77)
/192.168.177.172:38855[1](queued=0,recved=322,sent=369)
/192.168.177.167:52643[1](queued=0,recved=78,sent=90)
/192.168.177.172:38900[0](queued=0,recved=1,sent=0)
Latency min/avg/max: 0/2/291
Received: 476
Sent: 536
Connections: 4
Outstanding: 0
Zxid: 0x3300000047
Mode: follower
Node count: 29
machine-2:2222
Zookeeper version: 3.4.5-1392090, built on 09/30/2012 17:52 GMT
Clients:
/192.168.177.172:45693[0](queued=0,recved=1,sent=0)
/192.168.177.172:45687[1](queued=0,recved=13,sent=13)
/192.168.177.167:36053[1](queued=0,recved=43,sent=43)
Latency min/avg/max: 0/0/21
Received: 57
Sent: 56
Connections: 3
Outstanding: 0
Zxid: 0x3300000047
Mode: leader
Node count: 29 复制代码
根据显示的信息,我们可以查阅到HDFS中的HBase根路径,激活的主机地址域名和端口,root表的主机地址和端口。
HBase is rooted at /hbase
Active master address:hadoop-master,60000,1390921674646
Backup master addresses:
Region server holding ROOT:machine-0,60020,1390921686697 复制代码
区域服务器地址信息
Region servers:
machine-1,60020,1390921690387
machine-2,60020,1390921767658
machine-0,60020,1390921686697 复制代码
Zookeeper法定服务器的统计信息,当前的法定服务名称以及Zookeeper版本信息,客户端信息等
Quorum Server Statistics:
machine-1:2222
Zookeeper version: 3.4.5-1392090, built on 09/30/2012 17:52 GMT
Clients:
/192.168.177.158:55294[1](queued=0,recved=121,sent=135)
/192.168.177.172:54763[0](queued=0,recved=1,sent=0)
/192.168.177.168:59896[1](queued=0,recved=48,sent=48)
/192.168.177.158:55299[1](queued=0,recved=47,sent=47)
Latency min/avg/max: 0/2/291
Received: 476
Sent: 536
Connections: 4
Outstanding: 0
Zxid: 0x3300000047
Mode: follower
Node count: 29
machine-2:2222
Zookeeper version: 3.4.5-1392090, built on 09/30/2012 17:52 GMT
Clients:
/192.168.177.172:45693[0](queued=0,recved=1,sent=0)
/192.168.177.172:45687[1](queued=0,recved=13,sent=13)
/192.168.177.167:36053[1](queued=0,recved=43,sent=43)
Latency min/avg/max: 0/0/21
Received: 57
Sent: 56
Connections: 3
Outstanding: 0
Zxid: 0x3300000047
Mode: leader
Node count: 29 复制代码
当我们尝试去理解系统当前的状态时,这些信息显得尤为重要。那些主机加入到集群中了,那个主机扮演什么角色。更重要的是,个主机充当HBase的-root-表服务。HBase客户端需要这些信息来实现读写操作,而Zookeeper正好可以提供这些信息。
客户端能够制动化地与Zookeeper进行操作交流以及找到区域服务器
(RegisionServer)。为了更好的理解这些信息,我们将探究一下HBase中两个特殊的表-root-和.meta.。
2 探究-ROOT-表
扫描-root-表,查看具体的信息。
从输出的信息可以知道,-root-表包含.meta.表信息。-root-表中仅有一行数据,并且所有的信息是关于region, 这就意味着,整个系统由-root-表管理。这我目前的实例中,一个单一的.meta.表中的region能够包含所有信息。从-root-表中,我们可以知道有4列(regioninfo, server,serverstartcode, v.)数据,.meta.的数据在RegionServer 服务机的machine-0上。由于只有一个region,regioninfo字段中的开始字段startkey和结束字段endkey都为空。
3 探究.META.表
从上一节中,我们知道,regioninfo中包含region的名称,开始关键字startkey,结束关键字endkey,编码过的名称(编码过的名称是系统内部使用的)。如果.meta.表中没有表单定义,会有下列的显示:
hbase(main):030:0> scan '.META.'
ROW COLUMN+CELL
0 row(s) in 5.4180 seconds
一旦有表定义在HBase中,呈现效果会是这样:
hbase(main):012:0>scan '.META.'
ROW COLUMN+CELL
car,,1389254794373.41b48a453column=info:regioninfo, timestamp=1389254795518, value={NAME =>'car,,1389254794373.
79036ed6a28620f95bc3e73. 41b48a45379036ed6a28620f95bc3e73.',STARTKEY => '', ENDKEY => '', ENCODED => 41b48a4
5379036ed6a28620f95bc3e73,}
car,,1389254794373.41b48a453column=info:server, timestamp=1390982716032, value=machine-1:60020
79036ed6a28620f95bc3e73.
car,,1389254794373.41b48a453column=info:serverstartcode, timestamp=1390982716032, value=1390982688688
79036ed6a28620f95bc3e73.
pentaho_mappings,,1389456264column=info:regioninfo, timestamp=1389456267362, value={NAME =>'pentaho_mappings,,1
784.1fa2cc86c50ced5fa39630da389456264784.1fa2cc86c50ced5fa39630dae76fb1a2.', STARTKEY => '', ENDKEY=> '', ENCOD
e76fb1a2. ED =>1fa2cc86c50ced5fa39630dae76fb1a2,}
pentaho_mappings,,1389456264column=info:server, timestamp=1390982716247, value=machine-0:60020
784.1fa2cc86c50ced5fa39630da
e76fb1a2.
pentaho_mappings,,1389456264column=info:serverstartcode, timestamp=1390982716247, value=1390982687824
784.1fa2cc86c50ced5fa39630da
e76fb1a2.
users,,1389925800801.6a5a2b0column=info:regioninfo, timestamp=1389925809127, value={NAME =>'users,,138992580080
170dfd0e19df13849706ec035. 1.6a5a2b0170dfd0e19df13849706ec035.',STARTKEY => '', ENDKEY => '', ENCODED => 6a5a2
b0170dfd0e19df13849706ec035,}
users,,1389925800801.6a5a2b0column=info:server, timestamp=1390982718429, value=machine-1:60020
170dfd0e19df13849706ec035.
users,,1389925800801.6a5a2b0column=info:serverstartcode, timestamp=1390982718429, value=1390982688688
170dfd0e19df13849706ec035.
weblogs,,1389255303284.d2973column=info:regioninfo, timestamp=1389255304879, value={NAME =>'weblogs,,1389255303
dcc1b1ff64cc56a197fdd83ec5e.284.d2973dcc1b1ff64cc56a197fdd83ec5e.', STARTKEY => '', ENDKEY => '',ENCODED => d29
73dcc1b1ff64cc56a197fdd83ec5e,}
weblogs,,1389255303284.d2973column=info:server, timestamp=1390982716256, value=machine-0:60020
dcc1b1ff64cc56a197fdd83ec5e.
weblogs,,1389255303284.d2973column=info:serverstartcode, timestamp=1390982716256, value=1390982687824
dcc1b1ff64cc56a197fdd83ec5e.
4 row(s) in0.3280 seconds 复制代码
正如你看到的,.META.包含的是表的信息,这里就不详述了。看下列这个结构图便可以理解HBase中这两个表的关系。