MAC單機部署HBase+Phoenix

一、brew安裝HBase:

brew install hbase

1:運行結果

Updating Homebrew...
==> Installing dependencies for hbase: lzo
==> Installing hbase dependency: lzo
==> Downloading https://homebrew.bintray.com/bottles/lzo-2.10.catalina.bottle.tar.gz
Already downloaded: /Users/duchao/Library/Caches/Homebrew/downloads/24d54a83f3cd4083745a790e68a7664c8bc1747af893d6a271c1c77c1953af43--lzo-2.10.catalina.bottle.tar.gz
==> Pouring lzo-2.10.catalina.bottle.tar.gz
🍺  /usr/local/Cellar/lzo/2.10: 31 files, 546.7KB
==> Installing hbase
==> Downloading https://homebrew.bintray.com/bottles/hbase-1.3.5.catalina.bottle.tar.gz
Already downloaded: /Users/duchao/Library/Caches/Homebrew/downloads/d073cc999dc121170a4a142598a9a2c4e271d0f6ba5f50d73b9132c5560d2966--hbase-1.3.5.catalina.bottle.tar.gz
==> Pouring hbase-1.3.5.catalina.bottle.tar.gz
==> Caveats
To have launchd start hbase now and restart at login:
  brew services start hbase
Or, if you don't want/need a background service you can just run:
  /usr/local/opt/hbase/bin/start-hbase.sh
==> Summary
🍺  /usr/local/Cellar/hbase/1.3.5: 10,226 files, 345.8MB
==> Caveats
==> hbase
To have launchd start hbase now and restart at login:
  brew services start hbase
Or, if you don't want/need a background service you can just run:
  /usr/local/opt/hbase/bin/start-hbase.sh

2:修改JAVAHOME

/usr/local/Cellar/hbase/1.3.5/libexec/conf目錄下hbase-env.sh文件中JAVA_HOME屬性

3:修改內建zookeeper配置

/usr/local/Cellar/hbase/1.3.5/libexec/conf目錄下hbase-site.xml文件中修改下面屬性

<property>
    <name>hbase.zookeeper.property.dataDir</name>
    <!-- 這裏valu值自己調整 -->
    <value>/Users/duchao/Code/server/zk</value>
</property>

4:啓動HBase

brew services start hbase

5:檢查HBase是否安裝成功

執行命令jps, 有HMaster說明安裝成功

6:停止HBase

brew services stop hbase

7:常用hbase shell命令

二、Phonenix部署

1. 下載Phonenix

phonenix下載地址下載hbase對應版本的包,並解壓在合適目錄

2.將Phonenix目錄下的phoenix-4.15.0-HBase-1.3-server.jar和phoenix-core-4.15.0-HBase-1.3.jar放到HBase的lib目錄下(/usr/local/Cellar/hbase/1.3.5/libexec/lib)

3.重啓HBase

brew services stop hbase
brew services start hbase

4.啓動Phoenix

在phoenix目錄下bin中運行./sqlline.py 127.0.0.1:2181
運行結果:

Setting property: [incremental, false]
Setting property: [isolation, TRANSACTION_READ_COMMITTED]
issuing: !connect jdbc:phoenix:127.0.0.1:2181 none none org.apache.phoenix.jdbc.PhoenixDriver
Connecting to jdbc:phoenix:127.0.0.1:2181
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.apache.hadoop.security.authentication.util.KerberosUtil (file:/Users/duchao/Code/server/apache-phoenix-4.15.0/phoenix-4.15.0-HBase-1.3-client.jar) to method sun.security.krb5.Config.getInstance()
WARNING: Please consider reporting this to the maintainers of org.apache.hadoop.security.authentication.util.KerberosUtil
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
20/05/20 09:08:53 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Connected to: Phoenix (version 4.15)
Driver: PhoenixEmbeddedDriver (version 4.15)
Autocommit status: true
Transaction isolation: TRANSACTION_READ_COMMITTED
Building list of tables and columns for tab-completion (set fastconnect to true to skip)...
154/154 (100%) Done
Done
sqlline version 1.5.0

5.測試sql運行

-- 創建訂單
CREATE TABLE IF NOT EXISTS tbl_order (
	id BIGINT not null primary key,
	order_code char(20),
	total_amount decimal(10,2),
	create_time date,
	user_id bigint
);
-- 插入數據
upsert into tbl_order values(1, 'A001', 10.5, '2019-3-19 23:35:00', 1);
upsert into tbl_order values(2, 'A002', 60.0, '2019-3-19 23:36:00', 2);
upsert into tbl_order values(3, 'B001', 66.6, '2019-3-20 01:01:00', 3);
upsert into tbl_order values(4, 'C001', 66.4, '2019-3-20 02:01:00', 3);
-- 查詢表數據
select * from tbl_order;

到此部署完成,下一篇介紹通過springboot+mybatis-plus集成phonenix完成增刪改查功能

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