HBase是一个分布式的、面向列的开源数据库
##下载后解压
我的机器名为hadoop2
##1. 单机版运行
使用本地文件系统,不需要启动HDFS,开发、调试方便
进入hbase的安装目录,修改`conf/hbase-site.xml`,加上一段:
1 2 3 4
| <property> <name>hbase.rootdir</name> <value>file:///tmp/hbase</value> #此处可替换成其他路径 </property>
|
启动HBase
1 2
| [root@hadoop2 hbase-0.96.2-hadoop2]# ./bin/start-hbase.sh starting master, logging to /usr/local/share/applications/hbase-0.96.2-hadoop2/bin/../logs/hbase-hduser-master-hadoop2.out
|
jps
一下可以看到HMaster进程已经启动
1 2 3 4 5 6 7
| [root@hadoop2 hbase-0.96.2-hadoop2]# jps 4961 DataNode 5130 SecondaryNameNode 6574 HMaster 5358 NodeManager 5260 ResourceManager 4872 NameNode
|
停止HBASE
1 2
| [root@hadoop2 hbase-0.96.2-hadoop2]# stop-hbase.sh stopping hbase.........................
|
###1.1 HBase shell
进入shellhbase shell
1 2 3 4 5 6 7
| [hduser@hadoop2 applications]$ hbase shell 2014-05-20 14:48:54,159 INFO [main] Configuration.deprecation: hadoop.native.lib is deprecated. Instead, use io.native.lib.available HBase Shell; enter 'help<RETURN>' for list of supported commands. Type "exit<RETURN>" to leave the HBase Shell Version 0.96.2-hadoop2, r1581096, Mon Mar 24 16:03:18 PDT 2014 hbase(main):001:0>
|
退出shellexit
##2. 伪分布式运行
相关进程运行在同一台机器的不同JVM上,需要依赖HDFS,比较接近分布式运行,开发调试方便
###2.1 修改conf/hbase-site.xml
增加
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| <configuration> <property> <name>hbase.cluster.distributed</name> <value>true</value> </property> <property> <name>hbase.rootdir</name> <value>hdfs://hadoop2:9000/hbase</value> </property> <property> <name>hbase.zookeeper.quorum</name> <value>hadoop2</value> </property> <property> <name>hbase.zookeeper.property.datadir</name> <value>/home/hduser/zookeeper</value> </property> </configuration>
|
启动start-hbase.sh
,运行jps
,可以看到HMaster
、HRegionServer
、HQuorumPeer
三个进程在运行
1 2 3 4 5 6 7 8 9 10 11 12
| [hduser@hadoop2 conf]$ jps 4961 DataNode 14155 Jps 5130 SecondaryNameNode 13918 HQuorumPeer 12369 Main 5358 NodeManager 13980 HMaster 5260 ResourceManager 9526 Main 14097 HRegionServer 4872 NameNode
|
启动hbase shell
,手工创建一个表
1 2 3 4
| hbase(main):002:0> create 'test1','c1' 0 row(s) in 1.1310 seconds => Hbase::Table - test1
|
查看hdfs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| [hduser@hadoop2 ~]$ hdfs dfs -ls -R / drwxr-xr-x - hduser supergroup 0 2014-05-19 16:39 /abc drwxr-xr-x - hduser supergroup 0 2014-05-20 17:11 /hbase drwxr-xr-x - hduser supergroup 0 2014-05-20 17:12 /hbase/.tmp drwxr-xr-x - hduser supergroup 0 2014-05-20 17:12 /hbase/.tmp/data drwxr-xr-x - hduser supergroup 0 2014-05-20 17:12 /hbase/.tmp/data/default drwxr-xr-x - hduser supergroup 0 2014-05-20 17:11 /hbase/WALs drwxr-xr-x - hduser supergroup 0 2014-05-20 17:12 /hbase/WALs/hadoop2,60020,1400577095283 -rw-r--r-- 3 hduser supergroup 0 2014-05-20 17:11 /hbase/WALs/hadoop2,60020,1400577095283/hadoop2%2C60020%2C1400577095283.1400577104007 -rw-r--r-- 3 hduser supergroup 393 2014-05-20 17:11 /hbase/WALs/hadoop2,60020,1400577095283/hadoop2%2C60020%2C1400577095283.1400577109953.meta -rw-r--r-- 3 hduser supergroup 180 2014-05-20 17:12 /hbase/WALs/hadoop2,60020,1400577095283/hadoop2%2C60020%2C1400577095283.1400577116884.meta -rw-r--r-- 3 hduser supergroup 363 2014-05-20 17:12 /hbase/WALs/hadoop2,60020,1400577095283/hadoop2%2C60020%2C1400577095283.1400577143759.meta -rw-r--r-- 3 hduser supergroup 0 2014-05-20 17:12 /hbase/WALs/hadoop2,60020,1400577095283/hadoop2%2C60020%2C1400577095283.1400577143916.meta drwxr-xr-x - hduser supergroup 0 2014-05-20 17:11 /hbase/corrupt drwxr-xr-x - hduser supergroup 0 2014-05-20 17:09 /hbase/data drwxr-xr-x - hduser supergroup 0 2014-05-20 17:12 /hbase/data/default drwxr-xr-x - hduser supergroup 0 2014-05-20 17:12 /hbase/data/default/test1 drwxr-xr-x - hduser supergroup 0 2014-05-20 17:12 /hbase/data/default/test1/.tabledesc -rw-r--r-- 1 hduser supergroup 283 2014-05-20 17:12 /hbase/data/default/test1/.tabledesc/.tableinfo.0000000001 drwxr-xr-x - hduser supergroup 0 2014-05-20 17:12 /hbase/data/default/test1/.tmp drwxr-xr-x - hduser supergroup 0 2014-05-20 17:12 /hbase/data/default/test1/8bd0797eb991e9379975ad835c43ba20 -rwxr-xr-x 1 hduser supergroup 38 2014-05-20 17:12 /hbase/data/default/test1/8bd0797eb991e9379975ad835c43ba20/.regioninfo drwxr-xr-x - hduser supergroup 0 2014-05-20 17:12 /hbase/data/default/test1/8bd0797eb991e9379975ad835c43ba20/c1
|
###2.2 web管理界面
访问HMaster所在服务器的60010端口即可,我本机地址:http://hadoop2:60010/
##3. 升级