我正在嘗試使用 docker 和 Golang 設(shè)置并連接到 Cassandra 單節(jié)點(diǎn)實(shí)例,但它無法正常工作。我能找到的最接近解決 golanggocql包和 Cassandra 之間的連接問題的信息可以在這里找到:Cassandra cqlsh - connection refused,但是有許多不同的 upvote 答案沒有明確指出哪個(gè)是首選。這也是一個(gè)受保護(hù)的問題(沒有“我也是”),所以很多社區(qū)成員似乎都遇到了這個(gè)問題。這個(gè)問題應(yīng)該略有不同,因?yàn)樗褂玫氖?Docker 并且我已經(jīng)嘗試了大部分(如果不是上面鏈接的所有解決方案)。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/誠然,我對(duì)應(yīng)該在環(huán)境部分傳遞給 Cassandra 的監(jiān)聽地址有點(diǎn)猶豫,所以我只是傳遞了“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則會(huì)收到以下錯(cuò)誤: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