PLANNED MAINTENANCE

Hello, DataStax Community!

We want to make you aware of a few operational updates which will be carried out on the site. We are working hard to streamline the login process to integrate with other DataStax resources. As such, you will soon be prompted to update your password. Please note that your username will remain the same.

As we work to improve your user experience, please be aware that login to the DataStax Community will be unavailable for a few hours on:

  • Wednesday, July 15 16:00 PDT | 19:00 EDT | 20:00 BRT
  • Thursday, July 16 00:00 BST | 01:00 CEST | 04:30 IST | 07:00 CST | 09:00 AEST

For more info, check out the FAQ page. Thank you for being a valued member of our community.


question

devopsdymyr_180369 avatar image
devopsdymyr_180369 asked ·

multi node cassandra cluster - load_balancing_policy python connector

Hi have some issue to connect my cassandra from my python connector

Connotor.py contain below code

from cassandra.cluster import Cluster
from cassandra.auth import PlainTextAuthProvider
from cassandra import ReadTimeout
import os

class CassandraConnection():

    def getConnection():
        auth_provider = PlainTextAuthProvider(username ='admin', password='Dog2019')
        cluster=Cluster(['a5ad8e558c23e9a524-1196365.us-west-2.elb.amazonaws.com'], auth_provider=auth_provider)

        session = cluster.connect()
        session.set_keyspace('tonnage')
        cluster.connect()

        return session

While run my python code getting this error

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 = ['a5ad8e558c23e9a524-1196365.us-west-2.elb.amazonaws.com'], lbp = None)

WARNING:

cassandra.pool:Error attempting to reconnect to 100.100.0.3, scheduling retry in 4.0 seconds: [Errno None] Tried connecting to [('100.100.0.3', 9042)]. Last error: timed out

WARNING:

cassandra.pool:Error attempting to reconnect to 100.100.0.2, scheduling retry in 128.0 seconds: [Errno None] Tried connecting to [('100.100.0.2', 9042)]. Last error: timed out

WARNING:

cassandra.pool:Error attempting to reconnect to 100.100.0.2, scheduling retry in 4.0 seconds: [Errno None] Tried connecting to [('100.100.0.2', 9042)]. Last error: timed out

INFO:cassandra.policies:Using datacenter 'datacenter1' for DCAwareRoundRobinPolicy (via host '34.217.153.0'); if incorrect, please specify a local_dc to the constructor, or limit contact points to local cluster nodes INFO:cassandra.cluster:New Cassandra host discovered INFO:cassandra.cluster:New Cassandra host discovered
INFO:cassandra.cluster:Cassandra host 52.26.34.69 removed

kubernetesclusterpython-drivercassandra-connection
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

Erick Ramirez avatar image
Erick Ramirez answered ·

@devopsdymyr_180369 You're getting a warning because you have not specified a load balancing policy in the connection properties.

Also, you're using an elastic load balancer in front of Cassandra and it's an anti-pattern. The Cassandra drivers have built-in load balancing features which you need to take advantage of. You need to provide a list of IP addresses instead -- usually, these are the same as the seeds list (though it doesn't have to be the same).

See the Python driver Getting Started guide for more info. Cheers!

Share
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.