langfuse从v2升级到v3(本地升级docker compose)

环境:
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:2
    depends_on:
      db:
        condition: service_healthy
    ports:
      - "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=true

  db:
    image: registry.cn-shenzhen.aliyuncs.com/hxlk8s/postgresql:16.4.0
    restart: always
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U postgres"]
      interval: 3s
      timeout: 3s
      retries: 10
    environment:
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=postgres
      - POSTGRES_DB=postgres
    ports:
      - 5432:5432
    volumes:
      - /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:3
    restart: always
    depends_on: &langfuse-depends-on
      postgres:
        condition: service_healthy
      minio:
        condition: service_healthy
      redis:
        condition: service_healthy
      clickhouse:
        condition: service_healthy
    ports:
      - "3030:3030"
    environment: &langfuse-worker-env
      DATABASE_URL: postgresql://postgres:postgres@postgres:5432/postgres
      SALT: "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:3
    restart: always
    depends_on: *langfuse-depends-on
    ports:
      - "3000:3000"
    environment:
      <<: *langfuse-worker-env
      NEXTAUTH_URL: http://localhost:3000
      NEXTAUTH_SECRET: mysecret
      LANGFUSE_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.8
    restart: always
    container_name: clickhouse
    hostname: clickhouse
    environment:
      CLICKHOUSE_DB: default
      CLICKHOUSE_USER: clickhouse
      CLICKHOUSE_PASSWORD: clickhouse
    volumes:
      - /home/middle/langfuse/clickhouse_data:/var/lib/clickhouse
      - /home/middle/langfuse/clickhouse_logs:/var/log/clickhouse-server
    ports:
      - "8123:8123"
      - "9000:9000"
    healthcheck:
      test: wget --no-verbose --tries=1 --spider http://localhost:8123/ping || exit 1
      interval: 5s
      timeout: 5s
      retries: 10
      start_period: 1s

  minio:
    image: minio:latest
    restart: always
    container_name: minio
    entrypoint: sh
    # create the 'langfuse' bucket before starting the service
    command: -c 'mkdir -p /data/langfuse && minio server --address ":9000" --console-address ":9001" /data'
    environment:
      MINIO_ROOT_USER: minio
      MINIO_ROOT_PASSWORD: miniosecret
    ports:
      - "9090:9000"
      - "9091:9001"
    volumes:
      - /home/middle/langfuse/minio_data:/minio_data
    healthcheck:
      test: ["CMD", "mc", "ready", "local"]
      interval: 1s
      timeout: 5s
      retries: 5
      start_period: 1s

  redis:
    image: registry.cn-shenzhen.aliyuncs.com/hxlk8s/redis:7.4
    restart: always
    command: >
      --requirepass ${REDIS_AUTH:-myredissecret}
    ports:
      - 6379:6379
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 3s
      timeout: 10s
      retries: 10

  postgres:
    image: registry.cn-shenzhen.aliyuncs.com/hxlk8s/postgresql:16.4.0
    restart: always
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U postgres"]
      interval: 3s
      timeout: 3s
      retries: 10
    environment:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: postgres
      POSTGRES_DB: postgres
    ports:
      - 5432:5432
    volumes:
      - /home/middle/langfuse/pgdata:/var/lib/postgresql/data

volumes:
  langfuse_postgres_data:
    driver: local
  langfuse_clickhouse_data:
    driver: local
  langfuse_clickhouse_logs:
    driver: local
  langfuse_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 -p5432

postgres=# \d
                  List of relations
 Schema |           Name           | Type  |  Owner   
--------+--------------------------+-------+----------
 public | Account                  | table | postgres
 public | Session                  | table | postgres
 public | _prisma_migrations       | table | postgres
 public | annotation_queue_items   | table | postgres
 public | annotation_queues        | table | postgres
 public | api_keys                 | table | postgres
 public | audit_logs               | table | postgres
 public | background_migrations    | table | postgres
 public | batch_exports            | table | postgres
 public | comments                 | table | postgres
 public | cron_jobs                | table | postgres
 public | dataset_items            | table | postgres
 public | dataset_run_items        | table | postgres
 public | dataset_runs             | table | postgres
 public | datasets                 | table | postgres
 public | eval_templates           | table | postgres
 public | events                   | table | postgres
 public | job_configurations       | table | postgres
 public | job_executions           | table | postgres
 public | llm_api_keys             | table | postgres
 public | media                    | table | postgres
 public | membership_invitations   | table | postgres
 public | models                   | table | postgres
 public | observation_media        | table | postgres
 public | observations             | table | postgres
 public | observations_view        | view  | postgres
 public | organization_memberships | table | postgres
 public | organizations            | table | postgres
 public | posthog_integrations     | table | postgres
 public | prices                   | table | postgres
 public | project_memberships      | table | postgres
 public | projects                 | table | postgres
 public | prompts                  | table | postgres
 public | score_configs            | table | postgres
 public | scores                   | table | postgres
 public | sso_configs              | table | postgres
 public | trace_media              | table | postgres
 public | trace_sessions           | table | postgres
 public | traces                   | table | postgres
 public | traces_view              | view  | postgres
 public | users                    | table | postgres
 public | verification_tokens      | table | postgres
(42 rows)

v3有42个对象,而v2是34个对象.
复制代码

 

posted @   slnngk  阅读(30)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
历史上的今天:
2023-01-09 配置ssh等效连接(ssh-copy-id)
2019-01-09 rman备份例子
点击右上角即可分享
微信分享提示