我正在使用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
因此metrictank能够连接到cassandra泊坞窗,但无法连接到gocql。有人可以帮助我解决此问题。
答案 0 :(得分:0)
我认为您应该在每个Cassandra节点上使用唯一的主机名。 cassandra1
,cassandra-2
和cassandra-seed
似乎具有相同的主机名。