首页 > 其他 > 详细

presto-gateway 试用以及docker 镜像制作

时间:2019-08-24 12:32:04      阅读:115      评论:0      收藏:0      [点我收藏+]

presto-gateway 是 lyft 团队开源 的prestodb 的工具.以下是一个简单的试用,以及碰到问题的解决
还有就是docker 镜像的制作

Dockerfile

很简单,本地构建然后基于jdk 基础镜像,制作docker 镜像

  • 构建方法

    因为默认官方在运行的时候出现了一个索引的bug(主要是因为api 状态处理引起的),所以使用了我自己的版本

git clone https://github.com/rongfengliang/presto-gateway.git
cd presto-gateway 
mvn clean pacakge
  • Dockerfile
FROM azul/zulu-openjdk-alpine:8u222
LABEL AUTHOR="dalongrong"
LABEL EMAIL="1141591465@qq.com"
LABEL VERSION="1.6.1"
WORKDIR /
COPY gateway/target/gateway-1.6.1-jar-with-dependencies.jar /gateway.jar
COPY config.yml.template /config.yml.template
COPY entrtypoint.sh /entrtypoint.sh
RUN chmod +x /entrtypoint.sh
EXPOSE 8888 
ENTRYPOINT [ "/entrtypoint.sh"]

集成gateway 试用

  • docker-compose 文件
version: "3"
services:
  proxy:
     image: dalongrong/presto-gateway:1.6.1
     ports:
     - "8888:8888"
     - "8082:8082"
     - "8083:8083"
     build: ./
     volumes:
     - "./config.yml.template:/config.yml.template"
  presto1:
     image: starburstdata/presto
     ports:
     - "8080:8080"
  presto2:
     image: starburstdata/presto
     ports:
     - "8081:8080"
  • proxy 配置文件
requestRouter:
  port: 8888
  name: prestoRouter
  cacheDir: /var/log/prestoproxy/cache
  historySize: 1000
?
backends:
  - localPort: 8082
    name: presto1
    proxyTo: http://presto1:8080
    routingGroup: adhoc
?
  - localPort: 8083
    name: presto2
    proxyTo: http://presto2:8080
    routingGroup: scheduled
?
server:
  applicationConnectors:
    - type: http
      port: 8090
  adminConnectors:
    - type: http
      port: 8091
?
notifier:
  smtpHost: localhost
  smtpPort: 587
  sender: presto-gw-monitor-noreply@lyft.com
  recipients:
    - prestodev@yourorg.com
?
modules:
  - com.lyft.data.gateway.module.ProxyBackendProviderModule
  - com.lyft.data.gateway.module.GatewayProviderModule
  - com.lyft.data.gateway.module.NotifierModule
?
managedApps:
  - com.lyft.data.gateway.GatewayManagedApp
  - com.lyft.data.gateway.ActiveClusterMonitor
?
# Logging settings.
logging:
  # The default level of all loggers. Can be OFF, ERROR, WARN, INFO, DEBUG, TRACE, or ALL.
  level: INFO
?
  # Logger-specific levels.
  loggers:
    com.lyft: DEBUG
?
  appenders:
    - type: console
    - type: file
      currentLogFilename: /var/log/prestoproxy/prestoproxy-java.log
      archivedLogFilenamePattern: /var/log/prestoproxy/prestoproxy-java-%d{yyyy-MM-dd}-%i.log.gz
      archivedFileCount: 7
      timeZone: UTC
      maxFileSize: 100MB

nodejs client 调用

为了使用方便,修改了一现有nodejs 的presto client 支持presto-gateway

  • 代码
var presto = require(‘@dalongrong/presto-client‘);
var client = new presto.Client({
  user: ‘appdemo‘,
  host: "localhost",
  port: 8888
});
?
client.execute({
  query: ‘select * from nation2‘,
  catalog: ‘memory‘,
  schema: ‘default‘,
  source: ‘nodejs-client‘,
  routingGroup: ‘scheduled‘,
  state: function (error, query_id, stats) {
    console.log(error)
    console.log({
      message: "status changed",
      id: query_id,
      stats: stats
    });
  },
  columns: function (error, data) {
    console.log({
      resultColumns: data
    });
  },
  data: function (error, data, columns, stats) {
    console.log(data);
  },
  success: function (error, stats) {
    console.log(stats)
  },
  error: function (error) {
    console.log(error)
  }
});

访问界面效果

技术分享图片

 


技术分享图片

 

说明

对于使用可以参考官方文档,官方的截图目前有点问题,但是presto-gateway是一个很不错的工具,可以简化我们对于presto 的管理

参考资料

https://github.com/rongfengliang/presto-gateway
https://github.com/rongfengliang/presto-client-node
https://github.com/lyft/presto-gateway

presto-gateway 试用以及docker 镜像制作

原文:https://www.cnblogs.com/rongfengliang/p/11403840.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!