独立模式
1,从http://www.apache.org/dyn/closer.cgi/hbase/ 下载hbase
2,把下载的hbase-0.94.5.tar.gz解压到/usr/local目录下,并重命名hbase-0.94.5为hbase
3,配置环境变量
在/etc/profile.d文件夹下添加hbase.sh
添加
export HBASE_HOME=/usr/local/hbase
export PATH=${PATH}:${HBASE_HOME}/bin
修改执行权限
$sudo chmod a+x hbase.sh
4,编辑hbase-env.sh
添加:
export JAVA_HOME=/usr/lib/jvm/java7
export HBASE_LOG_DIR=/tmp/hbase/logs
不使用/usr/local/hbase/logs是因为权限问题
5,修改conf/hbase-site.xml
添加:
<configuration>
<property>
<name>hbase.rootdir</name>
<value>hdfs://localhost:9001/hbase</value>
</property>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
</configuration>
6,拷贝jars到hbase。All I know is that without it, I was getting errors like: "HBase is able to connect to ZooKeeper but the connection closes immediately".
cp ${HADOOP_HOME}/hadoop-core-*.jar ${HBASE_HOME}/lib/
cp ${HADOOP_HOME}/lib/commons-configuration-*.jar ${HBASE_HOME}/lib/
源文档 <http://www.ripariandata.com/blog/installing-apache-hbase-on-ubuntu-for-standalone-mode>
6,开始hbase
hduser@localhost:/usr/local/hbase$ bin/start-hbase.sh
starting master, logging to /tmp/hbase/logs/hbase-hduser-master-localhost.out
7,完成
hduser@localhost:/usr/local/hbase$ bin/hbase shell
hbase(main):001:0> list
出现错误:ERROR: org.apache.hadoop.hbase.MasterNotRunningException: Retried 7 times
修改hbase-env.sh,添加export HBASE_MANAGES_ZK=true来使用hbase自带的zookeeper。
启动hadoop。hduser@localhost:/usr/local/hadoop$ bin/start-all.sh
然后重新执行hbase shell
hbase(main):001:0> list
TABLE
0 row(s) in 6.8540 seconds
没有错误了,并且说明没有创建表。
1,创建表t1,列名为f1
hbase(main):002:0> create 't1','f1'
0 row(s) in 1.2290 seconds
2,写入三条数据
hbase(main):003:0> put 't1','row1','f1:1','value1'
hbase(main):004:0> put 't1','row2','f1:2','value2'
hbase(main):005:0> put 't1','row3','f1:3','value3'
3,查看插入的数据
hbase(main):006:0> scan 't1'
ROW COLUMN+CELL
row1 column=f1:1, timestamp=1362547640951, value=value1
row2 column=f1:2, timestamp=1362547656650, value=value2
row3 column=f1:3, timestamp=1362547666203, value=value3
3 row(s) in 0.1560 seconds
4,禁用后删除表
hbase(main):007:0> disable 't1'
hbase(main):008:0> drop 't1'
5,退出shell
hbase(main):010:0> quit
http://www.ripariandata.com/blog/installing-apache-hbase-on-ubuntu-for-standalone-mode