trino是一款开源的分布式SQL查询引擎,专为大数据的交互式分析而设计。支持跨多种数据源进行联邦查询(跨源查询)
不过原版trino不支持达梦数据库,所以需要我们进行适配
先下载相关依赖,包括jdk、maven等
需要注意不同版本的trino对相关依赖要求的版本不一样,433版本trino要求使用jdk17,之后的版本要求使用更新的版本
这里以433版本为例,jdk下载地址: https://www.azul.com/downloads/#zulu
打开页面下滑,选择java17、linux、x86架构64bit,选择jdk包,下载了tgr.gz

官方下载地址: https://archive.apache.org/dist/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.zip
官方github下载地址: https://github.com/trinodb/trino/archive/refs/tags/433.tar.gz
[root@localhost bin]# vim /etc/security/limits.conf trino soft nofile 131072 trino hard nofile 131072 trino soft nproc 128000 trino hard nproc 128000
# 创建jdk目录
[root@localhost bin]# mkdir /linux_soft
# 这里已经将jdk文件放进该目录
[root@localhost bin]# ll /linux_soft
总用量 193496
-rw-r--r-- 1 root root 198138085 7月 27 11:14 zulu17.68.17-ca-jdk17.0.20-linux_4.tar.gz
# 需要解压,将解压后的jdk文件夹放到linux_soft目录下,建议对解压后的文件夹重命名,这里重命名为jdk17
[root@localhost linux_soft]# tar -zxvf zulu17.68.17-ca-jdk17.0.20-linux_x64.tar.
[root@localhost linux_soft]# mv zulu17.68.17-ca-jdk17.0.20-linux_x64 jdk17
# 修改配置文件
[root@localhost linux_soft]# vi /etc/profile
export JAVA_HOME=/linux_soft/jdk17
export PATH=$JAVA_HOME/bin:$PATH
#让修改的配置文件立刻生效
[root@localhost linux_soft]# source /etc/profile
#查询版本
[root@localhost linux_soft]# /linux_soft/jdk17/bin/java -version
openjdk version "17.0.20" 2026-07-21 LTS
OpenJDK Runtime Environment Zulu17.68+17-CA (build 17.0.20+8-LTS)
OpenJDK 64-Bit Server VM Zulu17.68+17-CA (build 17.0.20+8-LTS, mixed mode, sharing)
#看一下path是否配置成功了
[root@localhost linux_soft]# java -version
openjdk version "17.0.20" 2026-07-21 LTS
OpenJDK Runtime Environment Zulu17.68+17-CA (build 17.0.20+8-LTS)
OpenJDK 64-Bit Server VM Zulu17.68+17-CA (build 17.0.20+8-LTS, mixed mode, sharing)
#将解压后的manven文件夹放到linux_soft下
[root@localhost linux_soft]# ls
apache-maven-3.6.3-bin.zip jdk17
[root@localhost linux_soft]# unzip apache-maven-3.6.3-bin.zip
Archive: apache-maven-3.6.3-bin.zip
【解压输出略】
[root@localhost linux_soft]# ls
apache-maven-3.6.3 apache-maven-3.6.3-bin.zip jdk17
# 配置maven路径
[root@localhost linux_soft]# vi /etc/profile
export JAVA_HOME=/linux_soft/jdk17
export MAVEN_HOME=/linux_soft/apache-maven-3.6.3
export PATH=$JAVA_HOME/bin:$MAVEN_HOME/bin:$PATH
# 使修改过的配置立刻生效
[root@localhost linux_soft]# source /etc/profile
# 查看mvn版本是否正确
[root@localhost linux_soft]# mvn -version
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /linux_soft/apache-maven-3.6.3
Java version: 17.0.20, vendor: Azul Systems, Inc., runtime: /linux_soft/jdk17
Default locale: zh_CN, platform encoding: UTF-8
OS name: "linux", version: "4.19.90-89.11.v2401.ky10.x86_64", arch: "amd64", family: "unix"
修改settings.xml
#创建本地仓库目录
[root@localhost linux_soft]# mkdir /linux_soft/apache-maven-3.6.3/repo
[root@localhost linux_soft]# vi /linux_soft/apache-maven-3.6.3/conf/settings.xml
写入或修改如下内容:
<localRepository>/linux_soft/apache-maven-3.6.3/repo</localRepository>
<!-- 修改镜像源地址 -->
<mirrors>
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>*</mirrorOf>
</mirror>
</mirrors>
在trino的pom.xml里加入如下内容指定国内镜像源
<repositories> <repository> <id>aliyun1</id> <url>https://maven.aliyun.com/repository/public/</url> </repository> <repository> <id>aliyun2</id> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> </repository> <repository> <id>tencent1</id> <url>https://mirrors.cloud.tencent.com/nexus/repository/maven-public/</url> </repository> <repository> <id>gw1</id> <url>http://search.maven.org</url> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>tencent</id> <url>https://mirrors.cloud.tencent.com/nexus/repository/maven-public/</url> </pluginRepository> </pluginRepositories>
新建一个目录存放相关文件
[root@localhost linux_soft]# mkdir /trino_src [root@localhost linux_soft]# cd /trino_src [root@localhost trino_src]# ls trino-433.tar.gz [root@localhost trino_src]# tar -zxf trino-433.tar.gz [root@localhost trino_src]# ls trino-433 trino-433.tar.gz [root@localhost trino_src]# cd trino-433/
需要注意,下载的tar.gz包里没有.git目录,不存在git信息,导致一个需要该信息的插件无法无法编译,于是在这里自己init了一下
git init -b main git add .gitignore git commit -m "ignore" git add . git commit -m "first"
开始构建,需要注意第一次构建时需要下载很多包
[root@localhost trino-433]# ./mvnw install -DskipTests -rf :trino-testing-services -pl '!docs'
编译的时候可以用下列参数加快构建
-pl '!docs':排除非必需的docs模块-DskipTests=true:跳过测试,能节省构建时间,但容易导致无法发现代码中的潜在问题-DfailIfNoTests=false:防止因某些模块没有测试用例而构建失败-rf :trino-testing-services命令表示从上次失败的某个模块(这里是trino-testing-services)的位置继续,用于加快构建等待编译完成
下载idea linux版本,解压出来用
[root@localhost ~]# sudo tar -zxvf ~/idea-2026.2.0.1.tar.gz -C /linux_soft/ [root@localhost ~]# cd /linux_soft/ [root@localhost linux_soft]# ls apache-maven-3.6.3 apache-maven-3.6.3-bin.zip idea-IU-262.8665.337 jdk17 [root@localhost linux_soft]# mv idea-IU-262.8665.337 idea [root@localhost linux_soft]# ls apache-maven-3.6.3 apache-maven-3.6.3-bin.zip idea jdk17
用idea打开项目

