admin管理员组

文章数量:1336100

I was facing local DC issue connecting to cassandra from intellij IDE. It says that the local DC must be explicitly set. I am providing the below details

hosts : cassandra.prod-az-southcentralus-301.prod.us
port : 9042
Authentication : User & Password
User : svcproduser
Password : xxxx
Keyspace : my_cassandra

Using Apache Cassandra driver 1.4 version . I do not see any option to set local DC.Can you help on how you connect to cassandra from Intellij?

Error :

Unexpected error while creating connection. Since you provided explicit contact points, the local DC must be explicitly set (see basic.load-balancing-policy.local-datacenter in the config, or set it programmatically with SessionBuilder.withLocalDatacenter). Current contact points are: Node(endPoint=cassandra.prod-az-southcentralus-301.prod.us/<unresolved>:9042, hostId=ccb86d7f-7f2d-4c63-9f07-c45c7849db91, hashCode=36891956)=southcentralus-d. Current DCs in this cluster are: southcentralus-d, westus2-d.

I was facing local DC issue connecting to cassandra from intellij IDE. It says that the local DC must be explicitly set. I am providing the below details

hosts : cassandra.prod-az-southcentralus-301.prod.us
port : 9042
Authentication : User & Password
User : svcproduser
Password : xxxx
Keyspace : my_cassandra

Using Apache Cassandra driver 1.4 version . I do not see any option to set local DC.Can you help on how you connect to cassandra from Intellij?

Error :

Unexpected error while creating connection. Since you provided explicit contact points, the local DC must be explicitly set (see basic.load-balancing-policy.local-datacenter in the config, or set it programmatically with SessionBuilder.withLocalDatacenter). Current contact points are: Node(endPoint=cassandra.prod-az-southcentralus-301.prod.us/<unresolved>:9042, hostId=ccb86d7f-7f2d-4c63-9f07-c45c7849db91, hashCode=36891956)=southcentralus-d. Current DCs in this cluster are: southcentralus-d, westus2-d.

Share edited Jan 16 at 4:53 Erick Ramirez 16.4k2 gold badges21 silver badges31 bronze badges asked Nov 19, 2024 at 19:31 Deepak KothariDeepak Kothari 1,76327 silver badges41 bronze badges 1
  • I also made it work by passing a query string parameter as below but passing it as VM options is neat and readable! jdbc:cassandra://cassandra.prod-az-southcentralus-301.prod.us:9042?localdatacenter=southcentralus-d – Deepak Kothari Commented Nov 20, 2024 at 15:56
Add a comment  | 

2 Answers 2

Reset to default 7

Click "Advanced", at "VM options", put "-Ddatastax-java-driver.basic.load-balancing-policy.local-datacenter=datacenter1"

To add to @Jane He's answer, the default load balancing policy for the driver requires the name of the data centre local to the contact points. The driver only contacts nodes in the local DC unless the default behaviour is overridden by allowing remote nodes (not recommended).

For details, see the Cassandra Java driver Quickstart and Load balancing guides. Cheers!

本文标签: