环境:
OS:Centos 7
#################################################部署v2###########################################################
1.部署v2
v2资源清单配置文件如下:
[root@host135 langfuse]# more docker-compose.yml
services:langfuse-server:image: registry.cn-shenzhen.aliyuncs.com/hxlk8s/langfuse:2depends_on:db:condition: service_healthyports:- "3000:3000"environment:- DATABASE_URL=postgresql://postgres:postgres@db:5432/postgres- NEXTAUTH_SECRET=mysecret- SALT=mysalt- ENCRYPTION_KEY=0000000000000000000000000000000000000000000000000000000000000000 # generate via `openssl rand-hex 32`- NEXTAUTH_URL=http://localhost:3000- TELEMETRY_ENABLED=${TELEMETRY_ENABLED:-true}- LANGFUSE_ENABLE_EXPERIMENTAL_FEATURES=${LANGFUSE_ENABLE_EXPERIMENTAL_FEATURES:-false}- LANGFUSE_DISABLE_EXPENSIVE_POSTGRES_QUERIES=truedb:image: registry.cn-shenzhen.aliyuncs.com/hxlk8s/postgresql:16.4.0restart: alwayshealthcheck:test: ["CMD-SHELL", "pg_isready -U postgres"]interval: 3stimeout: 3sretries: 10environment:- POSTGRES_USER=postgres- POSTGRES_PASSWORD=postgres- POSTGRES_DB=postgresports:- 5432:5432volumes:- /home/middle/langfuse/pgdata:/var/lib/postgresql/data
volumes:database_data:driver: local
2.创建pg外挂目录
mkdir -p /home/middle/langfuse/pgdata
3.启动
将资源清单文件存放到如下目录
/home/middle/langfuse/langfuse
[root@host135 langfuse]# cd /home/middle/langfuse/langfuse
[root@host135 langfuse]# docker compose up -d
4.浏览器登录
http://192.168.1.135:3000
创建账号hxl,然后登录进去创建项目,模拟造数据,等升级完成后这些数据是否存在
5.删除v2的部署
[root@host135 langfuse]# cd /home/middle/langfuse/langfuse
[root@host135 langfuse]# docker compose down
[root@host135 langfuse]# docker compose ps
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
这个时候v2没有运行了
##########################################升级到v3#############################
v3部署与v2相同的目录
1.准备资源配置文件
[root@host135 langfuse]# more v3_docker-compose.yml
services:langfuse-worker:image: registry.cn-shenzhen.aliyuncs.com/hxlk8s/langfuse-worker:3restart: alwaysdepends_on: &langfuse-depends-onpostgres:condition: service_healthyminio:condition: service_healthyredis:condition: service_healthyclickhouse:condition: service_healthyports:- "3030:3030"environment: &langfuse-worker-envDATABASE_URL: postgresql://postgres:postgres@postgres:5432/postgresSALT: "mysalt"ENCRYPTION_KEY: "0000000000000000000000000000000000000000000000000000000000000000" # generate via `openssl ran
d -hex 32`TELEMETRY_ENABLED: ${TELEMETRY_ENABLED:-true}LANGFUSE_ENABLE_EXPERIMENTAL_FEATURES: ${LANGFUSE_ENABLE_EXPERIMENTAL_FEATURES:-true}CLICKHOUSE_MIGRATION_URL: ${CLICKHOUSE_MIGRATION_URL:-clickhouse://clickhouse:9000}CLICKHOUSE_URL: ${CLICKHOUSE_URL:-http://clickhouse:8123}CLICKHOUSE_USER: ${CLICKHOUSE_USER:-clickhouse}CLICKHOUSE_PASSWORD: ${CLICKHOUSE_PASSWORD:-clickhouse}CLICKHOUSE_CLUSTER_ENABLED: ${CLICKHOUSE_CLUSTER_ENABLED:-false}LANGFUSE_S3_EVENT_UPLOAD_BUCKET: ${LANGFUSE_S3_EVENT_UPLOAD_BUCKET:-langfuse}LANGFUSE_S3_EVENT_UPLOAD_REGION: ${LANGFUSE_S3_EVENT_UPLOAD_REGION:-auto}LANGFUSE_S3_EVENT_UPLOAD_ACCESS_KEY_ID: ${LANGFUSE_S3_EVENT_UPLOAD_ACCESS_KEY_ID:-minio}LANGFUSE_S3_EVENT_UPLOAD_SECRET_ACCESS_KEY: ${LANGFUSE_S3_EVENT_UPLOAD_SECRET_ACCESS_KEY:-miniosecret}LANGFUSE_S3_EVENT_UPLOAD_ENDPOINT: ${LANGFUSE_S3_EVENT_UPLOAD_ENDPOINT:-http://minio:9000}LANGFUSE_S3_EVENT_UPLOAD_FORCE_PATH_STYLE: ${LANGFUSE_S3_EVENT_UPLOAD_FORCE_PATH_STYLE:-true}LANGFUSE_S3_EVENT_UPLOAD_PREFIX: ${LANGFUSE_S3_EVENT_UPLOAD_PREFIX:-events/}LANGFUSE_S3_MEDIA_UPLOAD_BUCKET: ${LANGFUSE_S3_MEDIA_UPLOAD_BUCKET:-langfuse}LANGFUSE_S3_MEDIA_UPLOAD_REGION: ${LANGFUSE_S3_MEDIA_UPLOAD_REGION:-auto}LANGFUSE_S3_MEDIA_UPLOAD_ACCESS_KEY_ID: ${LANGFUSE_S3_MEDIA_UPLOAD_ACCESS_KEY_ID:-minio}LANGFUSE_S3_MEDIA_UPLOAD_SECRET_ACCESS_KEY: ${LANGFUSE_S3_MEDIA_UPLOAD_SECRET_ACCESS_KEY:-miniosecret}LANGFUSE_S3_MEDIA_UPLOAD_ENDPOINT: ${LANGFUSE_S3_MEDIA_UPLOAD_ENDPOINT:-http://minio:9000}LANGFUSE_S3_MEDIA_UPLOAD_FORCE_PATH_STYLE: ${LANGFUSE_S3_MEDIA_UPLOAD_FORCE_PATH_STYLE:-true}LANGFUSE_S3_MEDIA_UPLOAD_PREFIX: ${LANGFUSE_S3_MEDIA_UPLOAD_PREFIX:-media/}REDIS_HOST: ${REDIS_HOST:-redis}REDIS_PORT: ${REDIS_PORT:-6379}REDIS_AUTH: ${REDIS_AUTH:-myredissecret}langfuse-web:image: registry.cn-shenzhen.aliyuncs.com/hxlk8s/langfuse:3restart: alwaysdepends_on: *langfuse-depends-onports:- "3000:3000"environment:<<: *langfuse-worker-envNEXTAUTH_URL: http://localhost:3000
NEXTAUTH_SECRET: mysecretLANGFUSE_INIT_ORG_ID: ${LANGFUSE_INIT_ORG_ID:-}LANGFUSE_INIT_ORG_NAME: ${LANGFUSE_INIT_ORG_NAME:-}LANGFUSE_INIT_PROJECT_ID: ${LANGFUSE_INIT_PROJECT_ID:-}LANGFUSE_INIT_PROJECT_NAME: ${LANGFUSE_INIT_PROJECT_NAME:-}LANGFUSE_INIT_PROJECT_PUBLIC_KEY: ${LANGFUSE_INIT_PROJECT_PUBLIC_KEY:-}LANGFUSE_INIT_PROJECT_SECRET_KEY: ${LANGFUSE_INIT_PROJECT_SECRET_KEY:-}LANGFUSE_INIT_USER_EMAIL: ${LANGFUSE_INIT_USER_EMAIL:-}LANGFUSE_INIT_USER_NAME: ${LANGFUSE_INIT_USER_NAME:-}LANGFUSE_INIT_USER_PASSWORD: ${LANGFUSE_INIT_USER_PASSWORD:-}LANGFUSE_SDK_CI_SYNC_PROCESSING_ENABLED: ${LANGFUSE_SDK_CI_SYNC_PROCESSING_ENABLED:-false}LANGFUSE_READ_FROM_POSTGRES_ONLY: ${LANGFUSE_READ_FROM_POSTGRES_ONLY:-false}LANGFUSE_READ_FROM_CLICKHOUSE_ONLY: ${LANGFUSE_READ_FROM_CLICKHOUSE_ONLY:-true}LANGFUSE_RETURN_FROM_CLICKHOUSE: ${LANGFUSE_RETURN_FROM_CLICKHOUSE:-true}clickhouse:image: registry.cn-shenzhen.aliyuncs.com/hxlk8s/clickhouse-server:24.8restart: alwayscontainer_name: clickhousehostname: clickhouseenvironment:CLICKHOUSE_DB: defaultCLICKHOUSE_USER: clickhouseCLICKHOUSE_PASSWORD: clickhousevolumes:- /home/middle/langfuse/clickhouse_data:/var/lib/clickhouse- /home/middle/langfuse/clickhouse_logs:/var/log/clickhouse-serverports:- "8123:8123"- "9000:9000"healthcheck:test: wget --no-verbose --tries=1 --spider http://localhost:8123/ping || exit 1
interval: 5stimeout: 5sretries: 10start_period: 1sminio:image: minio:latestrestart: alwayscontainer_name: minioentrypoint: sh# create the 'langfuse' bucket before starting the servicecommand: -c 'mkdir -p /data/langfuse && minio server --address ":9000" --console-address ":9001" /data'environment:MINIO_ROOT_USER: minioMINIO_ROOT_PASSWORD: miniosecretports:- "9090:9000"- "9091:9001"volumes:- /home/middle/langfuse/minio_data:/minio_datahealthcheck:test: ["CMD", "mc", "ready", "local"]interval: 1stimeout: 5sretries: 5start_period: 1sredis:image: registry.cn-shenzhen.aliyuncs.com/hxlk8s/redis:7.4restart: alwayscommand: >--requirepass ${REDIS_AUTH:-myredissecret}ports:- 6379:6379healthcheck:test: ["CMD", "redis-cli", "ping"]interval: 3stimeout: 10sretries: 10postgres:image: registry.cn-shenzhen.aliyuncs.com/hxlk8s/postgresql:16.4.0restart: alwayshealthcheck:test: ["CMD-SHELL", "pg_isready -U postgres"]interval: 3stimeout: 3sretries: 10environment:POSTGRES_USER: postgresPOSTGRES_PASSWORD: postgresPOSTGRES_DB: postgresports:- 5432:5432volumes:- /home/middle/langfuse/pgdata:/var/lib/postgresql/datavolumes:langfuse_postgres_data:driver: locallangfuse_clickhouse_data:driver: locallangfuse_clickhouse_logs:driver: locallangfuse_minio_data:driver: local
2.创建资源配置文件中外挂的目录
mkdir /home/middle/langfuse/pgdata 保留v2的 不需要创建,升级到v3会用到这里的数据
mkdir -p /home/middle/langfuse/minio_data
mkdir -p /home/middle/langfuse/clickhouse_data
mkdir -p /home/middle/langfuse/clickhouse_logs
3.备份v2的配置文件
[root@host135 langfuse]# cd /home/middle/langfuse/langfuse
[root@host135 langfuse]# mv docker-compose.yml v2_docker-compose.yml
4.使用v3的配置文件部署
[root@host135 langfuse]# mv v3_docker-compose.yml docker-compose.yml
[root@host135 langfuse]# docker compose up -d
5.查看进程
[root@host135 langfuse]# docker compose ps
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
clickhouse registry.cn-shenzhen.aliyuncs.com/hxlk8s/clickhouse-server:24.8 "/entrypoint.sh" clickhouse 17 seconds ago Up 12 seconds (healthy) 0.0.0.0:8123->8123/tcp, :::8123->8123/tcp, 0.0.0.0:9000->9000/tcp, :::9000->9000/tcp, 9009/tcp
langfuse-langfuse-web-1 registry.cn-shenzhen.aliyuncs.com/hxlk8s/langfuse:3 "dumb-init -- ./web/…" langfuse-web 16 seconds ago Up 5 seconds 0.0.0.0:3000->3000/tcp, :::3000->3000/tcp
langfuse-langfuse-worker-1 registry.cn-shenzhen.aliyuncs.com/hxlk8s/langfuse-worker:3 "dumb-init -- ./work…" langfuse-worker 16 seconds ago Up 4 seconds 0.0.0.0:3030->3030/tcp, :::3030->3030/tcp
langfuse-postgres-1 registry.cn-shenzhen.aliyuncs.com/hxlk8s/postgresql:16.4.0 "docker-entrypoint.s…" postgres 17 seconds ago Up 13 seconds (healthy) 0.0.0.0:5432->5432/tcp, :::5432->5432/tcp
langfuse-redis-1 registry.cn-shenzhen.aliyuncs.com/hxlk8s/redis:7.4 "docker-entrypoint.s…" redis 17 seconds ago Up 14 seconds (healthy) 0.0.0.0:6379->6379/tcp, :::6379->6379/tcp
minio minio:latest "sh -c 'mkdir -p /da…" minio 17 seconds ago Up 13 seconds (healthy) 0.0.0.0:9090->9000/tcp, :::9090->9000/tcp, 0.0.0.0:9091->9001/tcp, :::9091->9001/tcp
6.登录查看
http://192.168.1.135:3000/
可以看到之前在v2上创建的数据是存在的
7.查看pg的表
/opt/pg16/bin/psql -h 192.168.1.135 -U postgres -p5432postgres=# \dList of relationsSchema | Name | Type | Owner
--------+--------------------------+-------+----------public | Account | table | postgrespublic | Session | table | postgrespublic | _prisma_migrations | table | postgrespublic | annotation_queue_items | table | postgrespublic | annotation_queues | table | postgrespublic | api_keys | table | postgrespublic | audit_logs | table | postgrespublic | background_migrations | table | postgrespublic | batch_exports | table | postgrespublic | comments | table | postgrespublic | cron_jobs | table | postgrespublic | dataset_items | table | postgrespublic | dataset_run_items | table | postgrespublic | dataset_runs | table | postgrespublic | datasets | table | postgrespublic | eval_templates | table | postgrespublic | events | table | postgrespublic | job_configurations | table | postgrespublic | job_executions | table | postgrespublic | llm_api_keys | table | postgrespublic | media | table | postgrespublic | membership_invitations | table | postgrespublic | models | table | postgrespublic | observation_media | table | postgrespublic | observations | table | postgrespublic | observations_view | view | postgrespublic | organization_memberships | table | postgrespublic | organizations | table | postgrespublic | posthog_integrations | table | postgrespublic | prices | table | postgrespublic | project_memberships | table | postgrespublic | projects | table | postgrespublic | prompts | table | postgrespublic | score_configs | table | postgrespublic | scores | table | postgrespublic | sso_configs | table | postgrespublic | trace_media | table | postgrespublic | trace_sessions | table | postgrespublic | traces | table | postgrespublic | traces_view | view | postgrespublic | users | table | postgrespublic | verification_tokens | table | postgres
(42 rows)v3有42个对象,而v2是34个对象.