1
2
3
4
5
|
# tar zxvf hbase-1.0.1.1-bin.tar.gz
# mv hbase-1.0.1.1 /opt
# vi hbase-env.sh
export
JAVA_HOME=
/usr/local/jdk1
.7
export
HBASE_MANAGES_ZK=
false
#关闭通过内置Zookeeper管理HBase
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# vi hbase-site.xml
<configuration>
<!--HBase数据目录位置-->
<property>
<name>hbase.rootdir<
/name
>
<value>hdfs:
//hcluster/hbase
<
/value
>
<
/property
>
<!--启用分布式集群-->
<property>
<name>hbase.cluster.distributed<
/name
>
<value>
true
<
/value
>
<
/property
>
<!--默认HMaster HTTP访问端口-->
<property>
<name>hbase.master.info.port<
/name
>
<value>16010<
/value
>
<
/property
>
<!--默认HRegionServer HTTP访问端口-->
<property>
<name>hbase.regionserver.info.port<
/name
>
<value>16030<
/value
>
<
/property
>
<!--不使用默认内置的,配置独立的ZK集群地址-->
<property>
<name>hbase.zookeeper.quorum<
/name
>
<value>HSlave0,HSlave1,HSlave2<
/value
>
<
/property
>
<
/configuration
>
|
1
2
3
4
|
# vi regionservers
HSlave0
HSlave1
HSlave2
|
1
2
3
4
5
|
# vi /etc/profile
HBASE_HOME=
/opt/hbase-1
.0.1.1
PATH=$PATH:$HBASE_HOME
/bin
export
HBASE_HOME PATH
# source /etc/profile
|
1
|
# start-hbase.sh
|
1
|
# hbase-daemon.sh start regionserver
|
1
2
3
4
5
6
|
[root@HMaster0 ~]
# jps
2615 DFSZKFailoverController
30027 ResourceManager
29656 NameNode
2841 HMaster
8448 Jps
|
1
2
3
4
5
6
7
|
[root@HSlave0 ~]
# jps
11391 NodeManager
11213 DataNode
11298 JournalNode
10934 QuorumPeerMain
12571 HRegionServer
7005 Jps
|
name | info | address | |
sex | age | ||
zhangsan |
22 | man | beijing |
lisi | 23 | woman | shanghai |
1
|
hbase(main):024:0> create
'tb1'
,
'name'
,
'info'
,
'address'
|
1
|
hbase(main):025:0> describe
'tb1'
|
1
|
hbase(main):025:0> list
|
1
2
3
4
5
6
|
hbase(main):028:0> put
'tb1'
,
'zhangsan'
,
'info:sex'
,
'22'
hbase(main):039:0> put
'tb1'
,
'zhangsan'
,
'info:age'
,
'man'
hbase(main):031:0> put
'tb1'
,
'zhangsan'
,
'address'
,
'beijing'
hbase(main):046:0> put
'tb1'
,
'lisi'
,
'info:age'
,
'woman'
hbase(main):047:0> put
'tb1'
,
'lisi'
,
'info:sex'
,
'23'
hbase(main):048:0> put
'tb1'
,
'lisi'
,
'address'
,
'shanghai'
|
1
2
3
4
5
|
hbase(main):040:0> scan
'tb1'
ROW COLUMN+CELL
zhangsan column=address:,timestamp=1435129009088,value=beijing
zhangsan column=info:age,timestamp=1435129054098, value=
man
zhangsan column=info:sex,timestamp=1435128714392, value=22
|
1
2
3
4
|
hbase(main):050:0> count
'tb1'
2 row(s)
in
0.0190 seconds
=> 2
|
1
2
3
4
5
6
|
hbase(main):054:0> get
'tb1'
,
'zhangsan'
hbase(main):054:0> get
'tb1'
,
'zhangsan'
COLUMN CELL
address: timestamp=1435129096397,value=beijing
info:age timestamp=1435129054098,value=
man
info:sex timestamp=1435128714392,value=22
|
1
2
3
4
|
hbase(main):055:0> get
'tb1'
,
'zhangsan'
,
'info'
COLUMN CELL
info:age timestamp=1435129054098,value=
man
info:sex timestamp=1435128714392,value=22
|
1
2
|
hbase(main):063:0> put
'tb1'
,
'zhangsan'
,
'info:sex'
,
'23'
0 row(s)
in
0.0080 seconds
|
1
|
hbase(main):070:0> incr
'tb1'
,
'lisi'
,
'info:comment'
|
1
|
hbase(main):065:0> delete
'tb1'
,
'zhangsan'
,
'info:sex'
|
1
|
hbase(main):067:0> deleteall
'tb1'
,
'zhangsan'
|
1
2
|
hbase(main):072:0> disable
'tb1'
#先禁用
hbase(main):073:0> drop
'tb1'
#再删除
|