docker 搭建OLAP系统,实践 kylin,superset

一   docker 安装kylin

参考  http://kylin.apache.org/docs/install/kylin_docker.html

1  安装docker

2  拉去kylin 

docker pull apachekylin/apache-kylin-standalone:3.1.0

3  运行kylin

docker run -d \

-m 8G \

-p 7070:7070 \

-p 8088:8088 \

-p 50070:50070 \

-p 8032:8032 \

-p 8042:8042 \

-p 16010:16010 \

apachekylin/apache-kylin-standalone:3.1.0


4  登录  http://ip:7070/kylin/models

用户:ADMIN

 密码:KYLIN


二  安装 superset

具体参考:https://superset.apache.org/docs/installation/installing-superset-from-scratch


官方文档中有docker方式,我测试没有成功,主要我大家的kylin是docker方式,两个docker 通讯的问题没有解决。

三  kylinpy安装

为了在superset中连接kylin,我们首先需要安装kylinpy。在root权限下安装kylinpy非常简单,只需要通过下列命令即可:

pipinstall--upgradekylinpy

四  superset 链接kylin


kylin://ADMIN:KYLIN@you_ip/learn_kylin

如果没有提示seems ok,可以通过以下python进行测试。

测试:

import sqlalchemy as sa

#kylin_engine = sa.create_engine('kylin://ADMIN:KYLIN@boring_goldwasser/DEFAULT')

kylin_engine = sa.create_engine('kylin://ADMIN:[email protected]/learn_kylin')

results = kylin_engine.execute('SELECT count(*) FROM KYLIN_SALES')

[e for e in results]

kylin_engine.table_names()

五 测试查询:


参考: 

http://kylin.apache.org/blog/2018/01/01/kylin-and-superset/

https://blog.csdn.net/skyyws/article/details/79529540?utm_medium=distribute.pc_relevant.none-task-blog-OPENSEARCH-7.edu_weight&depth_1-utm_source=distribute.pc_relevant.none-task-blog-OPENSEARCH-7.edu_weight

查询的sql语句,数据库对应的是learn_kylin

select YEAR_BEG_DT,

MONTH_BEG_DT,

WEEK_BEG_DT,

META_CATEG_NAME,

CATEG_LVL2_NAME,

CATEG_LVL3_NAME,

OPS_REGION,

NAME as BUYER_COUNTRY_NAME,

sum(PRICE) as GMV,

sum(ACCOUNT_BUYER_LEVEL) ACCOUNT_BUYER_LEVEL,

count(*) as CNT

from KYLIN_SALES

join KYLIN_CAL_DT on CAL_DT=PART_DT

join KYLIN_CATEGORY_GROUPINGS on SITE_ID=LSTG_SITE_ID and KYLIN_CATEGORY_GROUPINGS.LEAF_CATEG_ID=KYLIN_SALES.LEAF_CATEG_ID join KYLIN_ACCOUNT on ACCOUNT_ID=BUYER_ID

join KYLIN_COUNTRY on ACCOUNT_COUNTRY=COUNTRY

group by YEAR_BEG_DT, MONTH_BEG_DT, WEEK_BEG_DT, META_CATEG_NAME, CATEG_LVL2_NAME, CATEG_LVL3_NAME, OPS_REGION, NAME

你可能感兴趣的:(docker 搭建OLAP系统,实践 kylin,superset)