Melissa Stewart
Melissa Stewart

Reputation: 3625

Can't launch more than 1 cassandra node

I launched a cassandra docker image using the following command,

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

This works fine,

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

Now when I try to launch a second node, this what I get,

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

Still no second node

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

What am I doing wrong here?

Upvotes: 2

Views: 213

Answers (1)

atline
atline

Reputation: 31664

I don't know where you get the information which you can use -seeds 172.17.0.2 to specify seed in this docker image, in fact check the log of n2, it said:

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"

And from it's doc, CASSANDRA_SEEDS env is the correct way, like next:

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

Results:

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

Wait a few time, then check again, we find the cluster has 2 nodes now:

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

Upvotes: 3

Related Questions