Contact Points for a Local Cassandra Instance
I Have Created 2 Cassandra Instances by Deploying It on Docker. One on Port 9042 Other One on 9043. I Have 2 Applications, One Is to Be Connected to 9042 Other...
I have created 2 cassandra instances by deploying it on docker. One on port 9042 other one on 9043.
I have 2 applications, one is to be connected to 9042 other one to 9043. 1st application is connected to 9042 and is running successfully.
The properties i've given for the db are : contactpoints = localhost, port = 9042
The 2nd application which is to be brought up by the second db instance i.e., 9043 is throwing error :
om.datastax.driver.core.Cluster - You listed localhost/0:0:0:0:0:0:0:1:9042 in your contact points, but it wasn't found in the control host's system.peers at startup
The properties i am giving for the db are :
contactpoints = localhost, port = 9043
How can i connect to the cassandra intsance 9043 while the first application is running?
2 Answers
You're specifying localhost, but inside Docker, every localhost is local to the running image, but not to the host machine. As I see you have ports bound to the host network, so you need to specify the IP address of your machine instead of localhost.
P.S. Also, why are you packing the application with Cassandra? It's not how the Docker works - every process should run in separate container...
Every node in Cassandra should bind to a separate ip address,even on physical servers or docker on which 2 instances/nodes are running.