본문 바로가기
AI

Trino(트리노) 설치

by david100gom 2025. 3. 20.
728x90

 


1. 사전 준비

(1) CentOS 버전 확인

cat /etc/os-release

CentOS 7 이상 권장

(2) Java 설치 (Trino는 Java 11 이상 필요)

sudo yum install -y java-11-openjdk

설치 확인:

java -version

OpenJDK 11 또는 그 이상이 출력되어야 합니다.


2. Trino 다운로드 및 설치

(1) Trino 서버 다운로드

wget https://repo1.maven.org/maven2/io/trino/trino-server/414/trino-server-414.tar.gz

최신 버전은 공식 다운로드 페이지에서 확인 가능

(2) 압축 해제 및 이동

tar -xvzf trino-server-414.tar.gz
sudo mv trino-server-414 /opt/trino
cd /opt/trino

3. 설정 파일 구성

(1) 디렉토리 생성

mkdir -p /opt/trino/etc

(2) 기본 설정 파일 생성

1) node.properties (노드 설정)

cat <<EOF | sudo tee /opt/trino/etc/node.properties
node.environment=production
node.id=trino-1
node.data-dir=/opt/trino/data
EOF

2) jvm.config (JVM 설정)

cat <<EOF | sudo tee /opt/trino/etc/jvm.config
-server
-Xmx4G
-XX:+UseG1GC
-XX:G1HeapRegionSize=32M
EOF

필요에 따라 -Xmx 값을 조정 (기본 4GB)

3) config.properties (Trino 서버 설정)

cat <<EOF | sudo tee /opt/trino/etc/config.properties
coordinator=true
node-scheduler.include-coordinator=true
http-server.http.port=8080
query.max-memory=4GB
query.max-memory-per-node=1GB
discovery-server.enabled=true
discovery.uri=http://localhost:8080
EOF

4) log.properties (로그 설정)

cat <<EOF | sudo tee /opt/trino/etc/log.properties
io.trino=INFO
EOF

4. MySQL 커넥터 설정

(1) MySQL 커넥터 다운로드

mkdir -p /opt/trino/etc/catalog
cat <<EOF | sudo tee /opt/trino/etc/catalog/mysql.properties
connector.name=mysql
connection-url=jdbc:mysql://your-mysql-host:3306
connection-user=root
connection-password=yourpassword
EOF

your-mysql-host를 실제 MySQL 서버 주소로 변경


5. Trino 실행 및 서비스 등록

(1) 실행 테스트

/opt/trino/bin/launcher run
  • 정상적으로 실행되면 http://<your-server-ip>:8080 접속 가능 (계정은 아무거나 넣으면 됨)

(2) 백그라운드 실행

/opt/trino/bin/launcher start

(3) 서비스 등록 (시스템 부팅 시 자동 실행)

1) 서비스 파일 생성

sudo tee /etc/systemd/system/trino.service <<EOF
[Unit]
Description=Trino Server
After=network.target

[Service]
User=root
Group=root
ExecStart=/opt/trino/bin/launcher start
ExecStop=/opt/trino/bin/launcher stop
Restart=always
WorkingDirectory=/opt/trino

[Install]
WantedBy=multi-user.target
EOF

2) 서비스 시작 및 자동 실행

sudo systemctl daemon-reload
sudo systemctl enable trino
sudo systemctl start trino

3) 상태 확인

sudo systemctl status trino

6. Trino CLI 사용

(1) CLI 다운로드

wget https://repo1.maven.org/maven2/io/trino/trino-cli/414/trino-cli-414-executable.jar -O trino
chmod +x trino
sudo mv trino /usr/local/bin/

(2) Trino CLI 실행

trino --server http://localhost:8080 --catalog mysql --schema default

MySQL 데이터베이스 조회 가능


7. MySQL 데이터 조회 테스트

SHOW TABLES;
SELECT * FROM your_table LIMIT 10;

✅ 설치 완료!

이제 Trino를 이용해 MySQL 데이터를 조회하고, API를 통해 제공할 수 있습니다. 🚀

728x90

댓글