Hadoop之HBase快速入門

來源:互聯網
上載者:User
Hadoop之HBase快速入門

cheungmine

2012-4-20

本文解決單機(standlone)運行HBase的故障問題。讀者可以快速領略HBase的基本Shell命令。


第一步 準備軟體

機器環境:Ubuntu11.10+JDK1.6

下載軟體:hbase-0.92.1.tar.gz

我的使用者名稱為:cl

我的機器名為:thinkpad-zh

解壓縮hbase:

$ tar xzf /home/cl/Downloads/hbase-0.92.1.tar.gz

複製到目錄下:

/home/hbase-0.92.1

第二步 配置HBase

更改配置:

1)配置JDK路徑

.../hbase-0.92.1/conf/hbase-env.sh

修改下面的行:
# export JAVA_HOME=/usr/java/jdk1.6.0/
export JAVA_HOME=/usr/local/java/jdk1.6.0_30

2)設定資料庫檔案路徑

.../hbase-0.92.1/conf/hbasev-site.xml

修改為下面的:

<configuration>
  <property>
    <name>hbase.rootdir</name>
    <value>file:///home/cl/hbase_data</value>
  </property>
</configuration>

第三步 使用命令列

1)啟動hbase資料庫

cl@thinkpad-zh:/home/hbase-0.92.1/bin$ ./start-hbase.sh


2)停止hbase資料庫命令:
...$ ./stop-hbase.sh

3)常見問題

日誌在:

.../hbase-0.92.1/logs/hbase-cl-master-thinkpad-zh.log

如果發現日誌中出現:

... WARN org.apache.hadoop.hbase.master.AssignmentManager: Unable to find a viable location to assign region -ROOT-,,0.70236052

則後面無法建立表(create 'tablename' 會無限期等待)


此時需要修改:

$ sudo vi /etc/hosts

為:

127.0.0.1 localhost
#127.0.1.1 thinkpad-zh
127.0.0.1 thinkpad-zh


重新啟動資料庫(如果已經存在進程nnnn,則先  $ kill nnnn):

cl@thinkpad-zh:/home/hbase-0.92.1/bin$ ./start-hbase.sh
starting master, logging to /home/hbase-0.92.1/bin/../logs/hbase-cl-master-thinkpad-zh.out


4)運行hbase shell命令工具

cl@thinkpad-zh:/home/hbase-0.92.1/bin$ ./hbase shell
HBase Shell; enter 'help<RETURN>' for list of supported commands.
Type "exit<RETURN>" to leave the HBase Shell
Version 0.92.1, r1298924, Fri Mar  9 16:58:34 UTC 2012


5)建立表

hbase(main):001:0> create 'my_first_table', 'col1', 'col2'
0 row(s) in 1.6050 seconds

hbase(main):002:0>

hbase(main):002:0> list 'my_first_table'
TABLE                                                                           
my_first_table                                                                  
1 row(s) in 0.0150 seconds

6)退出shell

hbase(main):003:0> exit


7)停止hbase資料庫

cl@thinkpad-zh:/home/hbase-0.92.1/bin$ ./stop-hbase.sh
stopping hbase............
cl@thinkpad-zh:/home/hbase-0.92.1/bin$

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.