我正在嘗試使用 docker 和 Golang 設置并連接到 Cassandra 單節點實例,但它無法正常工作。我能找到的最接近解決 golanggocql包和 Cassandra 之間的連接問題的信息可以在這里找到:Cassandra cqlsh - connection refused,但是有許多不同的 upvote 答案沒有明確指出哪個是首選。這也是一個受保護的問題(沒有“我也是”),所以很多社區成員似乎都遇到了這個問題。這個問題應該略有不同,因為它使用的是 Docker 并且我已經嘗試了大部分(如果不是上面鏈接的所有解決方案)。version: "3" services: cassandra00: restart: always image: cassandra:latest volumes: - ./db/casdata:/var/lib/cassandra ports: - 7000:7000 - 7001:7001 - 7199:7199 - 9042:9042 - 9160:9160 environment: - CASSANDRA_RPC_ADDRESS=127.0.0.1 - CASSANDRA_BROADCAST_ADDRESS=127.0.0.1 - CASSANDRA_LISTEN_ADDRESS=127.0.0.1 - CASSANDRA_START_RPC=true db: restart: always build: ./db environment: POSTGRES_USER: patientplatypus POSTGRES_PASSWORD: SUPERSECRETFAKEPASSD00T POSTGRES_DB: zennify expose: - "5432" ports: - 5432:5432 volumes: - ./db/pgdata:/var/lib/postgresql/data app: restart: always build: context: . dockerfile: Dockerfile command: bash -c 'while !</dev/tcp/db/5432; do sleep 10; done; realize start --run' # command: bash -c 'while !</dev/tcp/db/5432; do sleep 10; done; go run main.go' ports: - 8000:8000 depends_on: - db - cassandra00 links: - db - cassandra00 volumes: - ./:/go/src/github.com/patientplatypus/webserver/誠然,我對應該在環境部分傳遞給 Cassandra 的監聽地址有點猶豫,所以我只是傳遞了“home”: - CASSANDRA_RPC_ADDRESS=127.0.0.1 - CASSANDRA_BROADCAST_ADDRESS=127.0.0.1 - CASSANDRA_LISTEN_ADDRESS=127.0.0.1如果您嘗試并通過,0.0.0.0則會收到以下錯誤:cassandra00_1 | Exception (org.apache.cassandra.exceptions.ConfigurationException) encountered during startup: listen_address cannot be a wildcard address (0.0.0.0)!cassandra00_1 | listen_address cannot be a wildcard address (0.0.0.0)!cassandra00_1 | ERROR [main] 2018-09-10 21:50:44,530 CassandraDaemon.java:708 - Exception encountered during startup: listen_address cannot be a wildcard address (0.0.0.0)!
Golang gocql無法連接到Cassandra(使用Docker)
慕的地8271018
2023-04-04 14:15:41