hBase獨立模式的安裝與測試

獨立模式
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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章