不能启动超过1个Cassandra节点

时间:2019-06-05 20:20:17

标签: docker cassandra

我使用以下命令启动了cassandra docker镜像,

docker run --name=n1 -d cassandra:3.11.4
344138bb96e5326113af6ba5c44a17d8b40ed710fe36ce063677a56ef0c0117

这很好,

docker exec -it n1 nodetool status gives,

Datacenter: datacenter1
=======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
--  Address     Load       Tokens       Owns (effective)  Host ID                               Rack
UN  172.17.0.2  103.7 KiB  256          100.0%            0ca2907d-49b9-4ed4-8bf3-6db99d0c8b45  rack1

现在,当我尝试启动第二个节点时,这就是我得到的,

docker inspect -f '{{ .NetworkSettings.IPAddress}}' n1
172.17.0.2
docker run --name n2 -d cassandra:3.11.4 -seeds 172.17.0.2
1c89b67cb61b049c4a8ae0f21bd0f7cddffad02b7e7964e502cd82e0d2ff2866
docker ps 
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                                         NAMES
344138bb96e5        cassandra:3.11.4    "docker-entrypoint.s…"   2 minutes ago       Up 2 minutes        7000-7001/tcp, 7199/tcp, 9042/tcp, 9160/tcp   n1


docker exec -it n1 nodetool status

仍然没有第二个节点

Datacenter: datacenter1
=======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
--  Address     Load       Tokens       Owns (effective)  Host ID                               Rack
UN  172.17.0.2  103.7 KiB  256          100.0%            0ca2907d-49b9-4ed4-8bf3-6db99d0c8b45  rack1

docker exec -it n2 nodetool status
Error response from daemon: Container 1c89b67cb61b049c4a8ae0f21bd0f7cddffad02b7e7964e502cd82e0d2ff2866 is not running

docker ps -a

CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                     PORTS                                         NAMES
1c89b67cb61b        cassandra:3.11.4    "docker-entrypoint.s…"   2 minutes ago       Exited (1) 2 minutes ago                                                 n2
344138bb96e5        cassandra:3.11.4    "docker-entrypoint.s…"   4 minutes ago       Up 4 minutes               7000-7001/tcp, 7199/tcp, 9042/tcp, 9160/tcp   n1

我在这里做什么错了?

1 个答案:

答案 0 :(得分:3)

我不知道您从何处获得可用于在此Docker映像中指定种子的信息,-seeds 172.17.0.2实际上是检查n2的日志,它说:

getopt: invalid option -- 's'
getopt: invalid option -- 'e'
getopt: invalid option -- 'e'
getopt: invalid option -- 'd'
getopt: invalid option -- 's'
Error parsing arguments! Unknown argument "172.17.0.2"

doc开始,CASSANDRA_SEEDS env是正确的方法,如下所示:

docker run --name n2 -d -e CASSANDRA_SEEDS=172.17.0.2 cassandra:3.11.4

结果:

shubuntu1@shubuntu1:~$ docker run --name n1 -d cassandra:3.11.4
1d1d95f0caeff471c409cd8eda2e77aa5d9b3a60831c284937c305e823016885
shubuntu1@shubuntu1:~$ docker exec -it n1 nodetool status
Datacenter: datacenter1
=======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
--  Address     Load       Tokens       Owns (effective)  Host ID                               Rack
UN  172.17.0.2  112.85 KiB  256          100.0%            c6117826-2fff-48a2-964b-ba403e972154  rack1
shubuntu1@shubuntu1:~$ docker run --name n2 -d -e CASSANDRA_SEEDS=172.17.0.2 cassandra:3.11.4
37e5b84ab92b8b9087e6cff37b146b1f7e337ec9499ce907408abeba11f1985c

等一下,然后再次检查,我们发现集群现在有2个节点:

shubuntu1@shubuntu1:~$ docker exec -it n1 nodetool status
Datacenter: datacenter1
=======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
--  Address     Load       Tokens       Owns (effective)  Host ID                               Rack
UN  172.17.0.3  112.98 KiB  256          100.0%            e61857d3-b924-4fe9-9a68-03d603de7c38  rack1
UN  172.17.0.2  108.62 KiB  256          100.0%            c6117826-2fff-48a2-964b-ba403e972154  rack1