ubuntu 12.04上安裝HBase並執行
阿新 • • 發佈:2018-12-20
Ubuntu 12.04上安裝HBase並執行
作者:凱魯嘎吉 - 部落格園 http://www.cnblogs.com/kailugaji/
一、HBase的安裝
在官網上下載HBase-1.1.2,將其解壓到/home/wrr資料夾下
配置環境變數
[email protected]:~$ sudo gedit ~/.bashrc [sudo] password for wrr: [email protected]:~$ source ~/.bashrc
在.bashrc檔案最後新增
export PATH=$PATH:/home/wrr/hbase-1.1.2/bin
檢視HBase版本
[email protected]:~$ /home/wrr/hbase-1.1.2/bin/hbase version
HBase安裝成功。
二、單機模式配置
1.配置/home/wrr/hbase-1.1.2/conf/下的hbase-env.sh
在檔案末尾新增
export JAVA_HOME=/home/wrr/java/jdk1.8.0_191 export HBASE_MANAGES_ZK=true
2.配置/home/wrr/hbase-1.1.2/conf/下的hbase-site.xml
新建一個資料夾hbase-tmp
在hbase-site.xml中新增
<configuration> <property> <name>hbase.rootdir</name> <value>file:///home/wrr/hbase-1.1.2/hbase-tmp</value> </property> </configuration>
3.啟動HBase
[email protected]:~$ cd /home/wrr/hbase-1.1.2 [email protected]:~/hbase-1.1.2$ bin/start-hbase.sh [email protected]:~/hbase-1.1.2$ bin/hbase shell
三、HBase簡單操作
1.新建表
create 'student','Sname','Ssex','Sage','Sdept','course'
2.新增資料
hbase(main):003:0> put 'student','95001','Sname','LiYing' hbase(main):004:0> put 'student','95001','course:math','80'
3.刪除資料
delete 'student','95001','Ssex'
hbase(main):007:0> deleteall 'student','95001'
4.刪除表
disable 'student' drop 'student'
5.退出HBase資料庫表
6.停止HBase執行
hbase(main):012:0> exit [email protected]:~/hbase-1.1.2$ bin/stop-hbase.sh
如果想了解更多內容,請看大資料原理與應用 第四章 分散式資料庫HBase 學習指南_廈大資料庫實驗室部落格