Linux安装Temporal工作流引擎
使用Docker安装Temporal, 使用外部MySQL数据库 docker-compose.yml temporal-init: 用于自动初始化数据 销毁命令:1. 初始化MySQL数据库
# 创建用户 temporal
CREATE USER 'temporal'@'%' IDENTIFIED BY 'temporal';
# 创建数据库 temporal
CREATE DATABASE `temporal` DEFAULT CHARACTER SET utf8mb4 DEFAULT COLLATE utf8mb4_general_ci;
grant all privileges on `temporal`.* TO 'temporal'@'%';
# 创建数据库 temporal_visibility
CREATE DATABASE `temporal_visibility` DEFAULT CHARACTER SET utf8mb4 DEFAULT COLLATE utf8mb4_general_ci;
grant all privileges on `temporal_visibility`.* TO 'temporal'@'%';2. 配置文件
services:
temporal-init:
image: temporalio/auto-setup:1.29.3
container_name: temporal_init
environment:
DB: mysql8
# 改为正确MySQL配置
MYSQL_SEEDS: "192.168.2.215"
DB_PORT: 3306
MYSQL_USER: "temporal"
MYSQL_PWD: "temporal"
MYSQL_DB: "temporal"
DEFAULT_NAMESPACE: "default"
command: ["temporal-sql-tool", "create-schema", "-k", "default", "-v", "1.19"]
restart: "no"
temporal:
image: temporalio/auto-setup:1.29.3
container_name: temporal_server
environment:
# 使用外部 MySQL
DB: mysql8
MYSQL_SEEDS: "192.168.2.215" # 你的 MySQL 地址
DB_PORT: 3306
MYSQL_USER: "temporal"
MYSQL_PWD: "temporal"
MYSQL_DB: "temporal" # Temporal 数据库
DEFAULT_NAMESPACE: "default"
# 这里填127.0.0.1会报错, 需要在ports将7233端口映射到宿主机, 填写宿主机的IP
TEMPORAL_BROADCAST_ADDRESS: "192.168.2.215"
ports:
- "7233:7233" # gRPC frontend
- "7234:7234" # history
- "7235:7235" # matching
- "7239:7239" # worker
- "8088:8088" # Temporal Web API (可选)
depends_on:
- temporal-init
restart: always
temporal-ui:
image: temporalio/ui:2.45.0
container_name: temporal_ui
environment:
TEMPORAL_ADDRESS: "temporal:7233" # 指向 Temporal Server 容器名
TEMPORAL_UI_PORT: "8080"
ports:
- "8080:8080" # 浏览器访问
depends_on:
- temporal
restart: always
temporal: 启动核心进程
temporal-ui: 启动UI管理界面
访问 http://192.168.2.215:8080/ 查看管理后台
3. 启动
# 启动
docker compose up -d
# 查看日志
docker logs --tail=100 -f temporal_serverdocker compose down
docker container list