I have deployed Cassandra on Amazon Linux EC2 instance in default public subnet, and have installed python driver. Then I am able to successfully run - https://github.com/datastax/python-driver/blob/master/example_core.py on that EC2 instance. It worked fine.
Now, I spawned one more EC2 instance in default public subnet, have installed python cassandra driver on it, and have tried to execute the above-mentioned python file replacing 127.0.0.1 at line 33 with public IP address of the first EC2 instance where single node based cassandra installation is done, but it fails with the following error -
[ec2-user@ip-172-31-43-142 ~]$ python example.py
2018-05-02 09:50:23,061 [WARNING] cassandra.cluster: Cluster.__init__ called
with contact_points specified, but no load_balancing_policy. In the next
major version, this will raise an error; please specify a load-balancing
policy. (contact_points = ['54.244.59.178'], lbp = None)
2018-05-02 09:50:23,064 [DEBUG] cassandra.cluster: Connecting to cluster,
contact points: ['54.244.59.178']; protocol version: 4
2018-05-02 09:50:23,064 [DEBUG] cassandra.io.asyncorereactor: Validated loop
dispatch with cassandra.io.asyncorereactor._AsyncorePipeDispatcher
2018-05-02 09:50:23,064 [DEBUG] cassandra.pool: Host 54.244.59.178 is now
marked up
2018-05-02 09:50:23,067 [DEBUG] cassandra.cluster: [control connection]
Opening new connection to 54.244.59.178
2018-05-02 09:50:23,073 [WARNING] cassandra.cluster: [control connection]
Error connecting to 54.244.59.178:
Traceback (most recent call last):
File "cassandra/cluster.py", line 2798, in
cassandra.cluster.ControlConnection._reconnect_internal
return self._try_connect(host)
File "cassandra/cluster.py", line 2820, in
cassandra.cluster.ControlConnection._try_connect
connection = self._cluster.connection_factory(host.address,
is_control_connection=True)
File "cassandra/cluster.py", line 1205, in
cassandra.cluster.Cluster.connection_factory
return self.connection_class.factory(address, self.connect_timeout,
*args, **kwargs)
File "cassandra/connection.py", line 332, in
cassandra.connection.Connection.factory
conn = cls(host, *args, **kwargs)
File "/usr/local/lib64/python2.7/site-
packages/cassandra/io/asyncorereactor.py", line 344, in __init__
self._connect_socket()
File "cassandra/connection.py", line 371, in
cassandra.connection.Connection._connect_socket
raise socket.error(sockerr.errno, "Tried connecting to %s. Last error: %s" %
([a[4] for a in addresses], sockerr.strerror or sockerr))
error: [Errno 111] Tried connecting to [('54.244.59.178', 9042)]. Last
error:
Connection refused
2018-05-02 09:50:23,079 [ERROR] cassandra.cluster: Control connection failed
to connect, shutting down Cluster:
Traceback (most recent call last):
File "cassandra/cluster.py", line 1270, in
cassandra.cluster.Cluster.connect
self.control_connection.connect()
File "cassandra/cluster.py", line 2766, in
cassandra.cluster.ControlConnection.connect
self._set_new_connection(self._reconnect_internal())
File "cassandra/cluster.py", line 2809, in
cassandra.cluster.ControlConnection._reconnect_internal
raise NoHostAvailable("Unable to connect to any servers", errors)
NoHostAvailable: ('Unable to connect to any servers', {'54.244.59.178':
error(111, "Tried connecting to [('54.244.59.178', 9042)]. Last error:
Connection refused")})
2018-05-02 09:50:23,082 [DEBUG] cassandra.cluster: Shutting down Cluster
Scheduler
2018-05-02 09:50:23,082 [DEBUG] cassandra.cluster: Shutting down control
connection
Traceback (most recent call last):
File "example.py", line 73, in <module>
main()
File "example.py", line 22, in main
session = cluster.connect()
File "cassandra/cluster.py", line 1247, in
cassandra.cluster.Cluster.connect
File "cassandra/cluster.py", line 1283, in
cassandra.cluster.Cluster.connect
File "cassandra/cluster.py", line 1270, in
cassandra.cluster.Cluster.connect
File "cassandra/cluster.py", line 2766, in
cassandra.cluster.ControlConnection.connect
File "cassandra/cluster.py", line 2809, in
cassandra.cluster.ControlConnection._reconnect_internal
cassandra.cluster.NoHostAvailable: ('Unable to connect to any servers',
{'54.244.59.178': error(111, "Tried connecting to [('54.244.59.178', 9042)].
Last error: Connection refused")})
[ec2-user@ip-172-31-43-142 ~]$
Can you please provide tips to resolve it?
Please note that the following inbound ports are open in my security group -
- 9142
- 9042
- 9160
- 7000-7001
- 8182
- 10000
- 7199
- 7437
- 61621
- 80