按照该结构创建/修改相关配置文件
/trino_src/trino-433/testing/trino-server-dev/etc
|-->node.properties
|-->jvm.config
|-->config.propoerties
|-->log.propoerties
|-->catalog
|-->testmysql.properties
|-->dameng.properties
配置node.properties
[root@localhost bin]# cd /trino_src/trino-433/testing/trino-server-dev/etc [root@localhost etc]# mkdir /trino_src/trino_data [root@localhost etc]# vim node.properties node.environment=production node.id=ffffffff-ffff-ffff-ffff-ffffffffffff node.data-dir=/trino_src/trino_data
配置jvm.config
[root@localhost etc]# vim jvm.config
-server
-Xmx4G
-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=200000
-XX:+UnlockDiagnosticVMOptions
-XX:+UseAESCTRIntrinsics
# Disable Preventive GC for performance reasons (JDK-8293861)
-XX:-G1UsePreventiveGC
配置config.properties
[root@localhost etc]# vim config.properties http-server.http.port=8080 discovery.uri=http://localhost:8080 exchange.http-client.max-connections=1000 exchange.http-client.max-connections-per-server=1000 exchange.http-client.connect-timeout=1m exchange.http-client.idle-timeout=1m scheduler.http-client.max-connections=1000 scheduler.http-client.max-connections-per-server=1000 scheduler.http-client.connect-timeout=1m scheduler.http-client.idle-timeout=1m query.client.timeout=5m query.min-expire-age=30m plugin.bundles=\ ../../plugin/trino-resource-group-managers/pom.xml,\ ../../plugin/trino-password-authenticators/pom.xml, \ ../../plugin/trino-iceberg/pom.xml,\ ../../plugin/trino-delta-lake/pom.xml,\ ../../plugin/trino-blackhole/pom.xml,\ ../../plugin/trino-cassandra/pom.xml,\ ../../plugin/trino-memory/pom.xml,\ ../../plugin/trino-jmx/pom.xml,\ ../../plugin/trino-raptor-legacy/pom.xml,\ ../../plugin/trino-hive-hadoop2/pom.xml,\ ../../plugin/trino-hudi/pom.xml,\ ../../plugin/trino-example-http/pom.xml,\ ../../plugin/trino-kafka/pom.xml, \ ../../plugin/trino-tpch/pom.xml, \ ../../plugin/trino-local-file/pom.xml, \ ../../plugin/trino-mysql/pom.xml,\ ../../plugin/trino-mariadb/pom.xml,\ ../../plugin/trino-singlestore/pom.xml,\ ../../plugin/trino-sqlserver/pom.xml, \ ../../plugin/trino-prometheus/pom.xml, \ ../../plugin/trino-postgresql/pom.xml, \ ../../plugin/trino-thrift/pom.xml, \ ../../plugin/trino-tpcds/pom.xml, \ ../../plugin/trino-google-sheets/pom.xml, \ ../../plugin/trino-druid/pom.xml, \ ../../plugin/trino-geospatial/pom.xml, \ ../../plugin/trino-http-event-listener/pom.xml, \ ../../plugin/trino-exchange-filesystem/pom.xml, \ ../../plugin/trino-exchange-hdfs/pom.xml, \ ../../plugin/trino-mysql-event-listener/pom.xml node-scheduler.include-coordinator=true
新建log.properties
[root@localhost etc]# vim log.properties
io.trino=INFO
# show classpath for plugins
io.trino.server.PluginManager=DEBUG
# Maven plugin loading code
com.ning.http.client=WARN
配置mysql数据源
#在etc目录下新建catalog目录 存放数据源
[root@localhost etc]# mkdir -p /trino_src/trino-433/testing/trino-server-dev/etc/catalog
[root@localhost etc]# cd catalog/
[root@localhost catalog]# vim testmysql.properties
connector.name=mysql
connection-url=jdbc:mysql://localhost:3306
connection-user=root
connection-password=Maria123
修改DevelopmentServer类的配置

