You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Docker Compose部署Jaeger对接PostgreSQL存储启动报错求助

Jaeger PostgreSQL持久化部署报错解决

问题场景

使用docker-compose搭配OTEL Collector(collector-gateway.yaml)将追踪数据发送至Jaeger,通过jaeger-postgresql实现PostgreSQL数据持久化,执行docker-compose up启动容器时持续报错。

错误日志

jaeger-postgresql-jaeger-all-in-one-1  | {"level":"fatal","ts":1696996008.1216166,"caller":"./main.go:110","msg":"Failed to init storage factory","error":"grpc-plugin builder failed to create a store: error attempting to connect to plugin rpc client: fork/exec /etc/cmd/jaeger-pg-store: exec format error","stacktrace":"main.main.func1\n\t./main.go:110\ngithub.com/spf13/cobra.(*Command).execute\n\tgithub.com/spf13/cobra@v1.7.0/command.go:940\ngithub.com/spf13/cobra.(*Command).ExecuteC\n\tgithub.com/spf13/cobra@v1.7.0/command.go:1068\ngithub.com/spf13/cobra.(*Command).Execute\n\tgithub.com/spf13/cobra@v1.7.0/command.go:992\nmain.main\n\t./main.go:243\nruntime.main\n\truntime/proc.go:267"}

相关配置文件(docker-compose.yaml)

version: "3"
services:
  # Jaeger
  jaeger-all-in-one:
    image: jaegertracing/all-in-one:latest
    ports:
      - "16686:16686"
      - "14268"
      - "14250"
    environment:
      - SPAN_STORAGE_TYPE=grpc-plugin
      - COLLECTOR_OTLP_ENABLED=true
    volumes:
      - ./jaeger-pg-store:/etc/cmd/jaeger-pg-store
      - ./collector-gateway.yaml:/etc/collector-gateway.yaml
    command: ["--grpc-storage-plugin.binary=/etc/cmd/jaeger-pg-store", "--grpc-storage-plugin.configuration-file=/etc/collector-gateway.yaml"]
    
  # Collector
  collector-gateway:
    image: otel/opentelemetry-collector-contrib:0.53.0
    volumes:
      - ./collector-gateway.yaml:/etc/collector-gateway.yaml
      - ./jaeger-pg-store:/etc/cmd
    command: [ "--config=/etc/collector-gateway.yaml"]
    ports:
      - "1888:1888"   # pprof extension
      - "13133:13133" # health_check extension
      - "4317:4317"        # OTLP gRPC receiver
      - "4318:4318"        # OTLP HTTP receiver
      - "55670:55679" # zpages extension
    depends_on:
      - jaeger-all-in-one
    links:
      - jaeger-all-in-one

已尝试操作

  • 在Mac系统上使用CGO_ENABLED=0 GOARCH=amd64 GOOS=darwin编译jaeger-pg-store,问题未解决
  • 直接运行Jaeger二进制可执行文件能启动,但无法连接PostgreSQL,希望通过Docker Compose完成部署

解决方案

1. 编译适配Linux环境的jaeger-pg-store二进制

Jaeger容器基于Linux系统,你之前编译的是Mac(darwin)版本,导致容器内无法执行,需重新编译Linux适配版本:

CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build -o jaeger-pg-store

编译完成后,赋予二进制可执行权限:

chmod +x jaeger-pg-store

2. 修正Jaeger插件配置文件

你当前将OTEL Collector的配置文件作为Jaeger gRPC插件的配置文件,这是错误的。需创建单独的PostgreSQL配置文件(如pg-config.yaml),内容示例:

host: postgres
port: 5432
user: jaeger
password: jaeger
database: jaeger
ssl_mode: disable

3. 补充PostgreSQL服务到docker-compose.yaml

在docker-compose中添加PostgreSQL服务,并确保Jaeger能访问到:

version: "3"
services:
  # PostgreSQL
  postgres:
    image: postgres:14-alpine
    environment:
      - POSTGRES_USER=jaeger
      - POSTGRES_PASSWORD=jaeger
      - POSTGRES_DB=jaeger
    volumes:
      - postgres_data:/var/lib/postgresql/data
    ports:
      - "5432:5432"

  # Jaeger
  jaeger-all-in-one:
    image: jaegertracing/all-in-one:latest
    ports:
      - "16686:16686"
      - "14268"
      - "14250"
    environment:
      - SPAN_STORAGE_TYPE=grpc-plugin
      - COLLECTOR_OTLP_ENABLED=true
    volumes:
      - ./jaeger-pg-store:/etc/cmd/jaeger-pg-store
      - ./pg-config.yaml:/etc/pg-config.yaml
    command: ["--grpc-storage-plugin.binary=/etc/cmd/jaeger-pg-store", "--grpc-storage-plugin.configuration-file=/etc/pg-config.yaml"]
    depends_on:
      - postgres

  # Collector
  collector-gateway:
    image: otel/opentelemetry-collector-contrib:0.53.0
    volumes:
      - ./collector-gateway.yaml:/etc/collector-gateway.yaml
    command: [ "--config=/etc/collector-gateway.yaml"]
    ports:
      - "1888:1888"   # pprof extension
      - "13133:13133" # health_check extension
      - "4317:4317"        # OTLP gRPC receiver
      - "4318:4318"        # OTLP HTTP receiver
      - "55670:55679" # zpages extension
    depends_on:
      - jaeger-all-in-one

volumes:
  postgres_data:

4. 调整OTEL Collector配置

确保collector-gateway.yaml中的Jaeger exporter指向Jaeger服务,示例配置片段:

exporters:
  jaeger:
    endpoint: jaeger-all-in-one:14250
    tls:
      insecure: true

完成以上调整后,重新执行docker-compose up即可正常启动服务。

内容的提问来源于stack exchange,提问作者Isaac Chen

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.08 15:15:08