「Trino」:修訂間差異
跳至導覽
跳至搜尋
(未顯示同一使用者於中間所作的 42 次修訂) | |||
第4行: | 第4行: | ||
PrestoSQL是fork自[[Presto]]的專案,後來成立公司。在2018年時Facebook出面阻止使用其商標營利,改名為Trino。 | PrestoSQL是fork自[[Presto]]的專案,後來成立公司。在2018年時Facebook出面阻止使用其商標營利,改名為Trino。 | ||
== 硬體需求 == | |||
測試時用<code>t4g.small</code>就跑的動了,正式環境可以考慮先用<code>c6g.medium</code>。 | |||
== 安裝 == | == 安裝 == | ||
第10行: | 第14行: | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
sudo apt install -y openjdk-11-jre; cd /tmp; wget https://repo1.maven.org/maven2/io/trino/trino-server/ | TRINO_VERSION=363 sudo apt install -y openjdk-11-jre python-is-python3; sudo apt clean; cd /tmp; wget https://repo1.maven.org/maven2/io/trino/trino-server/${TRINO_VERSION}/trino-server-${TRINO_VERSION}.tar.gz; cd /opt; sudo tar xvf /tmp/trino-server-${TRINO_VERSION}.tar.gz; sudo mv trino-server-${TRINO_VERSION} trino-server; cd trino-server; sudo mkdir data etc var; sudo chown -R nobody:nogroup /opt/trino-server/ | ||
</syntaxhighlight> | |||
== 設定 == | |||
=== 防火牆 === | |||
{| class="sortable wikitable" | |||
! Port | |||
! Usage | |||
! Comment | |||
|- | |||
| 8080/tcp | |||
| Trino | |||
| | |||
|} | |||
=== 設定檔 === | |||
基本上都是照著官方的安裝文件<ref>{{Cite web |url= https://trino.io/docs/current/installation/deployment.html |title=Deploying Trino |language=en |accessdate=2021-08-10}}</ref>設定,這邊有些設定要注意的: | |||
* <code>etc/node.properties</code>的<code>node.environment</code>。 | |||
* <code>etc/jvm.config</code>的<code>-Xmx1G</code>。 | |||
<syntaxhighlight lang="bash"> | |||
cd /opt/trino-server; sudo mkdir data etc; sudo tee etc/node.properties > /dev/null <<EOF | |||
node.environment=production | |||
node.id=$(uuidgen) | |||
node.data-dir=/opt/trino-server/data | |||
EOF | |||
sudo tee etc/jvm.config > /dev/null <<EOF | |||
-server | |||
-Xmx1536M | |||
-XX:-UseBiasedLocking | |||
-XX:+UseG1GC | |||
-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 | |||
EOF | |||
sudo chown -R nobody:nogroup /opt/trino-server/etc/ | |||
</syntaxhighlight> | |||
然後是systemd的設定: | |||
<syntaxhighlight lang="bash"> | |||
sudo tee /lib/systemd/system/trino.service > /dev/null <<EOF | |||
# | |||
# Install into /lib/systemd/system | |||
[Unit] | |||
Description=Trino daemon | |||
After=remote-fs.target | |||
[Service] | |||
ExecStart=/opt/trino-server/bin/launcher run | |||
Group=nogroup | |||
Restart=always | |||
RestartSec=60 | |||
Type=simple | |||
User=nobody | |||
[Install] | |||
WantedBy=multi-user.target | |||
EOF | |||
sudo systemctl daemon-reload | |||
</syntaxhighlight> | |||
接下來會依照不同的機器設定不同的值: | |||
=== Coordinator === | |||
<syntaxhighlight lang="bash"> | |||
cd /opt/trino-server; sudo tee etc/config.properties > /dev/null <<EOF | |||
coordinator=true | |||
node-scheduler.include-coordinator=false | |||
http-server.http.port=8080 | |||
query.max-memory=1TB | |||
discovery.uri=http://example.net:8080 | |||
EOF | |||
sudo chown -R nobody:nogroup /opt/trino-server/etc/ | |||
</syntaxhighlight> | |||
=== Worker === | |||
這邊<code>query.max-memory-per-node</code>與<code>query.max-total-memory-per-node</code>建議設成記憶體一半的大小,預設是JVM heap的10%大小,很明顯太小。 | |||
<syntaxhighlight lang="bash"> | |||
cd /opt/trino-server; sudo tee etc/config.properties > /dev/null <<EOF | |||
coordinator=false | |||
http-server.http.port=8080 | |||
query.max-memory=1TB | |||
query.max-memory-per-node=32GB | |||
query.max-total-memory-per-node=32GB | |||
discovery.uri=http://example.net:8080 | |||
EOF | |||
sudo chown -R nobody:nogroup /opt/trino-server/etc/ | |||
</syntaxhighlight> | |||
== 啟動 == | |||
<syntaxhighlight lang="bash"> | |||
sudo systemctl daemon-reload; sudo systemctl enable trino; sudo service trino start | |||
</syntaxhighlight> | |||
== 常用指令 == | |||
先連上Trino: | |||
<syntaxhighlight lang="bash"> | |||
trino --server trino-coordinator-1.example.com:8080 | |||
</syntaxhighlight> | |||
另外可以看系統的各種狀況: | |||
<syntaxhighlight lang="sql"> | |||
SHOW SCHEMAS FROM system; | |||
SHOW TABLES FROM system.runtime; | |||
SELECT * FROM system.runtime.nodes; | |||
</syntaxhighlight> | |||
目前系統裡面的Query: | |||
<syntaxhighlight lang="sql"> | |||
SELECT * FROM system.runtime.queries; | |||
</syntaxhighlight> | </syntaxhighlight> | ||
第16行: | 第149行: | ||
* [[Presto]] | * [[Presto]] | ||
== 參考文獻 == | |||
{{Reflist|2}} | |||
== 外部連結 == | == 外部連結 == |
於 2022年3月28日 (一) 16:59 的最新修訂
Trino是一套SQL查詢引擎,舊名PrestoSQL,是源自於Presto的引擎。
簡介
PrestoSQL是fork自Presto的專案,後來成立公司。在2018年時Facebook出面阻止使用其商標營利,改名為Trino。
硬體需求
測試時用t4g.small
就跑的動了,正式環境可以考慮先用c6g.medium
。
安裝
在Ubuntu類的系統上沒有套件可以裝,這邊建議直接下載並且安裝到/opt
下(另外需要Java 11):
TRINO_VERSION=363 sudo apt install -y openjdk-11-jre python-is-python3; sudo apt clean; cd /tmp; wget https://repo1.maven.org/maven2/io/trino/trino-server/${TRINO_VERSION}/trino-server-${TRINO_VERSION}.tar.gz; cd /opt; sudo tar xvf /tmp/trino-server-${TRINO_VERSION}.tar.gz; sudo mv trino-server-${TRINO_VERSION} trino-server; cd trino-server; sudo mkdir data etc var; sudo chown -R nobody:nogroup /opt/trino-server/
設定
防火牆
Port | Usage | Comment |
---|---|---|
8080/tcp | Trino |
設定檔
基本上都是照著官方的安裝文件[1]設定,這邊有些設定要注意的:
etc/node.properties
的node.environment
。etc/jvm.config
的-Xmx1G
。
cd /opt/trino-server; sudo mkdir data etc; sudo tee etc/node.properties > /dev/null <<EOF
node.environment=production
node.id=$(uuidgen)
node.data-dir=/opt/trino-server/data
EOF
sudo tee etc/jvm.config > /dev/null <<EOF
-server
-Xmx1536M
-XX:-UseBiasedLocking
-XX:+UseG1GC
-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
EOF
sudo chown -R nobody:nogroup /opt/trino-server/etc/
然後是systemd的設定:
sudo tee /lib/systemd/system/trino.service > /dev/null <<EOF
#
# Install into /lib/systemd/system
[Unit]
Description=Trino daemon
After=remote-fs.target
[Service]
ExecStart=/opt/trino-server/bin/launcher run
Group=nogroup
Restart=always
RestartSec=60
Type=simple
User=nobody
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl daemon-reload
接下來會依照不同的機器設定不同的值:
Coordinator
cd /opt/trino-server; sudo tee etc/config.properties > /dev/null <<EOF
coordinator=true
node-scheduler.include-coordinator=false
http-server.http.port=8080
query.max-memory=1TB
discovery.uri=http://example.net:8080
EOF
sudo chown -R nobody:nogroup /opt/trino-server/etc/
Worker
這邊query.max-memory-per-node
與query.max-total-memory-per-node
建議設成記憶體一半的大小,預設是JVM heap的10%大小,很明顯太小。
cd /opt/trino-server; sudo tee etc/config.properties > /dev/null <<EOF
coordinator=false
http-server.http.port=8080
query.max-memory=1TB
query.max-memory-per-node=32GB
query.max-total-memory-per-node=32GB
discovery.uri=http://example.net:8080
EOF
sudo chown -R nobody:nogroup /opt/trino-server/etc/
啟動
sudo systemctl daemon-reload; sudo systemctl enable trino; sudo service trino start
常用指令
先連上Trino:
trino --server trino-coordinator-1.example.com:8080
另外可以看系統的各種狀況:
SHOW SCHEMAS FROM system;
SHOW TABLES FROM system.runtime;
SELECT * FROM system.runtime.nodes;
目前系統裡面的Query:
SELECT * FROM system.runtime.queries;
相關連結
參考文獻
- ↑ Deploying Trino. [2021-08-10] (English).