【发布时间】:2022-01-12 17:19:07
【问题描述】:
我正在尝试使用 Docker Compose 安装 TimeScaleDB,但在使用 timescaledb-parallel-copy 导入数据时出现以下错误:
/usr/local/bin/docker-entrypoint.sh:正在运行 /docker-entrypoint-initdb.d/import_data.sh timescaledb |恐慌:可以 未连接:拨打 tcp 172.18.0.2:5432:连接:连接被拒绝 时标数据库 |时标数据库 | goroutine 6 [运行]: timescaledb | main.processBatches(0xc000016730, 0xc000060780) timescaledb | /go/src/github.com/timescale/timescaledb-parallel-copy/cmd/timescaledb-parallel-copy/main.go:238 +0x8bb 时间刻度数据库 |创建者 main.main timescaledb | /go/src/github.com/timescale/timescaledb-parallel-copy/cmd/timescaledb-parallel-copy/main.go:148 +0x1d2 时间刻度数据库 |恐慌:无法连接:拨打 tcp 172.18.0.2:5432:连接:连接被拒绝
这是我的 docker compose 和我的 docker 文件:
Docker 撰写:
version: "3.8"
services:
timescaledb:
container_name: timescaledb
build:
context: "./timescaledb"
dockerfile: "docker_file"
env_file:
- "./timescaledb/environment.env"
volumes:
- "./timescaledb/data:/data"
ports:
- "5432:5432/tcp"
networks:
- local_network
restart: on-failure
networks:
local_network:
Docker 文件:
FROM timescale/timescaledb:latest-pg13
ADD create_tables.sql /docker-entrypoint-initdb.d
ADD import_data.sh /docker-entrypoint-initdb.d
RUN chmod a+r /docker-entrypoint-initdb.d/*
这是调用 timescaledb-parallel-copy 的 import_data.sh 脚本:
#!/bin/bash
timescaledb-parallel-copy --connection "host=timescaledb user=postgres password=XXX sslmode=disable" --db-name YYY --table ZZZ --copy-options "CSV" -skip-header --columns "name, unit" --file "/data/data.csv" --reporting-period 30s workers 4
我也尝试过使用 localhost,但我得到了同样的错误。
【问题讨论】:
-
您好 Manele,请查看我们在 Timescale slack 社区中遇到相同错误的人的一些笔记。他们发现 sslmode 后面的 disable 这个词必须在 " 标记中,但是因为该短语已经包含在 "" 中,这很痛苦。但是, sslmode=disable 是默认值,所以严格来说你不需要它。值得试试?如果你想保留它,你可能需要添加转义字符?透明度:我为 Timescale 工作
-
@greenweeds 我尝试删除 sslmode=disable 但仍然遇到同样的错误。
标签: postgresql docker go docker-compose timescaledb