虚拟机选项:
-ea -XX:+UseG1GC -XX:G1HeapRegionSize=32M -XX:+UseGCOverheadLimit -XX:+ExplicitGCInvokesConcurrent -Xmx2G -Dconfig=etc/config.properties -Dlog.levels-file=etc/log.properties
工作目录:
$MODULE_DIR$
修改后,运行成功,可以在 http://localhost:8080/ui/login.html 打开,默认账号admin,没有密码

确认一下是否编译出trino-cli-*-executable.jar,使用jar包进行测试
[root@localhost trino-433]# ls -l /trino_src/trino-433/client/trino-cli/target/trino-cli-*-executable.jar -rwx--x--x 1 root root 13935813 7月 27 15:32 /trino_src/trino-433/client/trino-cli/target/trino-cli-433-executable.jar
[root@localhost trino-433]# java -jar /trino_src/trino-433/client/trino-cli/target/trino-cli-433-executable.jar --server localhost:8080
trino> CREATE SCHEMA testmysql.test_decimal;
CREATE SCHEMA
trino> CREATE TABLE testmysql.test_decimal.test_decimal (delta DECIMAL(10, 5));
->
CREATE TABLE
trino> INSERT INTO testmysql.test_decimal.test_decimal VALUES (12345.06789);
->
INSERT: 1 row
Query 20260728_062912_00008_w3pr4, FINISHED, 1 node
Splits: 19 total, 19 done (100.00%)
0.60 [0 rows, 0B] [0 rows/s, 0B/s]
trino> SELECT * FROM testmysql.test_decimal.test_decimal;
->
delta
-------------
12345.06789
(1 row)
Query 20260728_062921_00009_w3pr4, FINISHED, 1 node
Splits: 1 total, 1 done (100.00%)
0.24 [1 rows, 0B] [4 rows/s, 0B/s]
trino>
测试连接成功
添加导入trino-dameng模块,这里用的是435版本进行修改
[root@localhost trino-433]# cd /root [root@localhost ~]# ls 公共 视频 文档 音乐 anaconda-ks.cfg initial-setup-ks.cfg 模板 图片 下载 桌面 idea-2026.2.0.1.tar.gz trino-dameng.zip [root@localhost ~]# unzip trino-dameng.zip 【解压过程略】 [root@localhost ~]# ls 公共 视频 文档 音乐 anaconda-ks.cfg initial-setup-ks.cfg trino_src 模板 图片 下载 桌面 idea-2026.2.0.1.tar.gz trino-dameng.zip [root@localhost ~]# mv trino_src/trino-435/plugin/trino-dameng /trino_src/trino-433/plugin/ [root@localhost ~]# ls /trino_src/trino-433/trino-dameng 1.txt pom.xml src
修改trino-dameng模块的pom.xml为trino框架的实际版本,此处是433

