不能启动超过1个cassandra节点

lnlaulya  于 2021-06-14  发布在  Cassandra
关注(0)|答案(1)|浏览(294)

我使用以下命令启动了一个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

我做错什么了?

a14dhokn

a14dhokn1#

我不知道你从哪里得到你可以利用的信息 -seeds 172.17.0.2 要在这个docker映像中指定seed,实际上检查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"

医生说, 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

相关问题