我正在使用docker-compose文件部署一个以cassandra集群为后台的metrictank。
version: '2'
services:
metrictank0:
hostname: metrictank0
image: grafana/metrictank
expose:
- 6060
ports:
- "2003:2003"
environment:
WAIT_HOSTS: cassandra-seed:9042
WAIT_TIMEOUT: 3000
MT_CASSANDRA_CREATE_KEYSPACE: "true"
MT_CASSANDRA_IDX_CREATE_KEYSPACE: "true"
MT_CLUSTER_BIND_ADDR: "metrictank0:7946"
MT_CLUSTER_MODE: shard
MT_CLUSTER_PRIMARY_NODE: "true"
MT_INSTANCE: metrictank0
MT_LOG_LEVEL: info
links:
- cassandra-seed:9042
metrictank-q0:
hostname: metrictank-q0
image: grafana/metrictank
expose:
- 6060
environment:
WAIT_HOSTS: metrictank0:6060
WAIT_TIMEOUT: 3000
MT_CARBON_IN_ENABLED: "false"
MT_CASSANDRA_ENABLED: "false"
MT_CASSANDRA_IDX_ENABLED: "false"
MT_KAFKA_MDM_IN_ENABLED: "false"
MT_KAFKA_CLUSTER_ENABLED: "false"
MT_CLUSTER_BIND_ADDR: "metrictank-q0:7946"
MT_CLUSTER_MODE: query
MT_CLUSTER_PEERS: metrictank0,metrictank1
MT_CLUSTER_PRIMARY_NODE: "false"
MT_INSTANCE: metrictank-q0
MT_LOG_LEVEL: info
MT_CLUSTER_GOSSIP_SETTLE_PERIOD: "10s"
links:
- metrictank0
cassandra-seed:
hostname: cassandra
image: cassandra
ports:
- "9042:9042"
environment:
- "CASSANDRA_CLUSTER_NAME=MyCluster"
# needed for setting up custom cluster name
- "CASSANDRA_DC=datacenter1"
- "CASSANDRA_ENDPOINT_SNITCH=GossipingPropertyFileSnitch"
# restart: always
cassandra1:
hostname: cassandra
image: cassandra
environment:
- "CASSANDRA_SEEDS=cassandra-seed"
- "CASSANDRA_CLUSTER_NAME=MyCluster"
# needed for setting up custom cluster name
- "CASSANDRA_DC=datacenter1"
- "CASSANDRA_ENDPOINT_SNITCH=GossipingPropertyFileSnitch"
depends_on:
- cassandra-seed
# restart: always
cassandra2:
hostname: cassandra
image: cassandra
environment:
- "CASSANDRA_SEEDS=cassandra-seed"
- "CASSANDRA_CLUSTER_NAME=MyCluster"
# needed for setting up custom cluster name
- "CASSANDRA_DC=datacenter2"
- "CASSANDRA_ENDPOINT_SNITCH=GossipingPropertyFileSnitch"
depends_on:
- cassandra-seed
# restart: always
graphite:
hostname: graphite
image: raintank/graphite-mt
ports:
- "8080:80"
environment:
GRAPHITE_CLUSTER_SERVERS: metrictank-q0:6060
GRAPHITE_STATSD_HOST: statsdaemon
SINGLE_TENANT: "true"
WSGI_PROCESSES: 4
WSGI_THREADS: 25
statsdaemon:
hostname: statsdaemon
image: raintank/statsdaemon
ports:
- "8125:8125/udp"
但是metrictank docker在运行几秒钟后就停止了,而且它的日志也显示出来了。
2020/06/15 12:48:14 waiting for cassandra-seed:9042 to become up...
2020/06/15 12:48:17 cassandra-seed:9042 is up. maintained connection for 3 seconds!
2020-06-15 12:48:17.217 [INFO] logging level set to 'info'
2020-06-15 12:48:17.218 [INFO] Metrictank starting. version: v0.13.1 - runtime: go1.11.4
2020/06/15 12:48:17 gocql: dns error: lookup cassandra on 127.0.0.11:53: no such host
2020-06-15 12:48:17.221 [ERROR] cassandra_store: failed to create cassandra session. gocql: unable to create session: failed to resolve any of the provided hostnames
2020-06-15 12:48:17.222 [FATAL] failed to initialize cassandra backend store. gocql: unable to create session: failed to resolve any of the provided hostnames
So metrictank is able to connect to the cassandra docker but it is not able to connect to the gocql.Can anyone help me in solving this problem.
我认为你应该有每个Cassandra节点的唯一主机名。cassandra1
, cassandra-2
和 cassandra-seed
似乎有相同的主机名。