修改达梦驱动版本,pom中内置的8.1.2.192驱动,可按需调整

修改根的pom.xml文件,添加trino-dameng的文件,这行一定要放到trino-c开头的最后一个模块后面,不然后面编译不通过(可以用命令自动调整顺序)
mvn com.github.ekryd.sortpom:sortpom-maven-plugin:3.3.0:sort

在dependency中添加达梦的依赖,这部分一定要放到trino-c开头的最后一个模块后面(这里trino-dameng模块弄错了顺序,但内容是对的)

屏蔽掉语法检查,不然多个空格少个空格都报错

修改trino-server模块的trino.xml文件

修改config.properties文件的插件部分

重新编译
[root@localhost trino-433]# cd /trino_src/trino-433 [root@localhost trino-433]# ./mvnw -pl '!docs' clean install -DskipTests=true -DfailIfNoTests=false
pom.xml里的435一定要替换,不然会导致编译失败,如果编译出错,修改后可以使用-rf :trino-dameng指定从dameng模块继续编译(其他模块也类似)
编译成功
[INFO] ------------------------------------------------------------------------ [INFO] Reactor Summary for trino-dameng 433: [INFO] [INFO] trino-dameng ....................................... SUCCESS [ 22.698 s] [INFO] trino-jmx .......................................... SUCCESS [ 7.085 s] [INFO] trino-testing-resources ............................ SUCCESS [ 2.461 s] [INFO] trino-delta-lake ................................... SUCCESS [ 52.769 s] [INFO] trino-druid ........................................ SUCCESS [ 6.083 s] [INFO] trino-elasticsearch ................................ SUCCESS [ 9.479 s] [INFO] trino-example-http ................................. SUCCESS [ 3.951 s] [INFO] trino-example-jdbc ................................. SUCCESS [ 3.820 s] [INFO] trino-exchange-hdfs ................................ SUCCESS [ 13.504 s] [INFO] trino-geospatial ................................... SUCCESS [ 12.774 s] [INFO] trino-google-sheets ................................ SUCCESS [ 4.880 s] [INFO] trino-http-event-listener .......................... SUCCESS [ 3.433 s] [INFO] trino-hudi ......................................... SUCCESS [ 29.027 s] [INFO] trino-iceberg ...................................... SUCCESS [ 45.878 s] [INFO] trino-ignite ....................................... SUCCESS [ 5.936 s] [INFO] trino-testing-kafka ................................ SUCCESS [ 2.104 s] [INFO] trino-kafka ........................................ SUCCESS [ 11.965 s] [INFO] trino-kinesis ...................................... SUCCESS [ 7.053 s] [INFO] trino-kudu ......................................... SUCCESS [ 7.344 s] [INFO] trino-local-file ................................... SUCCESS [ 3.548 s] [INFO] trino-mariadb ...................................... SUCCESS [ 5.039 s] [INFO] trino-ml ........................................... SUCCESS [ 5.340 s] [INFO] trino-mongodb ...................................... SUCCESS [ 6.527 s] [INFO] trino-mysql ........................................ SUCCESS [ 6.059 s] [INFO] trino-mysql-event-listener ......................... SUCCESS [ 3.497 s] [INFO] trino-oracle ....................................... SUCCESS [ 7.836 s] [INFO] trino-phoenix5 ..................................... SUCCESS [ 17.256 s] [INFO] trino-pinot ........................................ SUCCESS [ 18.583 s] [INFO] trino-postgresql ................................... SUCCESS [ 6.149 s] [INFO] trino-prometheus ................................... SUCCESS [ 5.029 s] [INFO] trino-raptor-legacy ................................ SUCCESS [ 15.516 s] [INFO] trino-redis ........................................ SUCCESS [ 6.040 s] [INFO] trino-redshift ..................................... SUCCESS [ 5.981 s] [INFO] trino-resource-group-managers ...................... SUCCESS [ 6.351 s] [INFO] trino-session-property-managers .................... SUCCESS [ 6.483 s] [INFO] trino-singlestore .................................. SUCCESS [ 4.185 s] [INFO] trino-sqlserver .................................... SUCCESS [ 5.448 s] [INFO] trino-teradata-functions ........................... SUCCESS [ 2.368 s] [INFO] trino-thrift-testing-server ........................ SUCCESS [ 19.051 s] [INFO] trino-thrift ....................................... SUCCESS [ 5.031 s] [INFO] trino-proxy ........................................ SUCCESS [ 5.311 s] [INFO] trino-verifier ..................................... SUCCESS [ 11.120 s] [INFO] trino-benchmark-queries ............................ SUCCESS [ 0.663 s] [INFO] trino-benchto-benchmarks ........................... SUCCESS [ 45.157 s] [INFO] trino-tests ........................................ SUCCESS [ 14.262 s] [INFO] trino-faulttolerant-tests .......................... SUCCESS [ 4.882 s] [INFO] trino-plugin-reader ................................ SUCCESS [ 24.588 s] [INFO] trino-product-tests ................................ SUCCESS [01:42 min] [INFO] trino-product-tests-launcher ....................... SUCCESS [ 38.783 s] [INFO] trino-server-dev ................................... SUCCESS [ 3.717 s] [INFO] trino-test-jdbc-compatibility-old-driver ........... SUCCESS [ 1.667 s] [INFO] trino-test-jdbc-compatibility-old-server ........... SUCCESS [ 1.405 s] [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 11:10 min [INFO] Finished at: 2026-07-29T10:28:01+08:00 [INFO] ------------------------------------------------------------------------ [root@localhost trino-433]#
添加配置文件
[root@localhost catalog]# pwd /trino_src/trino-433/testing/trino-server-dev/etc/catalog [root@localhost catalog]# cat dameng.properties connector.name=dameng connection-url=jdbc:dm://localhost:5236 connection-user=SYSDBA connection-password=Dameng123
测试dameng连接并操作
[root@localhost target]# java -jar trino-cli-433-executable.jar --server http://localhost:8080
trino> SHOW CATALOGS;
Catalog
---------
dameng
system
(2 rows)
Query 20260729_032947_00000_v86sj, FINISHED, 1 node
Splits: 11 total, 11 done (100.00%)
1.78 [0 rows, 0B] [0 rows/s, 0B/s]
trino> CREATE SCHEMA dameng.test_decimal;
CREATE SCHEMA
trino> CREATE TABLE dameng.test_decimal.test_decimal (delta DECIMAL(10, 5));
CREATE TABLE
trino> INSERT INTO dameng.test_decimal.test_decimal VALUES (12345.06789);
INSERT: 1 row
Query 20260729_033250_00003_v86sj, FINISHED, 1 node
Splits: 19 total, 19 done (100.00%)
0.97 [0 rows, 0B] [0 rows/s, 0B/s]
trino> SELECT * FROM dameng.test_decimal.test_decimal;
delta
-------------
12345.06789
(1 row)
Query 20260729_033255_00004_v86sj, FINISHED, 1 node
Splits: 1 total, 1 done (100.00%)
0.39 [1 rows, 0B] [2 rows/s, 0B/s]
trino>
ok,测试正常,可以连接达梦数据库,数据精度也无问题,一切完成
可以将编译的plugin/trino-dameng插件打包,用于分享给其他人用
[root@localhost target]# cd /root [root@localhost ~]# tar -czvf trino-dameng-433-plugin.tar.gz /trino_src/trino-433/plugin/trino-dameng/target/trino-dameng-433/ 【打包过程略】
文章
阅读量
获赞
