Ubuntu 22.04 单节点部署 Presto 指南
在 1 台 Ubuntu 22.04 服务器上以单节点模式(coordinator 与 worker 同机,node-scheduler.include-coordinator=true)部署 Presto 0.299,用于测试与开发。覆盖 JDK17、官方二进制下载、配置、systemd 启动与 tpch 单机查询验证,命令与输出实测通过。
PrestoPresto安装部署Ubuntu 22.04systemd 托管大数据数据仓库OLAP查询引擎大数据与计算引擎2026/10/02
Ubuntu 22.04 单节点部署 Presto 指南
目标:在 1 台 Ubuntu 22.04 服务器上以单节点模式部署 Presto 0.299。单节点模式下同一 JVM 既当 coordinator 又当 worker(
node-scheduler.include-coordinator=true),适合测试、开发与小型环境。本文命令与输出均在该单机环境实测。
环境信息
| 信息项 | 值 |
|---|---|
| 操作系统 | Ubuntu 22.04.5 LTS |
| Presto 版本 | 0.299 |
| JDK | OpenJDK 17.0.20(Presto 0.299 要求 Java 17) |
| 部署方式 | 官方 tar.gz + systemd 托管 |
| 模式 | 单节点(coordinator + worker 同机) |
| 主机 | presto-single,IP 10.0.0.24,node.id=presto-single |
| 默认端口 | 8080 |
前置条件
- 1 台 Ubuntu 22.04 服务器,root 或 sudo
- 至少 4GB 可用内存(JVM
-Xmx按机器内存调整) - 网络可访问 Maven Central(Server 包)与 GitHub(CLI)
第一步:安装 JDK17
apt-get update
apt-get install -y openjdk-17-jdk-headless curl wget tar vim
java -version
实测:
openjdk version "17.0.20.1" 2026-08-18
第二步:下载解压
mkdir -p /opt/data/presto
cd /opt/data/presto
wget https://repo1.maven.org/maven2/com/facebook/presto/presto-server/0.299/presto-server-0.299.tar.gz
tar -xzf presto-server-0.299.tar.gz
第三步:配置
cd /opt/data/presto/presto-server-0.299
mkdir -p etc/catalog /opt/data/presto/data
node.properties:
node.environment=presto
node.id=presto-single
node.data-dir=/opt/data/presto/data
jvm.config(2G 堆实测):
-server
-Xmx2G
-XX:+UseG1GC
-XX:G1HeapRegionSize=32M
-XX:+ExplicitGCInvokesConcurrent
-XX:+HeapDumpOnOutOfMemoryError
-XX:+ExitOnOutOfMemoryError
-Djdk.attach.allowAttachSelf=true
⚠️ 必须加
-Djdk.attach.allowAttachSelf=true,否则 JDK17 下启动直接失败(Can not attach to current VM)。
config.properties(单节点关键:coordinator=true 且 node-scheduler.include-coordinator=true,discovery.uri 指向本机):
coordinator=true
node-scheduler.include-coordinator=true
http-server.http.port=8080
query.max-memory=5GB
query.max-memory-per-node=1GB
query.max-total-memory-per-node=1GB
discovery-server.enabled=true
discovery.uri=http://10.0.0.24:8080
log.properties:
com.facebook.presto=INFO
catalog(自包含连接器;mysql/postgresql/hive 示例见《配置文件详解》):
cd etc/catalog
echo 'connector.name=jmx' > jmx.properties
echo 'connector.name=tpch' > tpch.properties
echo 'connector.name=tpcds' > tpcds.properties
第四步:systemd 启动
[Unit]
Description=Presto Server
After=network.target
[Service]
Type=simple
User=root
Environment=JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
WorkingDirectory=/opt/data/presto/presto-server-0.299
ExecStart=/opt/data/presto/presto-server-0.299/bin/launcher run
Restart=on-failure
[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl enable --now presto
systemctl is-active presto # active
日志确认启动成功:
journalctl -u presto --no-pager | grep "SERVER STARTED"
实测输出:
======= SERVER STARTED =======
第五步:下载 CLI 并验证
cd /opt/data/presto
wget https://github.com/prestodb/presto/releases/download/0.299/presto-cli-0.299-executable.jar -O presto
chmod +x presto
查看 catalog:
./presto --server http://10.0.0.24:8080 --catalog tpch --schema sf1 --execute "SHOW CATALOGS"
实测输出:
hive
jmx
mysql
postgresql
system
tpcds
tpch
TPC-H 单机查询:
./presto --server http://10.0.0.24:8080 --catalog tpch --schema sf1 \
--execute "SELECT count(*) AS n FROM tpch.sf1.lineitem"
实测输出:
"6001215"
注意事项
- 单节点必须
node-scheduler.include-coordinator=true,否则协调节点不参与 worker 计算,本地无 worker 时任何查询都会失败 - 内存配置:
query.max-total-memory-per-node(含 heap headroom)需小于-Xmx,否则报Invalid memory configuration - 仅用于测试/开发;生产多用户高并发建议参考《分布式部署 Presto 集群指南》拆分为 coordinator + worker
卸载方式
systemctl disable --now presto
rm -rf /opt/data/presto/presto-server-0.299 /opt/data/presto/data
rm -f /etc/systemd/system/presto.service && systemctl daemon-reload
参考链接
- 官方单机部署示例:https://prestodb.github.io/docs/current/installation/deployment.html
- Server 包:https://repo1.maven.org/maven2/com/facebook/presto/presto-server/
- GitHub Releases(CLI):https://github.com/prestodb/presto/releases
本文档由 www.quzuo.net 平台开发
章节目录