快捷搜索: 王者荣耀 脱发

Presto -- Trino391版本的集群部署

环境准备

  1. 官网地址:
  2. 下载安装包:
  3. 文档地址:
  4. trino建议使用zulu jdk 且最低版本17,所以下载
  5. 修改机器的limits.conf:
cat << EOF >>/etc/security/limits.conf
presto soft nofile 131072
presto hard nofile 131072
EOF
  1. 解压,新建etc、data目录
tar xvf trino-server-391.tar
cd trino-server-391
mkdir etc
mkdir data

修改配置

修改:node.properties

# 增加node.properties 
# vi etc/node.properties 

# 环境的名字。集群中所有的Trino节点必须具有相同的环境名称。
node.environment=trino
# 此Trino安装的唯一标识符。这对于每个节点都必须是唯一的。
node.id=2a1f445c-66d4-414e-bf6c-38cf252a6794
# 数据目录的位置(文件系统路径)。Trino在这里存储日志和其他数据。
node.data-dir=/data/services/trino-server-391/data

修改:jvm.config

# 增加etc/jvm.config 
# vi etc/jvm.config 

-server
-Xmx16G
-XX:InitialRAMPercentage=80
-XX:MaxRAMPercentage=80
-XX:G1HeapRegionSize=32M
-XX:+ExplicitGCInvokesConcurrent
-XX:+ExitOnOutOfMemoryError
-XX:+HeapDumpOnOutOfMemoryError
-XX:-OmitStackTraceInFastThrow
-XX:ReservedCodeCacheSize=512M
-XX:PerMethodRecompilationCutoff=10000
-XX:PerBytecodeRecompilationCutoff=10000
-Djdk.attach.allowAttachSelf=true
-Djdk.nio.maxCachedBufferSize=2000000
-XX:+UnlockDiagnosticVMOptions
-XX:+UseAESCTRIntrinsics

修改:config.properties

# 增加etc/config.properties
# coordinator和worker节点,该配置文件不一样,如下是coordinator配置
# vi etc/config.properties

coordinator=true
node-scheduler.include-coordinator=false
http-server.http.port=8080
discovery-server.enabled=true
discovery.uri=http://coordinator-ip:8080
# 所有节点查询可以使用的最大内存和
query.max-memory=30GB
query.max-total-memory=48GB
# 单个节点查询可以使用的最大用户内存
query.max-memory-per-node=10GB

修改:log.properties

# 增加etc/log.properties
# vi etc/log.properties

io.trino=INFO

配置hive catalog

# 新建 etc/catalog/hive.properties 
mkdir etc/catalog
vi etc/catalog/hive.properties 

connector.name=hive
hive.metastore.uri=thrift://hiveserver2-ip:9083
hive.config.resources=/data/services/trino-server-391/etc/core-site.xml,/data/services/trino-server-391/etc/hdfs-site.xml

分发配置,在worker节点修改config.properties

# 修改etc/config.properties,coordinator和worker节点,该配置文件不一样
# vi etc/config.properties

coordinator=false
http-server.http.port=8080
discovery.uri=http://coordinator-ip:8080

启动服务和验证

  1. 在每个节点启动服务
# 前台启动,第一次建议以这种方式启动,方便观察日志
bin/launcher run
# 后台启动
bin/launcher start
  1. 验证服务
http://coordinator-ip:8080/ui/login.html
用户名:trino, 密码为空

验证hive catalog

  1. 下载 trino client:
  2. 改名 mv trino-cli-391-executable.jar trino
  3. 增加可执行权限 chmod u+x trino
  4. 验证 ./trino --server http://coordinator-ip:8080 --catalog hive --schema test
  5. 查看所有表 show tables

验证jdbc连接

  1. 下载 trino jdbc driver:
  2. 配置 dbeaver
  3. 配置驱动
  4. 测试连接
  5. 程序jdbc 连接,pom:
<dependency>
    <groupId>io.trino</groupId>
    <artifactId>trino-jdbc</artifactId>
    <version>391</version>
</dependency>
经验分享 程序员 微信小程序 职场和发展