天天看點

一步步學習如何安裝并使用SAP HANA Express Edition

使用Jerry這篇文章 在Google Cloud platform上的Kubernetes叢集部署HANA Express

裡介紹的方法在Google Cloud Platform的Kubernetes cluster上安裝SAP HANA Express.

文中介紹了一個yaml檔案,裡面聲明了容器鏡像檔案store/saplabs/hanaexpress:2.00.033.00.20180925.2.

安裝完成後,在啟動的pod裡有兩個容器,分别運作着SQLPad和HANA Express.

SQLPad是一個基于Nodejs開發的直接在浏覽器運作SQL查詢并對結果進行可視化展示工具。SQLPad支援的資料庫非常多,比如:MySQL, Postgres, SQL Server, Vertica, Crate, Presto等。

使用kubectl get services拿到sqlpad的external IP:

在浏覽器裡輸入剛才獲得的IP位址,後面加上預設的3000端口,打開sqlpad的web控制台:

注冊一個帳戶并登入:

選擇admin-Connections:

建立一個資料庫連接配接:

database driver從下拉菜單裡選擇SAP HANA:

回到Google Cloud Platform的cloud shell,使用kubectl get services獲得hxe-connect的external IP:

把這個位址填到資料庫建立向導裡:

建立一個名為quotes的collection并插入一些資料:

create collection quotes;

insert into quotes values ( { "FROM" : 'HOMER', "TO" : 'BART',  "QUOTE" :  'I want to share something with you: The three little sentences that will get you through life. Number 1: Cover for me. Number 2: Oh, good idea, Boss! Number 3: It wai like that when I got here.', "MOES_BAR" : 'Point(  -86.880306 36.508361 )', "QUOTE_ID" : 1  });

insert into quotes values ( { "EPISODE" : 'GRADE SCHOOL CONFIDENTIAL', "FROM" : 'HOMER',   "QUOTE" :  'Wait a minute. Bart''s teacher is named Krabappel? Oh, I''ve been calling her Crandall. Why did not anyone tell me? Ohhh, I have been making an idiot out of myself!', "QUOTE_ID" : 2, "MOES_BAR" : 'Point( 2.161018 41.392641 )' });

insert into quotes values ( { "FROM" : 'HOMER',   "QUOTE" :  'Oh no! What have I done? I smashed open my little boy''s piggy bank, and for what? A few measly cents, not even enough to buy one beer. Weit a minute, lemme count and make sure…not even close.', "MOES_BAR" : 'Point( -122.400690 37.784366 )', "QUOTE_ID" : 3 });           

注意這個生成的sql collection并不是資料庫表,而是一種document store(noSQL),實際上隻是鍵值對-key value pair.

下面的SQL語句執行的操作是把document store裡的值取出進行分析,将分析結果存放到新建立的column table裡:

--Create a columnar table with a text fuzzy search index
create column table quote_analysis
(
    id integer,
    homer_quote text FAST PREPROCESS ON FUZZY SEARCH INDEX ON,
    lon_lat nvarchar(200)

);


-- Copy the quotes form the JSON store to the relational table
insert into quote_analysis
with doc_store as (select quote_id, quote from quotes)
select doc_store.quote_id as id, doc_store.quote as homer_quote, 'Point( 2.151255 41.354159 )'
from doc_store;           

本文來自雲栖社群合作夥伴“汪子熙”,了解相關資訊可以關注微信公衆号"汪子熙"。