使用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;
要获取更多Jerry的原创文章,请关注公众号"汪子熙":