Ubuntu 9.0 下之HBase 0.90.4 的安装和使用
Hbase 下載 地址 http://archive.apache.org/dist/hbase/hbase-0.90.4/
解壓 tar vxf hbase-0.90.4.tar.gz
? ? ? ? ?cd hbase-0.90.4
單機版的配置
配置一個目錄?
現(xiàn)在你已經(jīng)可以啟動Hbase了。但是你可能需要先編輯?conf/hbase-site.xml?去配置hbase.rootdir,來選擇Hbase將數(shù)據(jù)寫到哪個目錄 .
<?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="configuration.xsl"?> <configuration><property><name>hbase.rootdir</name><value>file:///DIRECTORY/hbase</value></property> </configuration>將?DIRECTORY?替換成你期望寫文件的目錄. 默認?hbase.rootdir?是指向?/tmp/hbase-${user.name}?,也就說你會在重啟后丟失數(shù)據(jù)(重啟的時候操作系統(tǒng)會清理/tmp目錄)
我配置到 只要指定到一個目錄下就可以,這個目錄是用來保存創(chuàng)建表記錄。
<value>/home/liucheng/hbase0.90.4/hbase</value>參看http://www.yankay.com/wp-content/hbase/book.html
然后編輯conf/hbase-env.sh,將其中的JAVA_HOME指向到你Java的安裝目錄。
啟動 HBase
現(xiàn)在啟動Hbase:
$ ./bin/start-hbase.sh starting Master, logging to logs/hbase-user-master-example.org.out用shell連接你的Hbase 這個時候 估計 需要 30秒左右,不要 以為死了 關閉了。
$ ./bin/hbase shell HBase Shell; enter 'help<RETURN>' for list of supported commands. Type "exit<RETURN>" to leave the HBase Shell Version: 0.90.0, r1001068, Fri Sep 24 13:55:42 PDT 2010hbase(main):001:0>在創(chuàng)建表時 出現(xiàn)?
ERROR: org.apache.hadoop.hbase.ZooKeeperConnectionException: HBase is able to connect to ZooKeeper but the connection closes immediately. This could be a sign that the server has too many connections (30 is the default).具體 方式:
vi /etc/security/limits.conf在最后添加兩行:
hdfs ?- ? ? ? nofile ?32768
hbase ?- ? ? ? nofile ?32768
?解決方案參看 http://mazd1002.blog.163.com/blog/static/6657496520111121018145/
重啟下 hbase
[root@master bin]# ./stop-hbase.sh?
stopping hbase.............................
[root@master bin]# ./start-hbase.sh
(如果stop-hbase一直處于………………的狀態(tài),怎么辦?我教你一個方法,先去重新start-hbase,肯定說hbase還沒有停止,需要先停止,給你一個PID,哈哈,之后你就kill -9 pid,在執(zhí)行start-hbase.sh)
當你結束的時候,會提示 hbase 的進程號 kill 進程號 就好
在創(chuàng)建表完成 后 顯示表
list 'table'
只會顯示 TABLE
所以 顯示表 用list 就可以 把剛剛新建的表顯示出來
/home/liucheng/hbase-0.90.4/
$ ./bin/start-hbase.sh
$ ./bin/stop-hbase.sh
?
九、遇到的問題 ?
hbase(main):001:0> create 'test','cf'
?
ERROR: org.apache.hadoop.hbase.NotAllMetaRegionsOnlineException: org.apache.hadoop.hbase.NotAllMetaRegionsOnlineException: Timed out (10000ms)
?
解決方法:修改/etc/hosts。把ubuntu對應的127.0.1.1改成本機的IP。OK!
參考 http://blog.csdn.net/god_wot/article/details/6829427
Hbase 的基礎命令語法 可以參考?http://blog.csdn.net/scutshuxue/article/details/6988348
我們做一個測試;
注意:有些命令是沒有 ; 號結束的。請注意。
第一步:新建一個學生表,只有兩列,一列是name,一列是address.
? ? ? ? ? ? ?create 'stu',{name=>'name'},{name=>'address'};
? ? ? ? ? ? 同時顯示一下,list?
第二步:向學生表添加一列數(shù)據(jù),
? ? ? ? ? ? ? ? put 'stu','row1','name:1','zs';
第三步:查看一下,建表語句,
? ? ? ? ? ? ? describe ?'stu'
第四步:查看一下表內(nèi)容 scan 'stu'?
??
第五步:通過key 獲取一行數(shù)據(jù)。
? ? ? ? ? ? ? ?get ?'stu','row1'
注:如果在一個表中,列族相同,第二個列就會覆蓋第一個列。
結束,刪除表。
偽分布式的配置
第一步:到hbase 的目錄 conf 下修改hbase-site.xml 配置文件,內(nèi)容如下。第二步:啟動 hbase ?./bin/start-hbase.sh 并進入shell 命令
在我想看一下表的時候。輸放list ?但報錯了。 錯誤信息是:
ERROR: org.apache.hadoop.hbase.ZooKeeperConnectionException: HBase is able to connect to ZooKeeper but the connection closes immediately. This could be a sign that the server has too many connections (30 is the default). Consider inspecting your ZK server logs for that error and then make sure you are reusing HBaseConfiguration as often as you can. See HTable's javadoc for more information.
?按這樣修改。
Hbase 常用命令:
轉載于:https://www.cnblogs.com/java20130726/archive/2013/03/18/3218281.html
總結
以上是生活随笔為你收集整理的Ubuntu 9.0 下之HBase 0.90.4 的安装和使用的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 基于用户评价的评分模型
- 下一篇: redhat 6.2安装telnet服务