Hbase实战
Hbase实战
AlexHbase实战
Hbase安装
- 工具包:
hbase-0.98.24-hadoop1-bin.tar.gz
1
tar zxvf hbase-0.98.24-hadoop1-bin.tar.gz
- 分别配置:
- bashrc:环境变量
- regionservers:节点host
- hbase-env.sh:环境变量
- hbase-site.xml:
1
cd hbase-0.98.0-hadoop1/conf
vi 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
23
24
25
26<configuration>
<property>
## 临时文件缓存目录
<name>hbase.tmp.dir</name>
<value>/var/hbase</value>
</property>
<property>
<name>hbase.rootdir</name>
<value>hdfs://master:9000/hbase</value>
</property>
<property>
## 是否分布式
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
<property>
## zookeeper集群
<name>hbase.zookeeper.quorum</name>
<value>master,slave1,slave2</value>
</property>
<property>
## zookeeper快照信息存储目录
<name>hbase.sookeeper.proper.dataDir</name>
<value>/usr/local/src/hbase-0.98.0-hadoop1/zookeeper</value>
</property>
</configuration>vi hbase-env.sh
1
2
3export JAVA_HOME=/usr/local/src/jdk1.6.0_45/
export CLASSPATH=.:$CLASSPATH:$JAVA_HOME/lib
export HBASE_MANAGES_ZK=true ## false使用单独搭建的zookeepervi regionservers
1
2
3master ## 可带master,可不带,如果带上标示master主即当主又当从
slave1
slave2vi ~/.bashrc
1
2
3
4### Hbase conf
export HBASE_HOME=/usr/local/src/hbase-0.98.0-hadoop1
export HBASE_CLASSPATH=$HBASE_HOME/conf
export HBASE_LOG_DIR=$HBASE_HOME/logs- 启动测试
启动进入终端
/hbase shell
1
2
3
4
5
6
7
8
9[root@master bin]# ./hbase shell
HBase Shell; enter 'help<RETURN>' for list of supported commands.
Type "exit<RETURN>" to leave the HBase Shell
Version 0.98.0-hadoop1, r1565492, Thu Feb 6 16:20:15 PST 2014
hbase(main):001:0> status
3 servers, 0 dead, 0.6667 average load
hbase(main):002:0>指定hadoop目录,指定zookeeper
Hbase基础用法
1
2
3create 'music' 'meta_data','action' # 创建表
describe 'musicmeta_data' # 查看表信息
alter 'musicmeta_data' ,{NAME=>'action',METHOD=>'delete'} ## 删除
安装Thrift:
1 | wget http://archive.apache.org/dist/thrift/0.8.0/thrift-0.8.0.tar.gz |
源码包编译安装
1
2
3./configure --with-cpp=no --with-ruby=no
make
make install下载Hbase Api
1
2
3
4
5
6
7
8
9
10wget http://archive.apache.org/dist/hbase/0.98.24/hbase-0.98.24-src.tar.gz
tar -zxvf hbase-0.98.24-src.tar.gz
cd hbase-0.98.24
find . -name Hbase.thrift
# ./hbase-thrift/src/main/resources/org/apache/hadoop/hbase/thrift/Hbase.thrift
–./hbase-thrift/src/main/resources/org/apache/hadoop/hbase/thrift/Hbase.thrift
cd ./hbase-thrift/src/main/resources/org/apache/hadoop/hbase/thrift
thrift -gen py Hbase.thrift
cp -r gen-py ~/hbase_test启动
1
/usr/local/src/hbase-0.98.24/bin/hbase-daemon.sh start thrift
上传测试文件到HDFS
1
/usr/local/src/hadoop-1.2.1/bin/hadoop fs -put input.data /
运行
1
bash run.sh