使用Erlang和Thrift,与Hbase通信(转)
操作系统是Ubuntu Server 12.10
先安装Thrift
sudo apt-get install libboost-dev libboost-test-dev \
libboost-program-options-dev libevent-dev automake \
libtool flex bison pkg-config g++ libssl-dev
如果你还要使用别的语言,也需要安装对应的包
- Ruby
- ruby-full ruby-dev librspec-ruby rake rubygems libdaemons-ruby libgemplugin-ruby mongrel
- Python
- python-dev python-twisted
- Perl
- libbit-vector-perl
- Php, install
- php5-dev php5-cli
- C_glib
- libglib2.0-dev
- Erlang
- erlang-base erlang-eunit erlang-dev
- Csharp
- mono-gmcs libmono-dev libmono-system-web2.0-cil
- Haskell
- ghc6 cabal-install libghc6-binary-dev libghc6-network-dev libghc6-http-dev
cd thrift
./bootstrap.sh
./configure --with-boost=/usr/local
make
make install
安装Hbase
修改源码包中的conf/hbase-site.xml文件。替换成以下内容:
hbase.rootdir
file:///DIRECTORY/hbase
hbase.zookeeper.property.dataDir
/DIRECTORY/zookeeper
替换上文中对应的目录位置 修改conf/hbase-env.sh 添加JAVA_HOME export JAVA_HOME=/usr/local/jdk 启动Hbase
$ ./bin/start-hbase.sh
starting Master, logging to logs/hbase-user-master-example.org.out
$ ./bin/hbase shell
HBase Shell; enter 'help' for list of supported commands.
Type "exit" to leave the HBase Shell
Version 0.94.2, r1395367, Sun Oct 7 19:11:01 UTC 2012
hbase(main):001:0>
hbase(main):001:0> create 't1','cf'
0 row(s) in 1.6600 seconds
hbase(main):002:0> list
TABLE
t1
1 row(s) in 0.0130 seconds
hbase(main):004:0> put 't1', 'row1', 'cf:a', 'value1'
0 row(s) in 0.0330 seconds
hbase(main):005:0> put 't1', 'row2', 'cf:a', 'value2'
0 row(s) in 0.0040 seconds
hbase(main):006:0> put 't1', 'row3', 'cf:a', 'value3'
0 row(s) in 0.0040 seconds
hbase(main):007:0> scan 't1'
ROW COLUMN+CELL
row1 column=cf:a, timestamp=1352453214504, value=value1
row2 column=cf:a, timestamp=1352453236805, value=value2
row3 column=